How do I get credentials?
Open Settings in the TuskMail web app
Sign in as the mailbox you want to send from. API access is available for user mailboxes, not group mailboxes.Create an app password
Go to Settings, then App passwords, and create one. Copy it right away. You can give it an expiry and, optionally, restrict it to specific IP addresses.Create an API key
Go to Settings, then Developers, and create a key. It starts withtk_live_and is shown once, so store it safely.
Set them in your shell:
Shell
export TK_API_KEY="tk_live_..."
export MAILBOX_EMAIL="[email protected]"
export APP_PASSWORD="your-app-password"How do I send my first message?
Post a JSON body to /v1/messages. The response confirms the message was sent.
curl -X POST "https://api.tuskmail.africa/v1/messages" \
-H "X-API-Key: $TK_API_KEY" \
-u "$MAILBOX_EMAIL:$APP_PASSWORD" \
-H "Idempotency-Key: order-1001-confirmation" \
-H "Content-Type: application/json" \
-d '{
"to": [
{
"email": "[email protected]",
"name": "Amina"
}
],
"subject": "Your order is confirmed",
"text": "Hello Amina, your order 1001 is confirmed.",
"html": "<p>Hello Amina, your order <b>1001</b> is confirmed.</p>"
}'201 Created
{
"id": "Mabc123",
"sent": true
}The sent message appears in the Sent folder of the mailbox. Use the messages reference to read, search and manage mail.
What should I read next?
- Authentication for how the two credentials work together.
- Rate limits and errors to make your integration robust.
- Idempotency to make retries safe.