Generate your own client from the OpenAPI document
exx.sh ships SDKs for TypeScript, Python, Go and Rust. For any other language, or to own your client end to end, generate one from the API's OpenAPI document. This guide covers where the document lives, what is in it, how to generate a client with common tools, and how to keep that client correct as the API grows.
Get the document
The API serves its own description, no key needed:
curl -sS https://api.exx.sh/openapi.json -o exx-openapi.jsonThe document is generated from the server's code, so it always describes the API that
answers at that host. Answers are cached for five minutes (Cache-Control: public, max-age=300). It is OpenAPI 3.1; some generators read only 3.0 (see below).
What the document says
| Topic | In the document | What your client must do |
|---|---|---|
| Authentication | components.securitySchemes.bearer | Send Authorization: Bearer <API key> on every call |
| Operations | One operationId per operation (send_email, list_domains, ...), grouped by tags | Map each to a method; the id is stable, the path may not be the best name |
| Errors | 4XX and 5XX answers with the ErrorBody schema: { statusCode, name, message } | Branch on name, not on message; any status can carry an envelope |
| Pagination | limit, after and before query parameters on list operations | Pass the last id of a page as after to get the next one (suppressions page by address) |
| Idempotency | Idempotency-Key header on send_email and send_batch | Send one key per logical email and reuse it on every retry of that email |
| Sending stream | X-Exx-Stream header (transactional or distributional) on the sends | Optional; transactional is the default |
| Rate limits | 429 with Retry-After and ratelimit-* headers | Wait Retry-After seconds before trying again |
Fields are snake_case on the wire, as in Resend's API.
Generate a client
Point any generator at the downloaded file. These are the generators and settings the official SDKs use.
TypeScript: Hey API
npx @hey-api/openapi-ts -i exx-openapi.json -o src/exx \
-p @hey-api/client-fetch @hey-api/typescript @hey-api/sdkSet auth to the API key and baseUrl to https://api.exx.sh when you create the client.
Python: openapi-python-client
uvx openapi-python-client generate --path exx-openapi.json --meta none \
--output-path exx_clientUse literal_enums: true in a config file (--config) to get Literal types instead of
enum classes. Build the client with AuthenticatedClient(base_url=..., token=<API key>).
Go: oapi-codegen
# oapi-codegen.yaml
package: exxapi
output: exxapi.gen.go
generate:
models: true
client: truego run github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest \
-config oapi-codegen.yaml exx-openapi.jsonUse the ClientWithResponses it generates: it decodes JSON4XX and JSON5XX into
ErrorBody for you. Add the bearer header with a request editor.
Rust: progenitor
progenitor reads OpenAPI 3.0 only. Lower the document first: turn "type": ["string", "null"] into "type": "string", "nullable": true, oneOf: [X, {"type": "null"}] into
allOf: [X] plus nullable, const into a one-value enum, and set "openapi": "3.0.3". Then generate with progenitor::Generator from a build.rs or a small binary.
Other languages
openapi-generator (Java, Kotlin, C#, PHP, Ruby, Swift, Dart, ...) and Kiota (C#, Java, PHP, Ruby, Swift, ...) both read the document. If your generator rejects 3.1, lower it to 3.0 as described for Rust.
What a generated client does not do
Generators turn operations into calls. The official SDKs add these behaviours on top, and you will want them too:
- Idempotent sends. Make a key per email (a UUID, or your own id such as
order-123/receipt) and send it asIdempotency-Key. The same key with the same body returns the first answer; with another body it is refused (409 invalid_idempotent_request). - Retries. Retry
429afterRetry-After, exceptdaily_quota_exceededandmonthly_quota_exceeded, which do not clear in seconds. Retry500,502,503,504and lost connections only when a second try cannot act twice: reads, deletes, and sends that carry anIdempotency-Key. Retry409 concurrent_idempotent_requests: the server is still working on that key. Back off exponentially and cap the wait. - Timeouts per attempt, so a retry gets its own time.
- Webhook verification. Events are signed with the
Standard Webhooks scheme: HMAC-SHA256 over
{svix-id}.{svix-timestamp}.{raw body}with the base64 key afterwhsec_, compared in constant time against eachv1,signature insvix-signature, with a five-minute tolerance on the timestamp. Refuse an empty secret. - Errors that never lose the name. Read
ErrorBodyfrom any non-2xx answer; when the body is not the envelope (a proxy's HTML page), keep the status and the text.
SMTP is not in the document. Send over SMTP with any client: host smtp.exx.sh, port 465
(TLS) or 587 (STARTTLS), user exx, your API key as the password.
Keep up with a changing document
The document changes when the API does. Most changes add something: an operation, an optional field, an error name. The API is young (0.x) and not yet declared stable, so read the release notes when the document changes. Build your client so that a change is a short, safe chore:
-
Pin a copy. Commit the
openapi.jsonyou generated from. Your build uses that copy, never the live URL, so a release of the API never changes your code by itself. -
Watch for changes. A scheduled job fetches the live document and compares it with your copy; a difference opens a pull request (or fails the job) with the new file:
curl -sS https://api.exx.sh/openapi.json -o /tmp/live.json diff -q <(jq -S . exx-openapi.json) <(jq -S . /tmp/live.json) \ || echo "the exx.sh API changed: regenerate the client" -
Regenerate, never edit. Keep generated code apart from your own code (its own directory or module) and regenerate it in one command. Your wrapper holds the retries, defaults and naming.
-
Check coverage of every operation. A test that reads
paths.*.*.operationIdfrom your pinned copy and fails when one has no method in your wrapper turns "the API grew" into a failing test instead of a missing feature. The official SDKs run exactly this test. -
Be lenient when reading. Ignore unknown fields in answers, accept unknown values of enum-like strings (
status,last_event, errorname), and do not rely on the order of fields or of list items beyond the documented sort. -
Check your generated code into review. The diff of the generated client shows what changed in the API in terms of your language.
The official SDKs
| Language | Package | Public source and issues | Docs |
|---|---|---|---|
| TypeScript | npm install @exx.sh/sdk | exx-node | https://docs.exx.sh/sdks/typescript |
| Python | pip install exx-sh | exx-python | https://docs.exx.sh/sdks/python |
| Go | go get github.com/sorvsys/exx-go | exx-go | https://docs.exx.sh/sdks/go |
| Rust | cargo add exx-sh | exx-rust | https://docs.exx.sh/sdks/rust |
Each is a thin layer over a client generated from this same document, with the behaviours above, plus SMTP sending.