For the complete documentation index, see llms.txt. This page is also available as Markdown.

Media Files

JavaScript multipart/form-data Example To Create A Media File:

const file = document.querySelector("input[type=file]").files[0];

const data = new FormData();
data.append('file_encoded', file);

fetch('/api/v1/media/', {
'method': 'POST',
'headers': {
  'Authorization': 'Token YOUR_TOKEN_HERE',
},
'body': data
}).then(response => {
  return response.json();
}).then(data => {
  console.log(data.file);
}).catch((error) => {
  console.error('Error:', error);
});

Above POST request will produce a valid binary file upload HTTP request similar to:

After API will return with specified JSON data, line console.log(data.file); will print a direct URL to uploaded media file.

post

Create a new media file

Use this endpoint to upload a new media file before you enter it into a new message as an attachment.

Authorizations
AuthorizationstringRequired

A user token, sent as Token <token>. Create a user in the admin panel (group App integration) and get its token from POST /api/v1/auth/token/. The channel API key (D360-Api-Key) is not supported.

Body
file_encodedstringRequired

Encoded in Base64.

Responses
201Success
application/json
file_encodedstring · uriWrite-onlyRequired
filestring · uriRead-onlyRequired

An authorization-free link to your media file. This link will contain query params: mime_type_type and mime_type_subtype that, when combined together, determine for you a content type of retrieved media file: {mime_type_type}/{mime_type_subtype}. For example: mime_type_type=image&mime_type_subtype=jpeg means Content-Type: image/jpeg. This information is not needed for HTTP client that will ignore file type (for example most of web browsers during file download), but it will be crucial for others (for example web browsers during file display or WhatsApp displaying outgoing message media to end users)

idstring · uuidRead-onlyRequired
post/api/v1/media/
POST /api/v1/media/ HTTP/1.1
Host: your-stack.inbox.getchat.360dialog.io/
Authorization: Token YOUR_TOKEN
Content-Type: multipart/form-data
Accept: */*
Content-Length: 23

{
  "file_encoded": "text"
}
201Success
{
  "file": "https://example.com",
  "id": "123e4567-e89b-12d3-a456-426614174000"
}
get

Retrieve binary raw media file

Used in media messages and for display.

  • Owned media (uploaded via this Inbox, identified by a UUID) is served as a 302 redirect to a short-lived signed URL on Google Cloud Storage, so the bucket can stay private and bytes never flow through the Inbox pod.

  • Inbound media hosted by WABA (numeric IDs) is proxied through WABA-Stack as before.

Authorizations
AuthorizationstringRequired

A user token, sent as Token <token>. Create a user in the admin panel (group App integration) and get its token from POST /api/v1/auth/token/. The channel API key (D360-Api-Key) is not supported.

Path parameters
idstring · uuidRequired

A UUID string identifying this media file.

Query parameters
mime_type_subtypestringOptional

mime_type_type and mime_type_subtype that, when combined together, determine for you a content type of retrieved media file - {mime_type_type}/{mime_type_subtype}. For example mime_type_type=image&mime_type_subtype=jpeg means Content-Type image/jpeg. This information is not needed for HTTP client that will ignore file type (for example most of web browsers during file download) but it will be crucial for others (for example web browsers during file display or WhatsApp displaying outgoing message media to end users)

mime_type_typestringOptional

mime_type_type and mime_type_subtype that, when combined together, determine for you a content type of retrieved media file: {mime_type_type}/{mime_type_subtype}. For example mime_type_type=image&mime_type_subtype=jpeg means Content-Type image/jpeg. This information is not needed for HTTP client that will ignore file type (for example most of web browsers during file download) but it will be crucial for others (for example web browsers during file display or WhatsApp displaying outgoing message media to end users)

Responses
200Success
string · binaryOptional
get/api/v1/media/{id}/
GET /api/v1/media/{id}/ HTTP/1.1
Host: your-stack.inbox.getchat.360dialog.io/
Authorization: Token YOUR_TOKEN
Accept: */*
binary

Last updated

Was this helpful?