{
  "slug": "merge-supabase-and-stripe-into-single-endpoint",
  "title": "How to Merge Supabase and Stripe into One Endpoint",
  "metaTitle": "Merge Supabase and Stripe into One API - RealComposer",
  "metaDescription": "Merge Supabase and Stripe into one fast edge endpoint. Fetch user data and subscriptions concurrently at the edge and return unified JSON payloads.",
  "headline": "Unified Customer Profile & Billing Endpoint at the Edge",
  "category": "aggregation",
  "categoryLabel": "Multi-API Aggregation",
  "urgency": 10,
  "clientPlatform": "React / Flutter / Mobile",
  "upstreamServices": [
    "Supabase",
    "Stripe"
  ],
  "searchIntentQuery": "how to combine supabase and stripe into one endpoint",
  "directAnswerSummary": "Instead of having your frontend make 2 separate requests over high-latency cellular networks, RealComposer fetches your Supabase user record and Stripe subscription details concurrently using Promise.all on Cloudflare Workers, returning a unified JSON payload in a single round-trip.",
  "problem": {
    "title": "The Chatty Round-Trip Problem on Mobile Networks",
    "explanation": "Mobile apps that call Supabase for profile data, then wait for a response, then call Stripe for subscription status suffer from multi-second load screens and high battery drain.",
    "risks": [
      "Multiple sequential network round-trips stalling UI render",
      "Exposed Stripe credentials on mobile devices",
      "Inconsistent state between auth and billing"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Configure Step 1 (Supabase)",
      "description": "Target Supabase PostgREST endpoint with apikey header."
    },
    {
      "stepNumber": 2,
      "title": "Configure Step 2 (Stripe)",
      "description": "Target Stripe customer endpoint in parallel with Secret Vault auth."
    },
    {
      "stepNumber": 3,
      "title": "Map to Unified Schema",
      "description": "Merge profile and billing fields into a single clean JSON object."
    }
  ],
  "pipelineConfig": {
    "name": "Supabase + Stripe BFF",
    "method": "GET",
    "cacheTtlSeconds": 0,
    "steps": [
      {
        "stepKey": "user",
        "upstreamUrlTemplate": "https://xyz.supabase.co/rest/v1/profiles?id=eq.{{query.userId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "apikey": "{{secrets.SUPABASE_ANON_KEY}}"
        },
        "timeoutMs": 3000
      },
      {
        "stepKey": "billing",
        "upstreamUrlTemplate": "https://api.stripe.com/v1/customers/{{query.stripeId}}",
        "httpMethod": "GET",
        "headersTemplate": {
          "Authorization": "Bearer {{secrets.STRIPE_SECRET_KEY}}"
        },
        "timeoutMs": 3000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "userId",
          "sourceStep": "user",
          "sourcePath": "0.id"
        },
        {
          "targetPath": "fullName",
          "sourceStep": "user",
          "sourcePath": "0.full_name"
        },
        {
          "targetPath": "email",
          "sourceStep": "user",
          "sourcePath": "0.email"
        },
        {
          "targetPath": "billing.customerId",
          "sourceStep": "billing",
          "sourcePath": "id"
        },
        {
          "targetPath": "billing.balance",
          "sourceStep": "billing",
          "sourcePath": "balance",
          "type": "number"
        },
        {
          "targetPath": "billing.delinquent",
          "sourceStep": "billing",
          "sourcePath": "delinquent",
          "type": "boolean"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "user": [
      {
        "id": "u_1",
        "full_name": "Jane Doe",
        "email": "jane@example.com"
      }
    ],
    "billing": {
      "id": "cus_99",
      "balance": 0,
      "delinquent": false
    }
  },
  "sampleSlimmedOutput": {
    "userId": "u_1",
    "fullName": "Jane Doe",
    "email": "jane@example.com",
    "billing": {
      "customerId": "cus_99",
      "balance": 0,
      "delinquent": false
    }
  },
  "curlSnippet": "curl -X GET \"https://realcomposer.com/v1/acme/user-dashboard?userId=u_1&stripeId=cus_99\"",
  "faqs": [
    {
      "question": "What happens if Stripe is down or slow?",
      "answer": "RealComposer supports per-step timeouts and fallback JSON, so your app still receives user profile data without failing completely."
    }
  ],
  "relatedRecipeSlugs": [
    "call-stripe-from-flutterflow-securely",
    "combine-multiple-apis-into-single-json"
  ],
  "links": {
    "page": "https://realcomposer.com/recipes/merge-supabase-and-stripe-into-single-endpoint",
    "markdown": "https://realcomposer.com/recipes/merge-supabase-and-stripe-into-single-endpoint.md",
    "json": "https://realcomposer.com/recipes/merge-supabase-and-stripe-into-single-endpoint.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=merge-supabase-and-stripe-into-single-endpoint&via=agent"
  }
}