Upload an attachment
/v1/attachmentsSend a multipart/form-data request with the file in the file field. The maximum size is 25 MB, otherwise you get 413 payload_too_large.
curl -X POST "https://api.tuskmail.africa/v1/attachments" \
-H "X-API-Key: $TK_API_KEY" \
-u "$MAILBOX_EMAIL:$APP_PASSWORD" \
-F "file=@./invoice-2041.pdf"{
"attachment_id": "B987",
"name": "invoice-2041.pdf",
"type": "application/pdf",
"size": 40960
}Send a message with attachments
Upload each file, then pass the ids in attachments on POST /v1/messages. Up to 20 attachments can be added to a message. Use the uploaded id soon after uploading: it stays usable for about 24 hours, and if it has expired you can still pass name and type next to the id.
{
"to": ["[email protected]"],
"subject": "Invoice 2041",
"text": "Attached.",
"attachments": [{ "attachment_id": "B987" }]
}Download an attachment
/v1/messages/{message_id}/attachments/{attachment_id}Get the attachment_id from the message’s attachments array, then request the file. The response body is the raw file, with the original name in Content-Disposition. An id that is not on that message returns 404 not_found.
curl "https://api.tuskmail.africa/v1/messages/Mabc123/attachments/B987" \
-H "X-API-Key: $TK_API_KEY" \
-u "$MAILBOX_EMAIL:$APP_PASSWORD" \
-o "rates.pdf"