Skip to main content

segmentflow

Send email from your server with Segmentflow.

pip install segmentflow

Needs Python 3.10 or later. Use it on your server only: an API Key can send email as your Organization, so it must never reach a browser or a mobile app.

Set up

  1. In the Segmentflow dashboard, verify a Sending Domain and add a sender (Integrations → Email).
  2. Create an API Key (Settings → API Keys → Create API Key) with purpose Unified API and scopes Send emails, and store it as SEGMENTFLOW_API_KEY. Only Organization owners and admins can create keys.
from segmentflow import SegmentflowClient

segmentflow = SegmentflowClient()  # reads SEGMENTFLOW_API_KEY

Send with a saved Template

Design the email in the dashboard, then send it by its id: the last part of its editor address, dashboard.segmentflow.ai/templates/email/<id>. A Template created with a stable key can use template_key instead. Profile details such as first name fill in from the recipient's Profile; values for this one send go in data, which the Template reads as /data/<name>.

sent = segmentflow.emails.send(
    template_id="018f7a35-2c2f-7e13-9b10-35f6d96d7a70",
    to={"email": "ada@example.com"},
    data={"order_number": "1042", "total": "49.00"},
    idempotency_key="order-1042-receipt",
)

Send your own HTML

Render the email however you like (Jinja, Django templates, MJML) and send the result:

segmentflow.emails.send_html(
    html=render_to_string("emails/receipt.html", {"order": order}),
    text=f"Thanks! Order {order.number} is on its way.",  # optional
    subject=f"Your order {order.number}",
    purpose="transactional",
    from_="Acme <orders@acme.com>",
    to={"email": "ada@example.com"},
)

purpose is "transactional" for receipts, password resets and other email a person expects. "marketing" and "newsletter" need a subscription_group_id, and Segmentflow adds the unsubscribe footer for you. from_ must be a sender on a verified Sending Domain.

Async

from segmentflow import AsyncSegmentflowClient

segmentflow = AsyncSegmentflowClient()

async def send_receipt(email: str) -> None:
    await segmentflow.emails.send(template_id="...", to={"email": email})

Check what happened

send returns straight away with status Queued. Read the status later with the id:

email = segmentflow.emails.get(sent.id)
# email.status: Queued | Processing | Sent | Failed | Skipped | DeliveryUnknown
# email.skipped_reason, for example ProfileSuppressed or ProfileUnsubscribed

Never send twice

Every send carries an idempotency key. If you pass none, the SDK creates one, so its own retries (two by default) never send a second email. Pass your own key, such as "order-1042-receipt", to stay safe when your job restarts too: Segmentflow returns the first send instead of sending again. Reusing a key with different content fails with a ConflictError.

Many emails at once

emails.batch_send takes up to 100 independent sends. Each item has its own recipient, data and idempotency_key.

segmentflow.emails.batch_send(
    defaults={"template_id": "..."},
    items=[
        {
            "idempotency_key": f"digest-2026-48-{user.id}",
            "to": {"email": user.email},
            "data": {"unread": user.unread_count},
        }
        for user in users
    ],
)

Errors

Failed requests raise a typed error, such as BadRequestError or TooManyRequestsError, each with status_code and body.

from segmentflow import TooManyRequestsError

try:
    segmentflow.emails.send(template_id="...", to={"email": email})
except TooManyRequestsError:
    ...  # The daily sending limit or warming capacity is used up; try later.

Options

SegmentflowClient(
    api_key="...",  # defaults to SEGMENTFLOW_API_KEY
    timeout=30,
    max_retries=2,
)

Full API reference: https://docs.segmentflow.ai. The TypeScript SDK is @segmentflow/node.

Metadata

Release files for segmentflow 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for segmentflow 0.1.0
File Size Uploaded Provenance Actions
segmentflow-0.1.0.tar.gz 86.4 kB With provenance Details for segmentflow-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for segmentflow 0.1.0
File Interpreter ABI Platform Actions
segmentflow-0.1.0-py3-none-any.whl Python 3 none any Details for segmentflow-0.1.0-py3-none-any.whl

Total release size: 315.0 kB

Release files / segmentflow-0.1.0.tar.gz

Download URL segmentflow-0.1.0.tar.gz
Size 86.4 kB
Tags Source
SHA-256 checksum
How to use checksums
df6cf7278a5577f9e13e2816b20ecc6a361a7ac0896997a8496c4f1e2b33ad1e
BLAKE2b-256 checksum
How to use checksums
0f646b14f98bd158ab223a08ffb3e5b972c10e9a586f632b36ef0b0c24618a09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / segmentflow-0.1.0-py3-none-any.whl

Download URL segmentflow-0.1.0-py3-none-any.whl
Size 228.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a4aa9321415fd9533a3be17cb4365d01c9e68db7a70b42a05d0711411fa5b7eb
BLAKE2b-256 checksum
How to use checksums
a5bd0594a038151f641de482030191fb090d2e7a93219821b14bc4e57509ac59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for segmentflow 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for segmentflow-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page