{
  "slug": "clerk-backend-api-proxy",
  "title": "Call Clerk Backend API from Client Side",
  "metaDescription": "Call clerk backend api from client side. Keep Clerk keys in RealComposer Vault; Frontend / Web uses rc_live_ tokens only.",
  "headline": "Vault-backed Clerk proxy tuned for Frontend / Web",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 9,
  "clientPlatform": "Frontend / Web",
  "upstreamServices": [
    "Clerk"
  ],
  "searchIntentQuery": "call clerk backend api from client side",
  "directAnswerSummary": "Never place CLERK_SECRET_KEY inside Frontend / Web source. RealComposer injects them when calling https://api.clerk.com/v1/users/{{query.userId}}, so browsers see only a client token.",
  "problem": {
    "title": "Clerk keys in Frontend / Web network tabs",
    "explanation": "Frontend / Web ships code or scripts to end-user devices. Any Clerk bearer token in those bundles can be copied from DevTools, proxies, or repackaged apps.",
    "risks": [
      "Shared Frontend / Web projects revealing Clerk tokens",
      "Sudden Clerk quota burn from scripted abuse",
      "Inability to rotate keys without redeploying clients"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Add vault secrets for this pipeline",
      "description": "Create CLERK_SECRET_KEY vault entries, then bind them to this pipeline step headers with {{secrets.NAME}} placeholders."
    },
    {
      "stepNumber": 2,
      "title": "Target the real upstream URL",
      "description": "Point step clerk at https://api.clerk.com/v1/users/{{query.userId}} with GET. Add output mapping fields that mirror the JSON contract your screen already expects. 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 Frontend / Web",
      "description": "Call https://realcomposer.com/v1/workspace/clerk-backend-api-proxy with a restricted rc_live_ client token. Frontend / Web never sends upstream secrets.",
      "codeSnippet": "const res = await fetch('https://realcomposer.com/v1/workspace/clerk-backend-api-proxy', {\n  headers: { Authorization: 'Bearer rc_live_your_token' }\n});"
    }
  ],
  "pipelineConfig": {
    "name": "Call Clerk Backend API from Client Side",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "authMode": "client_token",
    "steps": [
      {
        "stepKey": "clerk",
        "upstreamUrlTemplate": "https://api.clerk.com/v1/users/{{query.userId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.CLERK_SECRET_KEY}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "userId",
          "sourcePath": "id",
          "type": "string",
          "sourceStep": "clerk"
        },
        {
          "targetPath": "email",
          "sourcePath": "email_addresses.0.email_address",
          "type": "string",
          "sourceStep": "clerk"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "requestId": "req_clerk-ba",
    "upstreamLatencyMs": 142,
    "audit": {
      "region": "edge",
      "trace": "clerk-backend-api-proxy"
    },
    "payload": {
      "id": "sample_id",
      "status": "active",
      "nested": {
        "tags": [
          "demo"
        ],
        "internal": true
      },
      "unused_blob": {
        "foo": "bar",
        "bar": "baz"
      }
    }
  },
  "sampleSlimmedOutput": {
    "userId": "sample",
    "email": "sample"
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/workspace/clerk-backend-api-proxy\" \\\n  -H \"Authorization: Bearer rc_live_client_token\"",
  "faqs": [
    {
      "question": "Does Frontend / Web need CORS changes after adding RealComposer?",
      "answer": "Yes for clerk-backend-api-proxy. Ship only an rc_live_ client token in Frontend / Web; RealComposer injects CLERK_SECRET_KEY on https://api.clerk.com/v1/users/{{query.userId}}."
    },
    {
      "question": "What cache key does RealComposer use?",
      "answer": "clerk-backend-api-proxy forwards client JSON to POST upstreams unchanged; secrets interpolate only in URLs and header templates."
    },
    {
      "question": "How do I rotate upstream credentials?",
      "answer": "Upstream steps in clerk-backend-api-proxy honor timeoutMs and optional fallback JSON without leaking secrets."
    }
  ],
  "relatedRecipeSlugs": [
    "transform-and-rename-nested-json-keys",
    "parallel-api-fetch-merge-payload",
    "call-stripe-from-flutterflow-securely"
  ],
  "updatedAt": "2026-11-20",
  "links": {
    "page": "https://realcomposer.com/recipes/clerk-backend-api-proxy",
    "markdown": "https://realcomposer.com/recipes/clerk-backend-api-proxy.md",
    "json": "https://realcomposer.com/recipes/clerk-backend-api-proxy.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=clerk-backend-api-proxy&via=agent"
  }
}