{
  "slug": "slim-contentful-api-response-mobile",
  "title": "Contentful api response slim down for mobile app",
  "metaTitle": "Contentful api response slim down - RealComposer",
  "metaDescription": "Contentful api response slim down for mobile app. Returns entry sys id fields and locale only from Delive. Map only UI fields from Contentful before.",
  "headline": "Lightweight CMS payloads on cellular",
  "category": "slimmer",
  "categoryLabel": "Payload Slimmer",
  "urgency": 8,
  "clientPlatform": "React Native",
  "upstreamServices": [
    "Contentful"
  ],
  "searchIntentQuery": "contentful api response slim down for mobile app",
  "directAnswerSummary": "Returns entry sys id fields and locale only from Delivery API. For \"contentful api response slim down for mobile app\", store CONTENTFUL_ACCESS_TOKEN in Secret Vault, call https://cdn.contentful.com/spaces/{{query.spaceId}}/entries from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/slim-contentful-api-response-mobile with an rc_live_ client token.",
  "problem": {
    "title": "Unmapped Contentful fields waste bandwidth",
    "explanation": "Contentful returns nested CRM, audit, and configuration objects. React Native parses them on the main thread even when the UI binds three fields.",
    "risks": [
      "Large arrays kept in memory after navigation",
      "Analytics showing poor LCP on API-heavy screens",
      "Developers shipping defensive null checks for unused paths"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Bind vault keys to the Worker",
      "description": "Store CONTENTFUL_ACCESS_TOKEN in the vault. React Native never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "Use GET against https://cdn.contentful.com/spaces/{{query.spaceId}}/entries. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache)."
    },
    {
      "stepNumber": 3,
      "title": "Call from React Native",
      "description": "Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/slim-contentful-api-response-mobile', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Contentful api response slim down for mobile app",
    "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
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "entryId",
          "sourcePath": "items.0.sys.id",
          "type": "string",
          "sourceStep": "contentful"
        },
        {
          "targetPath": "title",
          "sourcePath": "items.0.fields.title",
          "type": "string",
          "sourceStep": "contentful"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_slim-con",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "slim-contentful-api-response-mobile"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "entryId": "sample",
    "title": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/slim-contentful-api-response-mobile\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "What should React Native store instead of Contentful secrets?",
      "answer": "Point React Native at /recipes/slim-contentful-api-response-mobile edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins."
    },
    {
      "question": "Will Anthropic or Linear prompt bodies be rewritten?",
      "answer": "Cache key for slim-contentful-api-response-mobile: internal edge-cache path plus sorted query. Identical params hit; vary userId per user."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Rotate vault secrets for slim-contentful-api-response-mobile anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "simplify-airtable-json-structure",
    "optimize-api-response-size-react-native"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/slim-contentful-api-response-mobile",
    "markdown": "https://realcomposer.com/recipes/slim-contentful-api-response-mobile.md",
    "json": "https://realcomposer.com/recipes/slim-contentful-api-response-mobile.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=slim-contentful-api-response-mobile&via=agent"
  }
}