Reference
Attachments API
Open an upload slot, upload a file, and check whether it is ready to attach.
Every request needs Authorization: Bearer with an API key. Errors use the shapes and codes in Errors and retry decisions. The OpenAPI document has the full schemas.
Create attachment upload slot
POST /v1/attachments (createAttachmentUploadSlot)
Returns a presigned URL. PUT the raw file bytes to it with the returned headers, then call completeAttachmentUpload. The file is scanned for viruses before an email can use it.
Needs an API key with the send scope.
Request body
| Name | Type | Required | Notes |
|---|---|---|---|
filename | string | Yes | The file name. At most 255 characters. |
contentType | string | Yes | The MIME type, such as application/pdf. At most 255 characters. |
bytes | integer | Yes | The file size in bytes. |
contentHash | string | Yes | The SHA-256 of the file, in lowercase hex. |
curl --request POST "https://ternwire.com/v1/attachments" \
--header "Authorization: Bearer $TERNWIRE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"filename": "string",
"contentType": "string",
"bytes": 1,
"contentHash": "string"
}'Get attachment
GET /v1/attachments/{attachmentId} (getAttachment)
Returns the attachment's scan status. Use the attachment in an email once its status is clean.
Needs an API key with the send scope.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
attachmentId | string | Yes |
curl --request GET "https://ternwire.com/v1/attachments/{attachmentId}" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"Complete attachment upload
POST /v1/attachments/{attachmentId}/complete (completeAttachmentUpload)
Tells Ternwire the upload is complete and queues the virus scan. Read the attachment until its status is clean.
Needs an API key with the send scope.
Path parameters
| Name | Type | Required | Notes |
|---|---|---|---|
attachmentId | string | Yes |
curl --request POST "https://ternwire.com/v1/attachments/{attachmentId}/complete" \
--header "Authorization: Bearer $TERNWIRE_API_KEY"