SDKs

SDKs

An official SDK for each language your server runs, and what every one of them does the same way.

On this page
  1. What every SDK does the same
  2. Credentials
  3. Retries and timeouts
  4. Errors
  5. Idempotency
  6. The Mailset-Client header
  7. Versions
  8. Names

What every SDK does the same

The SDKs are written to one contract, so what you learn in one language holds in the next.

  • Every public command238 commands, each a typed method
  • Retries built inTwo more tries, and a send never doubles
  • Timeouts per try30 seconds a try, then tried again
  • Idempotency keysA send repeated with its key goes once
  • Webhook verificationSignatures checked, every event typed
  • Credential checkRefused before sending if your key can’t

Credentials

A client made with no arguments reads MAILSET_KEY from the environment, and MAILSET_TOKEN when there is no key. A key or a token you pass in wins over both: Use it shows the client both ways. Authentication says how to make each.

An app key sends as the mailboxes it was approved for. An API token is a person's, for the commands no app key can run, such as adding a domain. A command the client's credential can't run is refused before any request leaves, with an error that names the credential it needs.

Retries and timeouts

A call that gets no answer, or a 5xx one, is tried again: twice unless you set otherwise, waiting longer each time. A refusal is never tried again, since the same request gets the same answer. One try may take 30 seconds unless you set another limit, for the client or for one call.

A send is safe to try again. It keeps its Message-ID, so Mailset never sends it twice.

Errors

Every refusal is one kind of error, with the same fields in every language: code, which never changes and is what your code branches on, message for people, the HTTP status, and on some codes refusal, retryAt and issues. Each error also carries a link to its code in Errors and limits.

Idempotency

Give a send an idempotencyKey, and sending it again after a timeout or a crash sends nothing new: the same key from the same address answers the first receipt. Retry without sending twice has the rules.

The Mailset-Client header

Every request carries a Mailset-Client header: the SDK's language and version, then the framework, the runtime and the operating system it found. It tells Mailset which SDKs are in use. It names no host, path, user or app.

Mailset keeps the SDK's name and version with each message it sends, and your organization sees them as client on every delivery line of that message.

Versions

Every Mailset SDK ships under the same version number.

Names

A field keeps its name in every SDK, in each language's own case.

LanguageidempotencyKey is written
TypeScriptidempotencyKey
Pythonidempotency_key
GoIdempotencyKey
Rubyidempotency_key
PHPidempotencyKey
JavaidempotencyKey
Rustidempotency_key

A method is named for its command, as domains.add is. Where a language can't spell one, the method gets a name that says what it does.

LanguageCommandIts methodWhy
Pythoncontacts.importimport_contactsimport is a hard keyword in Python: contacts.import(…) doesn’t parse.
Pythonrules.importimport_rulesimport is a hard keyword in Python.
Rubymessages.sendsend_messagesend is Object#send, which Ruby itself and many libraries call.
Javabilling.switchswitchPlanswitch is a Java keyword.
Javaaddresses.defaultsetDefaultdefault is a Java keyword.
Javacontacts.importimportContactsimport is a Java keyword.
Javarules.importimportRulesimport is a Java keyword.

Mascots: Duke by Joe Palrang for Sun Microsystems, BSD; the Go gopher by Renée French, CC BY 4.0; Ferris by Karen Rustad Tölva, CC0. Each is simplified here to read at a small size.