# How to Call Private REST APIs from Webflow Custom Code Securely

> Webflow is a purely static and frontend visual builder with no backend server. To call private APIs from Webflow custom code without revealing secrets in the browser inspector, route requests through RealComposer. RealComposer stores your API keys in an AES-256-GCM vault, injects credentials at the edge, and handles CORS headers automatically.

- Canonical page: https://realcomposer.com/recipes/call-private-api-from-webflow-securely
- Client platform: Webflow
- Upstream services: Airtable, Stripe, HubSpot
- Category: Security & Secret Vault
- JSON version: https://realcomposer.com/recipes/call-private-api-from-webflow-securely.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=call-private-api-from-webflow-securely&via=agent

## Problem: Webflow Has No Server Environment for Secrets

When you paste JavaScript into Webflow Page Settings or Custom Embed elements, that script runs exclusively in visitors browsers. Any API key written in Webflow custom code is visible to anyone inspecting page source or network requests.

- Exposed Airtable Personal Access Tokens, allowing full base scraping
- Exposed CRM credentials allowing attackers to download lead lists
- Inability to make authenticated API requests directly from Webflow forms

## Solution steps

1. **Add API Credentials to RealComposer**: Store your upstream Bearer token or Basic Auth keys in the Secret Vault.

2. **Configure Webflow Origin Protection**: Whitelist your Webflow site domain (e.g., https://your-site.webflow.io).

3. **Paste Embed Script in Webflow**: In Webflow Custom Code, fetch your RealComposer edge URL with your public token.

```
fetch("https://realcomposer.com/v1/acme/lead-submit", {
  method: "POST",
  headers: { "Authorization": "Bearer rc_live_..." },
  body: JSON.stringify({ email: emailField.value })
});
```

## 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": "Webflow Secure API Gateway",
  "method": "POST",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "hubspotLead",
      "upstreamUrlTemplate": "https://api.hubapi.com/crm/v3/objects/contacts",
      "httpMethod": "POST",
      "headersTemplate": {
        "Authorization": "Bearer {{secrets.HUBSPOT_ACCESS_TOKEN}}",
        "Content-Type": "application/json"
      },
      "timeoutMs": 4000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "contactId",
        "sourceStep": "hubspotLead",
        "sourcePath": "id"
      },
      {
        "targetPath": "createdAt",
        "sourceStep": "hubspotLead",
        "sourcePath": "createdAt"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X POST "https://realcomposer.com/v1/acme/lead-submit" \
  -H "Authorization: Bearer rc_live_..." \
  -H "Content-Type: application/json" \
  -d '{"email":"lead@example.com"}'
```

## Payload before and after

Raw upstream response:

```json
{
  "id": "991024",
  "properties": {
    "email": "lead@startup.com",
    "hs_object_id": "991024",
    "createdate": "2026-11-01"
  },
  "createdAt": "2026-11-01T12:00:00Z",
  "updatedAt": "2026-11-01T12:00:00Z",
  "archived": false
}
```

Slimmed RealComposer response:

```json
{
  "contactId": "991024",
  "createdAt": "2026-11-01T12:00:00Z"
}
```

## FAQ

### Why not use Make or Zapier from Webflow?

Make and Zapier take 3 to 10 seconds to respond, creating a poor user experience on form submissions. RealComposer executes at the edge in sub-50ms.

### Does RealComposer fix Webflow CORS errors?

Yes. RealComposer handles CORS preflight (OPTIONS) automatically and attaches the necessary Access-Control headers.
