# Call mailchimp api from webflow without exposing api key

> RealComposer subscribes list members with API key injected server-side. For "call mailchimp api from webflow without exposing api key", store MAILCHIMP_BASIC_AUTH in Secret Vault, call https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10 from a Worker, and let Webflow hit only https://realcomposer.com/v1/workspace/call-mailchimp-from-webflow-securely with an rc_live_ client token.

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

## Problem: Mailchimp keys in Webflow network tabs

Webflow ships code or scripts to end-user devices. Any Mailchimp bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.

- Shared Webflow projects revealing Mailchimp tokens
- Sudden Mailchimp quota burn from scripted abuse
- Inability to rotate keys without redeploying clients

## Solution steps

1. **Add vault secrets for this pipeline**: Add MAILCHIMP_BASIC_AUTH to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Target the real upstream URL**: Configure headersTemplate to inject vault secrets, target https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10, and Add output mapping fields that mirror the JSON contract your screen already expects.

3. **Call from Webflow custom code**: Call https://realcomposer.com/v1/workspace/call-mailchimp-from-webflow-securely with a restricted rc_live_ client token. Webflow never sends upstream secrets.

```
fetch('https://realcomposer.com/v1/workspace/call-mailchimp-from-webflow-securely', {
  headers: { Authorization: 'Bearer rc_live_your_token' }
}).then(r => r.json());
```

## 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 mailchimp api from webflow without exposing api key",
  "method": "GET",
  "cacheTtlSeconds": 0,
  "authMode": "client_token",
  "steps": [
    {
      "stepKey": "mailchimp",
      "upstreamUrlTemplate": "https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10",
      "httpMethod": "GET",
      "headersTemplate": {
        "Authorization": "Basic {{secrets.MAILCHIMP_BASIC_AUTH}}"
      },
      "timeoutMs": 3000
    }
  ],
  "outputMapping": {
    "version": 1,
    "fields": [
      {
        "targetPath": "memberId",
        "sourcePath": "members.0.id",
        "type": "string",
        "sourceStep": "mailchimp"
      },
      {
        "targetPath": "email",
        "sourcePath": "members.0.email_address",
        "type": "string",
        "sourceStep": "mailchimp"
      },
      {
        "targetPath": "status",
        "sourcePath": "members.0.status",
        "type": "string",
        "sourceStep": "mailchimp"
      }
    ]
  }
}
```

## Call the pipeline

```bash
curl -X GET "https://realcomposer.com/v1/workspace/call-mailchimp-from-webflow-securely" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_call-mai",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "call-mailchimp-from-webflow-securely"
  },
  "payload": {
    "id": "sample_id",
    "status": "active",
    "nested": {
      "tags": [
        "demo"
      ],
      "internal": true
    },
    "unused_blob": {
      "foo": "bar",
      "bar": "baz"
    }
  }
}
```

Slimmed RealComposer response:

```json
{
  "memberId": "sample",
  "email": "sample",
  "status": "sample"
}
```

## FAQ

### Does Webflow need CORS changes after adding RealComposer?

Yes for call-mailchimp-from-webflow-securely. Ship only an rc_live_ client token in Webflow; RealComposer injects MAILCHIMP_BASIC_AUTH on https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10.

### What cache key does RealComposer use?

call-mailchimp-from-webflow-securely forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates.

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

Upstream steps in call-mailchimp-from-webflow-securely honor timeoutMs and optional fallback JSON without leaking secrets.
