Send email from your TypeScript or Python backend with the official Segmentflow SDKs.
Segmentflow has official SDKs for TypeScript and Python. They cover sending email (emails.send, emails.batchSend, emails.get) and reading Templates. Call every other endpoint over HTTP.
Use the SDKs on your server only. An API Key can send email as your
Organization, so it must never reach a browser or a mobile app. The TypeScript
client refuses to run in a browser.
Set up
In the dashboard, verify a Sending Domain and add a sender (Integrations → Email). See Sending domain.
Create an API Key (Settings → API Keys → Create API Key) with purpose Unified API and scopes Send emails. See Authentication.
Store the key as the SEGMENTFLOW_API_KEY environment variable on your server. Both SDKs read it by default.
Send your first email
import { SegmentflowClient } from "@segmentflow/node";const segmentflow = new SegmentflowClient(); // reads SEGMENTFLOW_API_KEYconst sent = await segmentflow.emails.send({ templateId: "018f7a35-2c2f-7e13-9b10-35f6d96d7a70", to: { email: "ada@example.com" }, data: { orderNumber: "1042" },});const email = await segmentflow.emails.get({ id: sent.id });console.log(email.status); // Queued, Processing, Sent, Failed, Skipped or DeliveryUnknown
A Template’s id is the last part of its editor address in the dashboard (/templates/email/<id>). To send by a stable name instead, give the Template a key (in the editor, More actions → Template key) and pass templateKey (template_key in Python); see Templates. To send HTML you render yourself, use emails.sendJsxEmail in TypeScript or emails.send_html in Python. See Emails for every option.
What the SDKs do for you
Idempotency. Every send carries an idempotency key. When you pass none, the SDK creates one, so its own retries never send the same email twice. Pass your own key, such as order-1042-receipt, to stay safe when your job restarts too.
Retries.408, 429 and 5xx responses are retried twice by default, honouring Retry-After. Set maxRetries (TypeScript) or max_retries (Python) on the client to change that.
Typed errors. Failed requests raise errors such as UnauthorizedError, ConflictError and TooManyRequestsError, each with the status code and response body.
Types. Requests and responses are fully typed in TypeScript and Python.
Other languages and endpoints
Events, Journeys, Segments, Subscription Groups, Broadcasts and the other endpoints aren’t in the SDKs. Call them with any HTTP client and the x-api-key header; each guide shows the request. The API Reference is generated from the OpenAPI spec, which you can also use to generate a client for another language.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"SegmentFlow.ai","description":"Help center and API docs for SegmentFlow.ai — set up email marketing on your Shopify store, and use the unified REST API to send emails, track business events, and manage Profiles, Templates, Catalog Products, Assets, Brand Kit resources, and EmailSends from your own systems.","colors":{"primary":"#5F62EA","light":"#818CF8","dark":"#4F46E5"},"logo":{"light":"https://mintcdn.com/segmentflowai/3CG4RVaFvydhSMHS/logo/light.png?fit=max\u0026auto=format\u0026n=3CG4RVaFvydhSMHS\u0026q=85\u0026s=22b32b6ce317cd5eabafca56a56881ea","dark":"https://mintcdn.com/segmentflowai/3CG4RVaFvydhSMHS/logo/dark.png?fit=max\u0026auto=format\u0026n=3CG4RVaFvydhSMHS\u0026q=85\u0026s=2fa58235ec0ea271918875baea4060c1"},"favicon":"https://mintcdn.com/segmentflowai/3CG4RVaFvydhSMHS/logo/favicon.ico?fit=max\u0026auto=format\u0026n=3CG4RVaFvydhSMHS\u0026q=85\u0026s=6907126ab757c6b74263be572ab15ddd","api":{"playground":{"display":"interactive"},"examples":{"autogenerate":true},"mdx":{"auth":{"method":"key","name":"x-api-key"},"server":"https://api.segmentflow.ai"}},"navbar":{"links":[{"href":"https://dashboard.segmentflow.ai","label":"Dashboard"}]},"footer":{"socials":{"x":"https://twitter.com/segmentflow","github":"https://github.com/segmentflow"}},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"segmentflowai","hasAudioNarration":false,"actualSubdomain":"segmentflowai","customDomains":["segmentflow.ai"],"gitSource":{"type":"github","owner":"segmentflow","repo":"segmentflow-main","deployBranch":"main","contentDirectory":"docs/mintlify","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6b0d28afc8c35da4f8a485c4","clientVersion":"0.0.4352","searchFilterCounts":[{"language":"default","tag":"API Reference","count":69},{"language":"default","tag":"API guides","count":18},{"language":"default","tag":"Get Started","count":18},{"language":"default","tag":"Brand-Kit","count":11},{"language":"default","tag":"Help center","count":10},{"language":"default","tag":"Templates","count":10},{"language":"default","tag":"Assets","count":9},{"language":"default","tag":"Catalog-Products","count":9},{"language":"default","tag":"Profiles","count":7},{"language":"default","tag":"Your account","count":5}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"/docs","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"sdks","slug":"/sdks","pageMetadata":{"title":"SDKs","description":"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.","href":"/sdks"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,ol:`ol`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,CodeGroup,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Segmentflow has official SDKs for TypeScript and Python. They cover sending email (`,_jsx(_components.code,{children:`emails.send`}),`, `,_jsx(_components.code,{children:`emails.batchSend`}),`, `,_jsx(_components.code,{children:`emails.get`}),`) and reading Templates. Call every other endpoint over HTTP.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Language`}),_jsx(_components.th,{children:`Install`}),_jsx(_components.th,{children:`Source`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`TypeScript / Node.js 20+`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`npm install @segmentflow/node`})}),_jsx(_components.td,{children:_jsx(_components.a,{href:`https://github.com/segmentflow/segmentflow-node`,children:`segmentflow/segmentflow-node`})})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Python 3.10+`}),_jsx(_components.td,{children:_jsx(_components.code,{children:`pip install segmentflow`})}),_jsx(_components.td,{children:_jsx(_components.a,{href:`https://github.com/segmentflow/segmentflow-python`,children:`segmentflow/segmentflow-python`})})]})]})]}),`\n`,_jsx(Warning,{children:_jsx(_components.p,{children:`Use the SDKs on your server only. An API Key can send email as your\nOrganization, so it must never reach a browser or a mobile app. The TypeScript\nclient refuses to run in a browser.`})}),`\n`,_jsx(Heading,{level:`2`,id:`set-up`,children:`Set up`}),`\n`,_jsxs(_components.ol,{children:[`\n`,_jsxs(_components.li,{children:[`In the dashboard, verify a Sending Domain and add a sender (Integrations → Email). See `,_jsx(_components.a,{href:`/sending-domain`,children:`Sending domain`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Create an API Key (Settings → API Keys → Create API Key) with purpose `,_jsx(_components.strong,{children:`Unified API`}),` and scopes `,_jsx(_components.strong,{children:`Send emails`}),`. See `,_jsx(_components.a,{href:`/authentication`,children:`Authentication`}),`.`]}),`\n`,_jsxs(_components.li,{children:[`Store the key as the `,_jsx(_components.code,{children:`SEGMENTFLOW_API_KEY`}),` environment variable on your server. Both SDKs read it by default.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`send-your-first-email`,children:`Send your first email`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`TypeScript`,numberOfLines:`12`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`SegmentflowClient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` } `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"@segmentflow/node\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` segmentflow`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` SegmentflowClient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// reads SEGMENTFLOW_API_KEY`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` sent`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` segmentflow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`emails`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`send`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` templateId:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"018f7a35-2c2f-7e13-9b10-35f6d96d7a70\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` to:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`email:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"ada@example.com\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`orderNumber:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"1042\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` email`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` segmentflow`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`emails`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`get`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({ `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`id:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` sent`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`id`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` });`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`console`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`log`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`email`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`status`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`); `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Queued, Processing, Sent, Failed, Skipped or DeliveryUnknown`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Python`,numberOfLines:`12`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` segmentflow `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SegmentflowClient`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`segmentflow `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SegmentflowClient() `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# reads SEGMENTFLOW_API_KEY`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`sent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` segmentflow.emails.send(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` template_id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"018f7a35-2c2f-7e13-9b10-35f6d96d7a70\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` to`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"email\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"ada@example.com\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` data`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"orderNumber\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"1042\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`email `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` segmentflow.emails.get(sent.id)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#DCDCAA`},children:`print`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(email.status) `}),_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Queued, Processing, Sent, Failed, Skipped or DeliveryUnknown`})]}),`\n`]})})})]}),`\n`,_jsxs(_components.p,{children:[`A Template’s id is the last part of its editor address in the dashboard (`,_jsx(_components.code,{children:`/templates/email/\u003cid>`}),`). To send by a stable name instead, give the Template a key (in the editor, `,_jsx(_components.strong,{children:`More actions`}),` → `,_jsx(_components.strong,{children:`Template key`}),`) and pass `,_jsx(_components.code,{children:`templateKey`}),` (`,_jsx(_components.code,{children:`template_key`}),` in Python); see `,_jsx(_components.a,{href:`/templates#give-a-template-a-key`,children:`Templates`}),`. To send HTML you render yourself, use `,_jsx(_components.code,{children:`emails.sendJsxEmail`}),` in TypeScript or `,_jsx(_components.code,{children:`emails.send_html`}),` in Python. See `,_jsx(_components.a,{href:`/emails`,children:`Emails`}),` for every option.`]}),`\n`,_jsx(Heading,{level:`2`,id:`what-the-sdks-do-for-you`,children:`What the SDKs do for you`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Idempotency.`}),` Every send carries an idempotency key. When you pass none, the SDK creates one, so its own retries never send the same email twice. Pass your own key, such as `,_jsx(_components.code,{children:`order-1042-receipt`}),`, to stay safe when your job restarts too.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Retries.`}),` `,_jsx(_components.code,{children:`408`}),`, `,_jsx(_components.code,{children:`429`}),` and `,_jsx(_components.code,{children:`5xx`}),` responses are retried twice by default, honouring `,_jsx(_components.code,{children:`Retry-After`}),`. Set `,_jsx(_components.code,{children:`maxRetries`}),` (TypeScript) or `,_jsx(_components.code,{children:`max_retries`}),` (Python) on the client to change that.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Typed errors.`}),` Failed requests raise errors such as `,_jsx(_components.code,{children:`UnauthorizedError`}),`, `,_jsx(_components.code,{children:`ConflictError`}),` and `,_jsx(_components.code,{children:`TooManyRequestsError`}),`, each with the status code and response body.`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:`Types.`}),` Requests and responses are fully typed in TypeScript and Python.`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`other-languages-and-endpoints`,children:`Other languages and endpoints`}),`\n`,_jsxs(_components.p,{children:[`Events, Journeys, Segments, Subscription Groups, Broadcasts and the other endpoints aren’t in the SDKs. Call them with any HTTP client and the `,_jsx(_components.code,{children:`x-api-key`}),` header; each guide shows the request. The `,_jsx(_components.a,{href:`/api-reference/overview`,children:`API Reference`}),` is generated from the OpenAPI spec, which you can also use to generate a client for another language.`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"SDKs","description":"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.","href":"/sdks"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Set up","slug":"set-up","depth":2,"children":[]},{"title":"Send your first email","slug":"send-your-first-email","depth":2,"children":[]},{"title":"What the SDKs do for you","slug":"what-the-sdks-do-for-you","depth":2,"children":[]},{"title":"Other languages and endpoints","slug":"other-languages-and-endpoints","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"segmentflowai","siteName":"SegmentFlow.ai","title":"SDKs - SegmentFlow.ai","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-30T07:41:47.187Z","originalFileLocation":"sdks.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.\">\u003cmeta data-mint-head name=\"application-name\" content=\"SegmentFlow.ai\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"SDKs - SegmentFlow.ai\">\u003cmeta data-mint-head property=\"og:description\" content=\"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"SegmentFlow.ai\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://segmentflow.ai/docs/sdks\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://segmentflowai.mintlify.site/docs/_mintlify/api/og/v2?division=Get+Started\u0026amp;title=SDKs\u0026amp;description=Send+email+from+your+TypeScript+or+Python+backend+with+the+official+Segmentflow+SDKs.\u0026amp;theme=75addf11c4865810772dcd87\u0026amp;signature=5d06ab8db59aa4671b704dba36e380a9d27cf320011971bd6680a1812fdbe6b5\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"SDKs - SegmentFlow.ai\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://segmentflowai.mintlify.site/docs/_mintlify/api/og/v2?division=Get+Started\u0026amp;title=SDKs\u0026amp;description=Send+email+from+your+TypeScript+or+Python+backend+with+the+official+Segmentflow+SDKs.\u0026amp;theme=75addf11c4865810772dcd87\u0026amp;signature=5d06ab8db59aa4671b704dba36e380a9d27cf320011971bd6680a1812fdbe6b5\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/docs/mintlify-assets/_mintlify/favicons/segmentflowai/ffY4iylLclbdAbj_/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"SegmentFlow.ai\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#5F62EA\">\u003clink data-mint-head rel=\"canonical\" href=\"https://segmentflow.ai/docs/sdks\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/sdks.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://segmentflow.ai/#organization\",\"name\":\"SegmentFlow.ai\",\"url\":\"https://segmentflow.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/segmentflowai/3CG4RVaFvydhSMHS/logo/light.png?fit=max\u0026auto=format\u0026n=3CG4RVaFvydhSMHS\u0026q=85\u0026s=22b32b6ce317cd5eabafca56a56881ea\"}},{\"@type\":\"WebSite\",\"@id\":\"https://segmentflow.ai/docs#website\",\"name\":\"SegmentFlow.ai\",\"url\":\"https://segmentflow.ai/docs\",\"publisher\":{\"@id\":\"https://segmentflow.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://segmentflow.ai/docs/sdks#webpage\",\"url\":\"https://segmentflow.ai/docs/sdks\",\"name\":\"SDKs\",\"description\":\"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.\",\"dateModified\":\"2026-11-30T07:41:47.187Z\",\"isPartOf\":{\"@id\":\"https://segmentflow.ai/docs#website\"},\"breadcrumb\":{\"@id\":\"https://segmentflow.ai/docs/sdks#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://segmentflow.ai/docs/sdks#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Get Started\",\"item\":\"https://segmentflow.ai/docs/introduction\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SDKs\",\"item\":\"https://segmentflow.ai/docs/sdks\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://segmentflow.ai/docs/sdks#article\",\"headline\":\"SDKs\",\"name\":\"SDKs\",\"description\":\"Send email from your TypeScript or Python backend with the official Segmentflow SDKs.\",\"url\":\"https://segmentflow.ai/docs/sdks\",\"mainEntityOfPage\":{\"@id\":\"https://segmentflow.ai/docs/sdks#webpage\"},\"dateModified\":\"2026-11-30T07:41:47.187Z\",\"publisher\":{\"@id\":\"https://segmentflow.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://segmentflow.ai/docs#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"SegmentFlow.ai\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"SegmentFlow.ai\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/sdks.md","siteName":"SegmentFlow.ai","nav":{"global":null,"tabs":[{"tab":"Help center","pages":[{"title":"Help center","href":"/help/overview"}]},{"tab":"API guides","groups":[{"group":"Get Started","pages":[{"title":"Introduction","description":"The SegmentFlow.ai unified API lets you send expected emails, track server-side business events, and manage Profiles, Templates, Catalog Products, Assets, Brand Kit resources, and EmailSends from your own systems.","href":"/introduction"},{"title":"SDKs","href":"/sdks"},{"title":"Which API should I use?","description":"Choose between emails.send, emails.batchSend, events.track, journeys.trigger, Broadcasts, and Newsletter Issues.","sidebarTitle":"Which API?","href":"/which-api-should-i-use"},{"title":"Sending domain","href":"/sending-domain"},{"title":"Emails","href":"/emails"},{"title":"Templates","href":"/templates"},{"title":"Catalog products","href":"/catalog-products"},{"title":"Segments","href":"/segments"},{"title":"Subscription groups","href":"/subscription-groups"},{"title":"Privacy requests","href":"/privacy-requests"},{"title":"Journeys","href":"/journeys"},{"title":"Broadcasts","href":"/broadcasts"},{"title":"Events","href":"/events"},{"title":"Order transactions","href":"/order-transactions"},{"title":"Connect another store platform","href":"/connect-other-platforms"},{"title":"Authentication","href":"/authentication"},{"title":"Errors","href":"/errors"},{"title":"API changelog","href":"/changelog"}]}]},{"tab":"API Reference","pages":[{"title":"API Reference","href":"/api-reference/profiles/list-profiles"}]}]},"basePath":"","title":"SDKs - SegmentFlow.ai","deploymentId":"dpl_CsF4Fp7CD8Gg1DEmR1C2gpC2wJMd","buildId":"dpl_CsF4Fp7CD8Gg1DEmR1C2gpC2wJMd","dynamics":[],"chunks":[]}