{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "polyglot-email-demo",
  "type": "registry:block",
  "title": "Polyglot: Send an Email",
  "description": "API Code Snippet Tabs example, Send an Email: Not only for chat: an email API with the recipient and subject editable in the code. Run streams the JSON the API returns (`responseLang=\"json\"`), and the recipient flies in as the request. A take on the code block (code snippet) and tabs (tab bar). Fits docs and features sections.",
  "author": "KeyframeUI <https://keyframeui.com>",
  "categories": [
    "docs",
    "features",
    "code-block",
    "tabs",
    "code",
    "developer",
    "ai"
  ],
  "docs": "Live preview, examples and props: https://keyframeui.com/components/polyglot#polyglot-email-demo",
  "registryDependencies": [
    "https://keyframeui.com/r/polyglot.json"
  ],
  "files": [
    {
      "path": "components/polyglot-email-demo.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { Polyglot, type PolyglotValues } from \"@/components/ui/polyglot\";\n\nconst snippets = [\n  {\n    label: \"cURL\",\n    lang: \"bash\",\n    code: `\ncurl https://api.sendwell.dev/v1/emails \\\\\n  -H \"Authorization: Bearer {{apiKey}}\" \\\\\n  -H \"Content-Type: application/json\" \\\\\n  -d '{\n    \"from\": \"{{from}}\",\n    \"to\": \"{{to}}\",\n    \"subject\": \"{{subject}}\",\n    \"html\": \"<p>Thanks for your order!</p>\"\n  }'\n`,\n  },\n  {\n    label: \"Node.js\",\n    lang: \"js\",\n    code: `\nimport { Sendwell } from \"sendwell\";\n\nconst sendwell = new Sendwell(\"{{apiKey}}\");\n\nawait sendwell.emails.send({\n  from: \"{{from}}\",\n  to: \"{{to}}\",\n  subject: \"{{subject}}\",\n  html: \"<p>Thanks for your order!</p>\",\n});\n`,\n  },\n  {\n    label: \"Python\",\n    lang: \"python\",\n    code: `\nimport sendwell\n\nsendwell.api_key = \"{{apiKey}}\"\n\nsendwell.Emails.send({\n    \"from\": \"{{from}}\",\n    \"to\": \"{{to}}\",\n    \"subject\": \"{{subject}}\",\n    \"html\": \"<p>Thanks for your order!</p>\",\n})\n`,\n  },\n  {\n    label: \"Ruby\",\n    lang: \"ruby\",\n    code: `\nrequire \"sendwell\"\n\nSendwell.api_key = \"{{apiKey}}\"\n\nSendwell::Emails.send(\n  from: \"{{from}}\",\n  to: \"{{to}}\",\n  subject: \"{{subject}}\",\n  html: \"<p>Thanks for your order!</p>\"\n)\n`,\n  },\n];\n\nconst queued = ({ from, to, subject }: PolyglotValues) =>\n  JSON.stringify(\n    {\n      id: \"em_01JA7Q3V9K2M5XR\",\n      object: \"email\",\n      from,\n      to,\n      subject,\n      status: \"queued\",\n      created_at: \"2026-10-14T09:41:07Z\",\n    },\n    null,\n    2,\n  );\n\nexport function PolyglotEmailDemo() {\n  return (\n    <section className=\"grid w-full max-w-5xl items-center gap-10 lg:grid-cols-[minmax(0,0.75fr)_minmax(0,1.25fr)]\">\n      <div>\n        <p className=\"font-mono text-xs text-muted-foreground\">Sendwell API</p>\n        <h2 className=\"mt-3 text-3xl font-semibold tracking-tight text-balance\">\n          Your first email is one request away.\n        </h2>\n        <p className=\"mt-4 text-sm leading-relaxed text-pretty text-muted-foreground\">\n          Type a recipient and a subject right in the code, pick your language, and send. The\n          response is the same in every one of them.\n        </p>\n        <ul className=\"mt-6 space-y-2 text-sm\">\n          {[\"Queued in under 50 ms\", \"Webhooks for every delivery\", \"SDKs for 6 languages\"].map((item) => (\n            <li key={item} className=\"flex items-center gap-2.5\">\n              <span aria-hidden className=\"size-1.5 rounded-full bg-foreground/60\" />\n              {item}\n            </li>\n          ))}\n        </ul>\n      </div>\n      <Polyglot\n        echo=\"to\"\n        responseLang=\"json\"\n        statusText=\"202 Accepted\"\n        slots={{\n          apiKey: { value: \"sw_live_9fK2mQx81LrT\", secret: true, label: \"API key\" },\n          from: { value: \"orders@acme.dev\", label: \"From\" },\n          to: { value: \"ada@example.com\", editable: true, label: \"To\" },\n          subject: { value: \"Your order has shipped\", editable: true, label: \"Subject\" },\n        }}\n        snippets={snippets}\n        response={queued}\n        speed={140}\n        latency={260}\n      />\n    </section>\n  );\n}\n"
    }
  ]
}