Reference

Attachments API

Open an upload slot, upload a file, and check whether it is ready to attach.

On this page

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

NameTypeRequiredNotes
filenamestringYesThe file name. At most 255 characters.
contentTypestringYesThe MIME type, such as application/pdf. At most 255 characters.
bytesintegerYesThe file size in bytes.
contentHashstringYesThe 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

NameTypeRequiredNotes
attachmentIdstringYes
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

NameTypeRequiredNotes
attachmentIdstringYes
curl --request POST "https://ternwire.com/v1/attachments/{attachmentId}/complete" \
  --header "Authorization: Bearer $TERNWIRE_API_KEY"