# Stitch contentful entries with shopify products api

> Contentful marketing fields plus Shopify SKU inventory in parallel. For "stitch contentful entries with shopify products api", store CONTENTFUL_ACCESS_TOKEN, SHOPIFY_ACCESS_TOKEN in Secret Vault, call https://cdn.contentful.com/spaces/{{query.spaceId}}/entries from a Worker, and let Next.js / React hit only https://realcomposer.com/v1/workspace/stitch-contentful-with-shopify-products with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/stitch-contentful-with-shopify-products
- Client platform: Next.js / React
- Upstream services: Contentful, Shopify
- Category: Multi-API Aggregation
- JSON version: https://realcomposer.com/recipes/stitch-contentful-with-shopify-products.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=stitch-contentful-with-shopify-products&via=agent

## Problem: Serial Contentful and Shopify calls slow Next.js / React pages

Each extra Contentful and Shopify hop adds hundreds of milliseconds and another OAuth refresh path your UI must manage.

- One slow upstream blocking an entire page
- Partial failures leaving UI in inconsistent states
- Duplicate auth refresh logic per service

## Solution steps

1. **Add vault secrets for this pipeline**: Store CONTENTFUL_ACCESS_TOKEN, SHOPIFY_ACCESS_TOKEN in the vault. Next.js / React never embeds the raw secret, only a revocable rc_live_ client token.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://cdn.contentful.com/spaces/{{query.spaceId}}/entries, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Call from Next.js / React**: Allowed origins on the token should list every Next.js / React host that calls this URL.

```
// app/api route or client component
const res = await fetch('https://realcomposer.com/v1/workspace/stitch-contentful-with-shopify-products', {
  cache: 'no-store',
  headers: { Authorization: 'Bearer rc_live_your_token' }
});
```

## Pipeline config

Import this config into a RealComposer pipeline. `{{secrets.NAME}}` values are read from the encrypted Secret Vault at request time, so the client never sees them.

```json
{
  "name": "Stitch contentful entries with shopify products api",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "contentful",
      "upstreamUrlTemplate": "https://cdn.contentful.com/spaces/{{query.spaceId}}/entries",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.CONTENTFUL_ACCESS_TOKEN}}"
      },
      "timeoutMs": 3000
    },
    {
      "stepKey": "shopify",
      "upstreamUrlTemplate": "https://{{secrets.SHOPIFY_STORE}}.myshopify.com/admin/api/2026-10/products.json?limit=5",
      "httpMethod": "GET",
      "headersTemplate": {
        "X-Shopify-Access-Token": "{{secrets.SHOPIFY_ACCESS_TOKEN}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "contentful.entryId",
        "sourcePath": "items.0.sys.id",
        "type": "string",
        "sourceStep": "contentful"
      },
      {
        "targetPath": "contentful.title",
        "sourcePath": "items.0.fields.title",
        "type": "string",
        "sourceStep": "contentful"
      },
      {
        "targetPath": "shopify.productId",
        "sourcePath": "products.0.id",
        "type": "number",
        "sourceStep": "shopify"
      },
      {
        "targetPath": "shopify.title",
        "sourcePath": "products.0.title",
        "type": "string",
        "sourceStep": "shopify"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/stitch-contentful-with-shopify-products" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_stitch-c",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "stitch-contentful-with-shopify-products"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "contentful_entryId": "sample",
  "contentful_title": "sample",
  "shopify_productId": "sample",
  "shopify_title": "sample"
}
```

## FAQ

### Which Contentful credential belongs in the vault for this pipeline?

Point Next.js / React at /recipes/stitch-contentful-with-shopify-products edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Does POST traffic get cached?

stitch-contentful-with-shopify-products vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.

### What happens if an upstream step times out?

Rotate vault secrets for stitch-contentful-with-shopify-products anytime; clients keep the same rc_live_ token.
