# Combine salesforce with plaid financial data

> Salesforce household and Plaid balances in one regulated edge response. For "combine salesforce with plaid financial data", store SALESFORCE_ACCESS_TOKEN, PLAID_SECRET in Secret Vault, call https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}} from a Worker, and let Mobile App (iOS & Android) hit only https://realcomposer.com/v1/workspace/combine-salesforce-with-plaid-accounts with an rc_live_ client token. POST upstream calls are not stored in caches.default; clients must send JSON bodies and headers forward unchanged.

- Canonical page: https://realcomposer.com/recipes/combine-salesforce-with-plaid-accounts
- Client platform: Mobile App (iOS & Android)
- Upstream services: Salesforce, Plaid
- Category: Multi-API Aggregation
- JSON version: https://realcomposer.com/recipes/combine-salesforce-with-plaid-accounts.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=combine-salesforce-with-plaid-accounts&via=agent

## Problem: Waterfall latency from multiple Salesforce and Plaid requests

Mobile App (iOS & Android) widgets often await Salesforce and Plaid sequentially, multiplying TLS handshakes on cellular networks and amplifying failure rates.

- Race conditions between parallel manual fetches
- Higher mobile data usage from redundant JSON
- Timeouts when any upstream exceeds cellular RTT

## Solution steps

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

2. **Target the real upstream URL**: Point step salesforce at https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}} with POST. Add output mapping fields that mirror the JSON contract your screen already expects. POST pipelines set cache TTL to 0 because RealComposer only stores GET responses at the edge.

3. **Call from Mobile App (iOS & Android)**: Call https://realcomposer.com/v1/workspace/combine-salesforce-with-plaid-accounts with a restricted rc_live_ client token. Mobile App (iOS & Android) never sends upstream secrets.

```
let url = URL(string: "https://realcomposer.com/v1/workspace/combine-salesforce-with-plaid-accounts")!
var request = URLRequest(url: url)
request.addValue("Bearer rc_live_token", forHTTPHeaderField: "Authorization")
```

## 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": "Combine salesforce with plaid financial data",
  "method": "POST",
  "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
    },
    {
      "stepKey": "plaid",
      "upstreamUrlTemplate": "https://production.plaid.com/accounts/get",
      "httpMethod": "POST",
      "headersTemplate": {
        "Content-Type": "application/json"
      },
      "timeoutMs": 10000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "salesforce.contactId",
        "sourcePath": "Id",
        "type": "string",
        "sourceStep": "salesforce"
      },
      {
        "targetPath": "salesforce.email",
        "sourcePath": "Email",
        "type": "string",
        "sourceStep": "salesforce"
      },
      {
        "targetPath": "plaid.accountId",
        "sourcePath": "accounts.0.account_id",
        "type": "string",
        "sourceStep": "plaid"
      },
      {
        "targetPath": "plaid.name",
        "sourcePath": "accounts.0.name",
        "type": "string",
        "sourceStep": "plaid"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X POST "https://realcomposer.com/v1/workspace/combine-salesforce-with-plaid-accounts" \
  -H "Authorization: Bearer rc_live_client_token" \
  -H "Content-Type: application/json" \
  -d '{"model":"example"}'
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_combine-",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "combine-salesforce-with-plaid-accounts"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "salesforce_contactId": "sample",
  "salesforce_email": "sample",
  "plaid_accountId": "sample",
  "plaid_name": "sample"
}
```

## FAQ

### Is it safe to log Salesforce responses in Mobile App (iOS & Android)?

Point Mobile App (iOS & Android) at /recipes/combine-salesforce-with-plaid-accounts edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Will Anthropic or Linear prompt bodies be rewritten?

combine-salesforce-with-plaid-accounts keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache.

### Can I restrict which domains call this pipeline?

Rotate vault secrets for combine-salesforce-with-plaid-accounts anytime; clients keep the same rc_live_ token.
