# Call salesforce api from bubble io securely

> RealComposer mediates Salesforce REST for Bubble workflows. For "call salesforce api from bubble io securely", 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 Bubble.io hit only https://realcomposer.com/v1/workspace/call-salesforce-from-bubble-securely with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/call-salesforce-from-bubble-securely
- Client platform: Bubble.io
- Upstream services: Salesforce
- Category: Security & Secret Vault
- JSON version: https://realcomposer.com/recipes/call-salesforce-from-bubble-securely.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=call-salesforce-from-bubble-securely&via=agent

## Problem: Why Bubble.io leaks Salesforce credentials

Attackers routinely extract Salesforce secrets from Bubble.io builds. Direct browser calls also expose internal error payloads with hostnames.

- Production Salesforce keys copied from Bubble.io bundles
- Compliance violations after credential leaks
- Attackers replaying vault-grade scopes from a laptop

## Solution steps

1. **Add vault secrets for this pipeline**: Store SALESFORCE_ACCESS_TOKEN in the vault. Bubble.io never embeds the raw secret, only a revocable rc_live_ client token.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://{{secrets.SALESFORCE_INSTANCE}}.my.salesforce.com/services/data/v68.0/sobjects/Contact/{{query.contactId}}, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Connect Bubble API Connector**: Allowed origins on the token should list every Bubble.io host that calls this URL.

```
API Connector GET https://realcomposer.com/v1/workspace/call-salesforce-from-bubble-securely
Private header: 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": "Call salesforce api from bubble io securely",
  "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/call-salesforce-from-bubble-securely" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_call-sal",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "call-salesforce-from-bubble-securely"
  },
  "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

### Can Bubble.io call Salesforce without holding the production key?

Use scoped tokens where the vendor allows them on call-salesforce-from-bubble-securely. Admin keys stay {{secrets.*}} references only.

### How do I forward JSON bodies to POST upstreams?

call-salesforce-from-bubble-securely POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.

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

Rotate vault secrets for call-salesforce-from-bubble-securely anytime; clients keep the same rc_live_ token.
