Skip to main content
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

  1. In the dashboard, verify a Sending Domain and add a sender (Integrations → Email). See Sending domain.
  2. Create an API Key (Settings → API Keys → Create API Key) with purpose Unified API and scopes Send emails. See Authentication.
  3. Store the key as the SEGMENTFLOW_API_KEY environment variable on your server. Both SDKs read it by default.

Send your first email

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.