# Salesforce api response too large trim fields mobile

> 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.

- Canonical page: https://realcomposer.com/recipes/trim-salesforce-json-for-mobile
- Client platform: React Native
- Upstream services: Salesforce
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/trim-salesforce-json-for-mobile.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=trim-salesforce-json-for-mobile&via=agent

## Problem: Unmapped Salesforce fields waste bandwidth

Salesforce returns nested CRM, audit, and configuration objects. React Native parses them on the main thread even when the UI binds three fields.

- Large arrays kept in memory after navigation
- Analytics showing poor LCP on API-heavy screens
- Developers shipping defensive null checks for unused paths

## Solution steps

1. **Bind vault keys to the Worker**: Add SALESFORCE_ACCESS_TOKEN to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Set headers, mapping, and cache TTL**: 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.

3. **Call from React Native**: Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.

```
const res = await fetch('https://realcomposer.com/v1/workspace/trim-salesforce-json-for-mobile', {
  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": "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"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/trim-salesforce-json-for-mobile" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "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"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "contactId": "sample",
  "email": "sample",
  "name": "sample"
}
```

## FAQ

### Is it safe to log Salesforce responses in React Native?

Use scoped tokens where the vendor allows them on trim-salesforce-json-for-mobile. Admin keys stay {{secrets.*}} references only.

### When does edge caching apply to this recipe?

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.

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

Rotate vault secrets for trim-salesforce-json-for-mobile anytime; clients keep the same rc_live_ token.
