Skip to main content

duta-sdk

The official Python SDK for Duta, transactional email for Malaysia.

  • Python 3.9+. One dependency, httpx.
  • Duta for regular code and AsyncDuta for asyncio, with the same methods.
  • Retries rate limits and server errors safely: every send carries an idempotency key, so a retry can never send twice.

Upgrading from 0.1.x

0.2.0 is a new SDK for Duta's current API, not an update of 0.1.x, which was written for an earlier version of Duta that no longer runs.

Install

pip install duta-sdk

Send an email

from duta import Duta

duta = Duta()  # reads DUTA_API_KEY

sent = duta.emails.send({
    "from": "Kedai <resit@kedai.my>",
    "to": "siti@example.com",
    "subject": "Resit #1042",
    "html": "<p>Terima kasih.</p>",
})
print(sent["id"])

Errors raise duta.DutaError. .code is Duta's error code and .request_id finds the request on the Logs screen.

from duta import DutaError

try:
    duta.emails.send(email, idempotency_key=f"receipt-{order.id}")
except DutaError as e:
    log.error("send failed: %s %s", e.code, e.request_id)

Async

from duta import AsyncDuta

async with AsyncDuta() as duta:
    await duta.emails.send(email)
    async for e in duta.emails.list_all(status="bounced"):
        print(e["id"])

Batch and paging

duta.batch.send([first, second], validation="permissive")

for e in duta.emails.list_all(status="bounced"):
    print(e["id"])

Verify webhooks

from duta import verify_webhook

event = verify_webhook(
    request.body,        # the raw body, before JSON parsing
    request.headers,
    os.environ["DUTA_WEBHOOK_SECRET"],
)

It raises duta.WebhookVerificationError when the signature is wrong or the delivery is more than five minutes old.

Everything else

emails send, get, list, list_all
batch send
domains create, list, get, verify, remove
api_keys create, list, remove
webhooks create, list, get, remove, enable, test, deliveries, verify
suppressions create, list, list_all, remove
logs list, list_all, get
usage get

Options: Duta(api_key, base_url=..., timeout=30.0, max_retries=2).

Full documentation: https://docs.duta.indra.sh

Release files for duta-sdk 0.2.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 duta-sdk 0.2.0
File Size Uploaded
duta_sdk-0.2.0.tar.gz 20.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for duta-sdk 0.2.0
File Interpreter ABI Platform
duta_sdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / duta_sdk-0.2.0.tar.gz

Download URL duta_sdk-0.2.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b3cdd43a75a34684eee90e136b3b75db869e0412de2aa398da746e06a093389f
BLAKE2b-256 checksum
How to use checksums
13dd40e09be86c9779a4b41306647a630029ed8df425b13cd1616a6b39dc7887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 26, 2026.

Transparency log

Release files / duta_sdk-0.2.0-py3-none-any.whl

Download URL duta_sdk-0.2.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2189af6ebbac723d8d20a2445fb60083c71ce9162aa2e828134deca998edb214
BLAKE2b-256 checksum
How to use checksums
2951f2e76e8d41ff63fdb5bdb6a0734ec9be75a7c50073d75f6751cebec93989
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.5

2 release files

0.1.0

2 release files

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