POST
/v1/me/mail/drafts/{id}/attachmentsA file goes onto a draft that already exists, so save a draft
first and use its id, such as msg_q9w3k7x2n8m4t6vb. The file then goes out with the
send of that draft, and it is on the draft wherever the
draft is opened, the browser included.
The file travels as base64 inside JSON. Every write in this API is JSON, so an upload is too.
Request
curl -X POST https://api.proppertrading.com/v1/me/mail/drafts/msg_q9w3k7x2n8m4t6vb/attachments \
-H "Authorization: Bearer ptat_9f2c1a44_3b8e7d2f5c9a1b4e6d8f0a2c4e6b8d1f" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 7d1e3a90-4b2c-4f6e-9a8d-1c3e5f7a9b0d" \
-d '{
"name": "statement-july.pdf",
"data": "JVBERi0xLjcKJeLjz9MK..."
}'
| Field | Description |
|---|---|
name | What the recipient sees the file called. Never used as a path on our side |
data | The file, base64. At most 8 MB once decoded |
The type is worked out from the bytes. There is no field for it, because a type the sender chose is a type nobody should trust.
Response
201, with every file now on the draft, oldest first:
{
"data": [
{
"id": "att_n6q2w8k4t9x3m7hr",
"name": "statement-july.pdf",
"content_type": "application/pdf",
"size_bytes": 84213
}
],
"meta": {
"request_id": "req_01kz4bkr1aj1gv63d8fv3133ey",
"has_more": false,
"next_cursor": null
}
}
Retrying with the same Idempotency-Key answers the same list and adds
nothing. A second file is a new key.
Errors
| Status | Code | Meaning |
|---|---|---|
| 400 | missing_idempotency_key | Every POST needs one |
| 400 | not_a_draft | The message is not a draft, or not any more |
| 400 | invalid_attachment | data is not base64, or it is empty |
| 400 | attachment_too_large | More than 8 MB once decoded |
| 403 | insufficient_scope | This device does not hold mail:write |
| 404 | resource_not_found | No such message in a mailbox you can read. A number in the path finds none either |
| 422 | validation_failed | name or data missing |