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
- In the Segmentflow dashboard, verify a Sending Domain and add a sender (Integrations → Email).
- 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,
)
Guides: https://segmentflow.ai/docs/sdks. API reference:
https://segmentflow.ai/docs/api-reference/overview. The TypeScript SDK is
@segmentflow/node.
Metadata
Release files for segmentflow 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| segmentflow-0.1.1.tar.gz | 86.4 kB | With provenance | Details for segmentflow-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| segmentflow-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for segmentflow-0.1.1-py3-none-any.whl |
Total release size: 315.1 kB
Release files / segmentflow-0.1.1.tar.gz
| Download URL | segmentflow-0.1.1.tar.gz |
|---|---|
| Size | 86.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9967fbe02b6277cd92f013fd75b1c0f13ede2670d13a7937c9f1d4e5212bfee8
|
|
BLAKE2b-256 checksum How to use checksums |
11414118db7486d98686b32ff67d4d05617059ee5c9c9dda13855125e958d4fa
|
| 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 logRelease files / segmentflow-0.1.1-py3-none-any.whl
| Download URL | segmentflow-0.1.1-py3-none-any.whl |
|---|---|
| Size | 228.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ac006081281dc2cb94cfdd792d6d041f03052ddd686df37779d1f517301fa93
|
|
BLAKE2b-256 checksum How to use checksums |
1a8d541ef51d9c759c4e101fbf58bebb0b39d00abe2afa728168d102ba8b103f
|
| 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 logSecurity for segmentflow 0.1.1
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.
Attestation for segmentflow-0.1.1.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 logA 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.