Send an attachment
Embed a small file directly or upload a reusable private transactional attachment.
On this page
Choose direct or uploaded
Direct content avoids a separate upload request for files up to 5 MB. RouteKite retains the decoded bytes privately only long enough for queued delivery and safe retries. Uploaded attachment IDs remain useful for larger or reusable files.
- Direct and uploaded attachments can be mixed in one ordered array.
- Direct files do not appear in Assets.
- The combined decoded size cannot exceed 10 MB.
Send a direct attachment
Set filename, content_type, and standard Base64 content inside the email request. Do not send a data URL.
curl --request POST https://routekite-app--routekite.us-east4.hosted.app/api/v1/emails \--header "Authorization: Bearer rk_your_key" \--header "Idempotency-Key: order-123-confirmation" \--header "Content-Type: application/json" \--data '{"from": "updates@example.com","to": "customer@example.net","reply_to": "support@example.com","subject": "Your order is confirmed","html": "<h1>Thank you</h1><p>Your order is confirmed.</p>","attachments": [{"filename": "notes.txt","content_type": "text/plain","content": "SGVsbG8gZnJvbSBSb3V0ZUtpdGUuCg=="},"c6ea638c-28a4-4b0c-a39d-74f1d29e1e9f"]}'
1. Prepare an uploaded attachment
Calculate the exact byte size and lowercase SHA-256 digest. RouteKite reserves storage and returns an opaque upload instruction.
curl --request POST https://routekite-app--routekite.us-east4.hosted.app/api/v1/attachments \--header "Authorization: Bearer rk_your_key" \--header "Content-Type: application/json" \--data '{"filename": "invoice.pdf","content_type": "application/pdf","size_bytes": 245800,"sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef","retention": "auto_delete"}'
2. Upload the exact bytes
Use the exact method, URL, and headers from the prepare response. Do not send your RouteKite key to the upload destination.
curl --request PUT "UPLOAD_URL_FROM_RESPONSE" \--header "Content-Type: application/pdf" \--upload-file "./invoice.pdf"
3. Complete validation
Completion checks the object, size, content type, digest, extension, and signature. Only ready attachments can be sent.
curl --request POST https://routekite-app--routekite.us-east4.hosted.app/api/v1/attachments/c6ea638c-28a4-4b0c-a39d-74f1d29e1e9f/complete \--header "Authorization: Bearer rk_your_key"
4. Reference the uploaded attachment
Add the ready ID to the attachments array. IDs must be unique, unexpired, and in the key's workspace.
- Maximum 10 files per email.
- Maximum 10,000,000 combined decoded bytes.
- auto_delete removes an uploaded file 31 days after completion.
- keep retains an uploaded file until explicit deletion.