Skip to content

Media

Upload files to send, download attachments, media library. · 13 endpoints

Download a message's file/photo/video/voice recording (downloaded to the machine first if it isn't there yet)

GET/api/v1/accounts/{accountId}/conversations/{threadId}/messages/{msgId}/mediaScope: media:read

Parameters

accountId
path · required
string
max 200
Account ID
threadId
path · required
string
max 200
Conversation ID
msgId
path · required
string
max 200
Message ID (msg_id)

Example request

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/conversations/{threadId}/messages/{msgId}/media" \
  -H "Authorization: Bearer dpk_xxx"

Upload a file to send in chat (returns an upload_id that expires after 24 hours)

POST/api/v1/media/uploadsScope: media:write

Two ways to send it:

  • Raw body: header X-Filename: ten-file.pdf (URL-encode it if it contains diacritics) + the file's Content-Type. Written straight to disk.
  • multipart/form-data with a file field. Only the key that uploaded the file can use the upload_id.

multipart/form-data body

Example request

bash
curl -X POST "http://127.0.0.1:9900/api/v1/media/uploads" \
  -H "Authorization: Bearer dpk_xxx"

Delete an uploaded file (without waiting for it to expire)

DELETE/api/v1/media/uploads/{uploadId}Scope: media:write

Parameters

uploadId
path · required
string
max 100

Example request

bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/media/uploads/{uploadId}" \
  -H "Authorization: Bearer dpk_xxx"

Items in the account's media library

GET/api/v1/accounts/{accountId}/library/itemsScope: media:read

Parameters

accountId
path · required
string
max 200
Account ID (accounts.zalo_id). Facebook uses the Facebook ID, Telegram uses the Telegram account ID.
type
query · optional
"all" | "image" | "video" | "file" | "audio"
default "all"
search
query · optional
string
max 200
folder_id
query · optional
integer-1 = not in any folder
page
query · optional
integer
≥ 1 · default 1
limit
query · optional
integer
≥ 1 · ≤ 200 · default 50

Example request

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/library/items" \
  -H "Authorization: Bearer dpk_xxx"

Add an uploaded file to the library

POST/api/v1/accounts/{accountId}/library/itemsScope: media:write

Parameters

accountId
path · required
string
max 200
Account ID (accounts.zalo_id). Facebook uses the Facebook ID, Telegram uses the Telegram account ID.

Request body (JSON)

upload_id
required
string
name
optional
string
max 200
tags
optional
string
max 500 · default ""
folder_id
optional
integer | null

Example request

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/library/items" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"upload_id":"string","name":"string","tags":""}'

Change the name, tags, folder, favorite

PATCH/api/v1/library/items/{uuid}Scope: media:write

Parameters

uuid
path · required
string
max 100

Request body (JSON)

name
optional
string
max 200
tags
optional
string
max 500
folder_id
optional
integer | null
is_favorite
optional
boolean
alt_text
optional
string
max 500

Example request

bash
curl -X PATCH "http://127.0.0.1:9900/api/v1/library/items/{uuid}" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","tags":"string","folder_id":0}'

Delete an item from the library

DELETE/api/v1/library/items/{uuid}Scope: media:write

Parameters

uuid
path · required
string
max 100

Example request

bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/library/items/{uuid}" \
  -H "Authorization: Bearer dpk_xxx"

Download the item's file

GET/api/v1/library/items/{uuid}/fileScope: media:read

Parameters

uuid
path · required
string
max 100

Example request

bash
curl "http://127.0.0.1:9900/api/v1/library/items/{uuid}/file" \
  -H "Authorization: Bearer dpk_xxx"

The item's thumbnail

GET/api/v1/library/items/{uuid}/thumbScope: media:read

Parameters

uuid
path · required
string
max 100

Example request

bash
curl "http://127.0.0.1:9900/api/v1/library/items/{uuid}/thumb" \
  -H "Authorization: Bearer dpk_xxx"

Library folders

GET/api/v1/accounts/{accountId}/library/foldersScope: media:read

Parameters

accountId
path · required
string
max 200
Account ID (accounts.zalo_id). Facebook uses the Facebook ID, Telegram uses the Telegram account ID.
type
query · optional
string
max 20

Example request

bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/library/folders" \
  -H "Authorization: Bearer dpk_xxx"

Create a folder

POST/api/v1/accounts/{accountId}/library/foldersScope: media:write

Parameters

accountId
path · required
string
max 200
Account ID (accounts.zalo_id). Facebook uses the Facebook ID, Telegram uses the Telegram account ID.

Request body (JSON)

name
required
string
max 200
color
optional
string
max 20

Example request

bash
curl -X POST "http://127.0.0.1:9900/api/v1/accounts/{accountId}/library/folders" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string","color":"string"}'

Rename a folder

PATCH/api/v1/accounts/{accountId}/library/folders/{folderId}Scope: media:write

Parameters

accountId
path · required
string
max 200
folderId
path · required
integer
≥ 1

Request body (JSON)

name
required
string
max 200

Example request

bash
curl -X PATCH "http://127.0.0.1:9900/api/v1/accounts/{accountId}/library/folders/{folderId}" \
  -H "Authorization: Bearer dpk_xxx" \
  -H "Content-Type: application/json" \
  -d '{"name":"string"}'

Delete a folder (files inside are moved out, not deleted)

DELETE/api/v1/accounts/{accountId}/library/folders/{folderId}Scope: media:write

Parameters

accountId
path · required
string
max 200
folderId
path · required
integer
≥ 1

Example request

bash
curl -X DELETE "http://127.0.0.1:9900/api/v1/accounts/{accountId}/library/folders/{folderId}" \
  -H "Authorization: Bearer dpk_xxx"