{
  "slug": "trim-salesforce-json-for-mobile",
  "title": "Salesforce api response too large trim fields mobile",
  "metaTitle": "Salesforce api response too large - RealComposer",
  "metaDescription": "Salesforce api response too large trim fields mobile. Map only id name email and owner fields; drop nested at. Map only UI fields from Salesforce.",
  "headline": "Slim Salesforce sObject payloads for mobile",
  "category": "slimmer",
  "categoryLabel": "Payload Slimmer",
  "urgency": 9,
  "clientPlatform": "React Native",
  "upstreamServices": [
    "Salesforce"
  ],
  "searchIntentQuery": "salesforce api response too large trim fields mobile",
  "directAnswerSummary": "Map only id name email and owner fields; drop nested attributes URLs. For \"salesforce api response too large trim fields mobile\", store SALESFORCE_ACCESS_TOKEN in Secret Vault, call https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}} from a Worker, and let React Native hit only https://realcomposer.com/v1/workspace/trim-salesforce-json-for-mobile with an rc_live_ client token.",
  "problem": {
    "title": "Unmapped Salesforce fields waste bandwidth",
    "explanation": "Salesforce 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": "Add SALESFORCE_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream."
    },
    {
      "stepNumber": 2,
      "title": "Set headers, mapping, and cache TTL",
      "description": "Configure headersTemplate to inject vault secrets, target https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}, and Map only the UI fields in output mapping so clients never download audit or nested blobs."
    },
    {
      "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/trim-salesforce-json-for-mobile', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Salesforce api response too large trim fields mobile",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "salesforce",
        "upstreamUrlTemplate": "https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.SALESFORCE_ACCESS_TOKEN}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "contactId",
          "sourcePath": "Id",
          "type": "string",
          "sourceStep": "salesforce"
        },
        {
          "targetPath": "email",
          "sourcePath": "Email",
          "type": "string",
          "sourceStep": "salesforce"
        },
        {
          "targetPath": "name",
          "sourcePath": "Name",
          "type": "string",
          "sourceStep": "salesforce"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_trim-sal",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "trim-salesforce-json-for-mobile"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "contactId": "sample",
    "email": "sample",
    "name": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/trim-salesforce-json-for-mobile\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Is it safe to log Salesforce responses in React Native?",
      "answer": "Use scoped tokens where the vendor allows them on trim-salesforce-json-for-mobile. Admin keys stay {{secrets.*}} references only."
    },
    {
      "question": "When does edge caching apply to this recipe?",
      "answer": "trim-salesforce-json-for-mobile keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache."
    },
    {
      "question": "What happens if an upstream step times out?",
      "answer": "Rotate vault secrets for trim-salesforce-json-for-mobile anytime; clients keep the same rc_live_ token."
    }
  ],
  "relatedRecipeSlugs": [
    "trim-stripe-json-for-mobile-apps",
    "filter-unnecessary-fields-rest-api"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/trim-salesforce-json-for-mobile",
    "markdown": "https://realcomposer.com/recipes/trim-salesforce-json-for-mobile.md",
    "json": "https://realcomposer.com/recipes/trim-salesforce-json-for-mobile.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=trim-salesforce-json-for-mobile&via=agent"
  }
}