# Mailchimp campaign stats trim for analytics card

> Opens clicks and send time without full report trees. For "mailchimp campaign stats trim for analytics card", 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 Retool hit only https://realcomposer.com/v1/workspace/trim-mailchimp-campaign-stats-json with an rc_live_ client token.

- Canonical page: https://realcomposer.com/recipes/trim-mailchimp-campaign-stats-json
- Client platform: Retool
- Upstream services: Mailchimp
- Category: Payload Slimmer
- JSON version: https://realcomposer.com/recipes/trim-mailchimp-campaign-stats-json.json
- Install in RealComposer (free plan, pre-fills this pipeline): https://realcomposer.com/dashboard/pipelines/new?recipe=trim-mailchimp-campaign-stats-json&via=agent

## Problem: Mailchimp JSON bloat on Retool

Oversized Mailchimp payloads inflate parse time and mobile data charges for Retool users.

- Main-thread JSON parse stalls on low-end phones
- Accidentally exposing PII fields to the client
- Downstream components re-render on unused keys

## Solution steps

1. **Store upstream credentials in Secret Vault**: Create MAILCHIMP_BASIC_AUTH vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders.

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 Map only the UI fields in output mapping so clients never download audit or nested blobs.

3. **Query from Retool**: Allowed origins on the token should list every Retool host that calls this URL.

```
// REST resource or JS query
const rows = await fetch('https://realcomposer.com/v1/workspace/trim-mailchimp-campaign-stats-json', {
  headers: { Authorization: 'Bearer rc_live_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": "Mailchimp campaign stats trim for analytics card",
  "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/trim-mailchimp-campaign-stats-json" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_trim-mai",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "trim-mailchimp-campaign-stats-json"
  },
  "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

### Is it safe to log Mailchimp responses in Retool?

Yes for trim-mailchimp-campaign-stats-json. Ship only an rc_live_ client token in Retool; RealComposer injects MAILCHIMP_BASIC_AUTH on https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10.

### Will Anthropic or Linear prompt bodies be rewritten?

trim-mailchimp-campaign-stats-json POST steps bypass caches.default even if cacheTtlSeconds is set in the dashboard.

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

Upstream steps in trim-mailchimp-campaign-stats-json honor timeoutMs and optional fallback JSON without leaking secrets.
