{
  "slug": "hide-mailchimp-api-key-javascript",
  "title": "Hide mailchimp api key in client side javascript",
  "metaTitle": "Hide mailchimp api key in client - RealComposer",
  "metaDescription": "Hide mailchimp api key in client side javascript. Keep Mailchimp keys in RealComposer Vault; JavaScript / HTML uses rc_live_ tokens only.",
  "headline": "Protect Mailchimp Marketing API quota",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 9,
  "clientPlatform": "JavaScript / HTML",
  "upstreamServices": [
    "Mailchimp"
  ],
  "searchIntentQuery": "hide mailchimp api key in client side javascript",
  "directAnswerSummary": "Block browser extraction of list API keys via edge-only authorization headers. For \"hide mailchimp api key in client side javascript\", 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/hide-mailchimp-api-key-javascript with an rc_live_ client token.",
  "problem": {
    "title": "Mailchimp keys in JavaScript / HTML network tabs",
    "explanation": "JavaScript / HTML ships code or scripts to end-user devices. Any Mailchimp bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.",
    "risks": [
      "Shared JavaScript / HTML projects revealing Mailchimp tokens",
      "Sudden Mailchimp quota burn from scripted abuse",
      "Inability to rotate keys without redeploying clients"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store upstream credentials in Secret Vault",
      "description": "Store MAILCHIMP_BASIC_AUTH in the vault. JavaScript / HTML never embeds the raw secret, only a revocable rc_live_ client token."
    },
    {
      "stepNumber": 2,
      "title": "Configure upstream steps and output mapping",
      "description": "Use GET against https://{{secrets.MAILCHIMP_DC}}.api.mailchimp.com/3.0/lists/{{query.listId}}/members?count=10. Allowed origins on the client token should match leave cache ttl at 0 when each response is user-specific (include userid or record id in query params before enabling cache)."
    },
    {
      "stepNumber": 3,
      "title": "Call from JavaScript / HTML",
      "description": "Allowed origins on the token should list every JavaScript / HTML host that calls this URL.",
      "codeSnippet": "const data = await fetch('https://realcomposer.com/v1/workspace/hide-mailchimp-api-key-javascript', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n}).then(r => r.json());"
    }
  ],
  "pipelineConfig": {
    "name": "Hide mailchimp api key in client side javascript",
    "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"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_hide-mai",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "hide-mailchimp-api-key-javascript"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "memberId": "sample",
    "email": "sample",
    "status": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/hide-mailchimp-api-key-javascript\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Can JavaScript / HTML call Mailchimp without holding the production key?",
      "answer": "Log request IDs for hide-mailchimp-api-key-javascript, not raw Mailchimp payloads, because upstream bodies may include PII."
    },
    {
      "question": "How do I forward JSON bodies to POST upstreams?",
      "answer": "hide-mailchimp-api-key-javascript keeps cache TTL at 0 because it uses POST upstream calls or per-user responses. Add ids to query strings before enabling GET cache."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Allowed origins on the hide-mailchimp-api-key-javascript client token restrict which domains may call the edge URL."
    }
  ],
  "relatedRecipeSlugs": [
    "sendgrid-frontend-proxy",
    "resend-email-api-static-site"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/hide-mailchimp-api-key-javascript",
    "markdown": "https://realcomposer.com/recipes/hide-mailchimp-api-key-javascript.md",
    "json": "https://realcomposer.com/recipes/hide-mailchimp-api-key-javascript.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=hide-mailchimp-api-key-javascript&via=agent"
  }
}