# Merge salesforce opportunities with stripe mrr data

> Salesforce Opportunity and Stripe subscription MRR merged for dashboards. For "merge salesforce opportunities with stripe mrr data", store SALESFORCE_ACCESS_TOKEN, STRIPE_SECRET_KEY in Secret Vault, call https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Opportunity/{{query.opportunityId}} from a Worker, and let Frontend / Web hit only https://realcomposer.com/v1/workspace/merge-salesforce-opportunities-stripe-mrr with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/merge-salesforce-opportunities-stripe-mrr
- Client platform: Frontend / Web
- Upstream services: Salesforce, Stripe
- Category: Multi-API Aggregation
- JSON version: https://realcomposer.com/recipes/merge-salesforce-opportunities-stripe-mrr.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=merge-salesforce-opportunities-stripe-mrr&via=agent

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

Frontend / Web widgets often await Salesforce and Stripe 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**: Create SALESFORCE_ACCESS_TOKEN, STRIPE_SECRET_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

2. **Set headers, mapping, and cache TTL**: Point step salesforce at https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Opportunity/{{query.opportunityId}} with GET. Add output mapping fields that mirror the JSON contract your screen already expects. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).

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

```
const res = await fetch('https://realcomposer.com/v1/workspace/merge-salesforce-opportunities-stripe-mrr', {
  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": "Merge salesforce opportunities with stripe mrr data",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "salesforce",
      "upstreamUrlTemplate": "https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Opportunity/{{query.opportunityId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.SALESFORCE_ACCESS_TOKEN}}"
      },
      "timeoutMs": 3000
    },
    {
      "stepKey": "stripe",
      "upstreamUrlTemplate": "https://api.stripe.com/v1/customers/{{query.customerId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.STRIPE_SECRET_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "salesforce.contactId",
        "sourcePath": "Id",
        "type": "string",
        "sourceStep": "salesforce"
      },
      {
        "targetPath": "salesforce.email",
        "sourcePath": "Email",
        "type": "string",
        "sourceStep": "salesforce"
      },
      {
        "targetPath": "stripe.customerId",
        "sourcePath": "id",
        "type": "string",
        "sourceStep": "stripe"
      },
      {
        "targetPath": "stripe.email",
        "sourcePath": "email",
        "type": "string",
        "sourceStep": "stripe"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/merge-salesforce-opportunities-stripe-mrr" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_merge-sa",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "merge-salesforce-opportunities-stripe-mrr"
  },
  "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",
  "stripe_customerId": "sample",
  "stripe_email": "sample"
}
```

## FAQ

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

Store SALESFORCE_ACCESS_TOKEN, STRIPE_SECRET_KEY for merge-salesforce-opportunities-stripe-mrr. Frontend / Web never sees decrypted values.

### Does POST traffic get cached?

merge-salesforce-opportunities-stripe-mrr vault headers attach server-side, but Anthropic or OpenAI model and messages must come from the client body.

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

Rotate vault secrets for merge-salesforce-opportunities-stripe-mrr anytime; clients keep the same rc_live_ token.
