# Secure API Proxy for Bubble.io API Connector

> To prevent API keys from leaking through the Bubble.io API Connector, route high-value third-party requests through RealComposer. RealComposer stores credentials encrypted at the edge and filters bloated responses, reducing the payload size that Bubble servers must parse.

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

## Problem: Bubble API Connector Key Visibility Risks

In Bubble.io, shared team editors can see plaintext keys in the API Connector plugin tab, and client-side executed calls can expose headers to the browser console. Furthermore, Bubble charges for Workload Units (WU) when parsing massive third-party JSON payloads.

- Team collaborators inspecting production keys in the Bubble editor
- High Workload Unit (WU) consumption when Bubble parses 100+ unneeded fields
- Exposed credentials during browser network debugging

## Solution steps

1. **Configure Keys in Secret Vault**: Keep master API keys out of Bubble and in RealComposer AES-256 vault.

2. **Slim the Response for Bubble**: Use the Visual Field Picker to extract only the 3-5 fields Bubble needs.

3. **Call RealComposer in Bubble API Connector**: Initialize call in Bubble pointing to your clean edge URL.

## 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": "Bubble.io Slimmed Proxy",
  "method": "GET",
  "cacheTtlSeconds": 60,
  "steps": [
    {
      "stepKey": "data",
      "upstreamUrlTemplate": "https://api.stripe.com/v1/invoices/{{query.invoiceId}}",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.STRIPE_SECRET_KEY}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "invoiceId",
        "sourceStep": "data",
        "sourcePath": "id"
      },
      {
        "targetPath": "amountDue",
        "sourceStep": "data",
        "sourcePath": "amount_due",
        "type": "number"
      },
      {
        "targetPath": "status",
        "sourceStep": "data",
        "sourcePath": "status"
      },
      {
        "targetPath": "hostedUrl",
        "sourceStep": "data",
        "sourcePath": "hosted_invoice_url"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/acme/bubble-invoice?invoiceId=in_123"
```

## Payload before and after

Raw upstream response:

```json
{
  "id": "in_123",
  "amount_due": 4900,
  "status": "paid",
  "hosted_invoice_url": "https://invoice.stripe.com/123"
}
```

Slimmed RealComposer response:

```json
{
  "invoiceId": "in_123",
  "amountDue": 4900,
  "status": "paid",
  "hostedUrl": "https://invoice.stripe.com/123"
}
```

## FAQ

### Does trimming JSON save Bubble Workload Units?

Yes. Bubble consumes compute based on payload volume and JSON complexity. Slimming payloads by 80%+ reduces WU consumption.
