{
  "slug": "twilio-sms-frontend-proxy",
  "title": "How to Call Twilio SMS API from Client-Side JavaScript Securely",
  "metaTitle": "Call Twilio SMS API from Frontend Securely - RealComposer",
  "metaDescription": "Call Twilio SMS API from frontend JavaScript securely. RealComposer proxies requests at the edge, attaching Basic Auth headers to prevent credit theft.",
  "headline": "Protect Twilio Account SID & Auth Token from Browser Exposure",
  "category": "security",
  "categoryLabel": "Security & Secret Vault",
  "urgency": 10,
  "clientPlatform": "JavaScript / HTML",
  "upstreamServices": [
    "Twilio"
  ],
  "searchIntentQuery": "call twilio sms api from client side javascript securely",
  "directAnswerSummary": "Calling Twilio directly from client-side JS exposes your Account SID and Auth Token, enabling malicious actors to drain your SMS credits with spam campaigns. RealComposer proxies Twilio calls at the edge, attaching Basic Auth headers server-side.",
  "problem": {
    "title": "Toll Fraud and Twilio Credit Depletion",
    "explanation": "Bots crawl web forms for Twilio credentials to send premium-rate SMS messages, creating massive bills.",
    "risks": [
      "Thousands of dollars in SMS toll fraud bills",
      "Immediate Twilio suspension",
      "Customer spamming"
    ]
  },
  "solutionSteps": [
    {
      "stepNumber": 1,
      "title": "Store Twilio Auth in Vault",
      "description": "Store TWILIO_AUTH_TOKEN in RealComposer."
    },
    {
      "stepNumber": 2,
      "title": "Expose Verification Endpoint",
      "description": "Trigger SMS dispatch without client-side credentials."
    }
  ],
  "pipelineConfig": {
    "name": "Twilio SMS Gateway",
    "method": "POST",
    "cacheTtlSeconds": 0,
    "steps": [
      {
        "stepKey": "twilio",
        "upstreamUrlTemplate": "https://api.twilio.com/2010-04-01/Accounts/{{secrets.TWILIO_ACCOUNT_SID}}/Messages.json",
        "httpMethod": "POST",
        "headersTemplate": {
          "Authorization": "Basic {{secrets.TWILIO_BASIC_AUTH}}"
        },
        "timeoutMs": 4000
      }
    ],
    "outputMapping": {
      "version": 1,
      "fields": [
        {
          "targetPath": "sid",
          "sourceStep": "twilio",
          "sourcePath": "sid"
        },
        {
          "targetPath": "status",
          "sourceStep": "twilio",
          "sourcePath": "status"
        }
      ]
    }
  },
  "sampleBloatedInput": {
    "sid": "SM123",
    "status": "queued",
    "to": "+14155552671"
  },
  "sampleSlimmedOutput": {
    "sid": "SM123",
    "status": "queued"
  },
  "curlSnippet": "curl -X POST \"https://realcomposer.com/v1/acme/send-sms\"",
  "faqs": [
    {
      "question": "Does RealComposer prevent SMS pumping?",
      "answer": "Yes, per-IP rate limiting and origin checks block automated pumping bots."
    }
  ],
  "relatedRecipeSlugs": [
    "sendgrid-frontend-proxy",
    "resend-email-api-static-site"
  ],
  "links": {
    "page": "https://realcomposer.com/recipes/twilio-sms-frontend-proxy",
    "markdown": "https://realcomposer.com/recipes/twilio-sms-frontend-proxy.md",
    "json": "https://realcomposer.com/recipes/twilio-sms-frontend-proxy.json",
    "install": "https://realcomposer.com/dashboard/pipelines/new?recipe=twilio-sms-frontend-proxy&via=agent"
  }
}