# Mailchimp member json too big filter fields

> Drop merge fields stats and _links from list member JSON. For "mailchimp member json too big filter fields", 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 JavaScript / HTML hit only https://realcomposer.com/v1/workspace/filter-mailchimp-member-json-fields with an rc_live_ client token.

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

## Problem: Mailchimp JSON bloat on JavaScript / HTML

Oversized Mailchimp payloads inflate parse time and mobile data charges for JavaScript / HTML 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**: Add MAILCHIMP_BASIC_AUTH to RealComposer Secret Vault. Values decrypt only inside the Cloudflare Worker that calls the upstream.

2. **Configure upstream steps and output mapping**: Point step mailchimp at https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10 with GET. Map only the UI fields in output mapping so clients never download audit or nested blobs. Leave cache TTL at 0 when each response is user-specific (include userId or record id in query params before enabling cache).

3. **Call from JavaScript / HTML**: Authorize with Bearer rc_live_ and fetch the mapped JSON contract your UI already expects.

```
const data = await fetch('https://realcomposer.com/v1/workspace/filter-mailchimp-member-json-fields', {
  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": "Mailchimp member json too big filter fields",
  "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/filter-mailchimp-member-json-fields" \
  -H "Authorization: Bearer rc_live_client_token"
```

## Payload before and after

Raw upstream response:

```json
{
  "requestId": "req_filter-m",
  "upstreamLatencyMs": 142,
  "audit": {
    "region": "edge",
    "trace": "filter-mailchimp-member-json-fields"
  },
  "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

### Which Mailchimp credential belongs in the vault for this pipeline?

Point JavaScript / HTML at /recipes/filter-mailchimp-member-json-fields edge URL. RealComposer answers OPTIONS with Access-Control headers for allowed origins.

### Does POST traffic get cached?

Cache key for filter-mailchimp-member-json-fields: internal edge-cache path plus sorted query. Identical params hit; vary userId per user.

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

Upstream steps in filter-mailchimp-member-json-fields honor timeoutMs and optional fallback JSON without leaking secrets.
