Upload a file

Upload an attachment for an outgoing message in three steps: get a signed upload URL,

PUT
the bytes to it, then register the file on the conversation. Finally send the message with the file fields.

Endpoint

POST
/conversation-files

Step 1: Get a signed upload URL

json

See Create an upload URL. The URL is valid for 1 hour.

Step 2: Upload the bytes

Send the same Content-Type you passed as contentType in step 1.

Step 3: Register the file

Body

NameTypeRequiredDescription
conversation_idintegerYesConversation receiving the file.
file_namestringYesOriginal file name.
file_typestringYesMIME type.
file_sizeintegerYesSize in bytes.
file_categorystringYesimage, audio, video or file.
s3_keystringYess3PathWithoutBucket from step 1.
s3_pathstringYess3Path from step 1.
organization_idintegerNoIf sent, it must match the conversation's organization. The conversation's organization is always used.

Request

Response

The conversation file with its _id:

json

For Instagram conversations, images in unsupported formats are converted, and for WhatsApp conversations videos are re-encoded when WhatsApp would reject them; the stored s3_key, file_name and file_type can therefore differ from what you sent. Use the values in the response.

Step 4: Send the message

Pass s3_key, file_name, file_type, file_size and conversation_file_id (the _id) to Send a message with message_type image, video, audio or document. For SMS, send the public URL https://achieveapex-conversation-files.s3.amazonaws.com/<s3_key> in media_urls.

Errors

StatusWhen
400 Bad Requestconversation_id missing or not found, organization_id does not match the conversation, or a required field is missing.

Report an issue with this documentation

Please log in to report issues with our documentation.