Bỏ qua tới nội dung

Media

Upload file để gửi, tải file đính kèm, thư viện media. · 13 endpoint

Tải file/ảnh/video/ghi âm của một tin (tự tải về máy nếu chưa có)

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

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản
threadId
path · bắt buộc
string
max 200
ID hội thoại
msgId
path · bắt buộc
string
max 200
ID tin nhắn (msg_id)

Lệnh mẫu

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

Upload file để gửi vào chat (trả upload_id, hết hạn sau 24 giờ)

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

Hai cách gửi:

  • Raw body: header X-Filename: ten-file.pdf (URL-encode nếu có dấu) + Content-Type của file. Ghi thẳng xuống đĩa.
  • multipart/form-data với trường file. upload_id chỉ key đã upload dùng được.

Body dạng multipart/form-data

Lệnh mẫu

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

Xoá file đã upload (không đợi hết hạn)

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

Tham số

uploadId
path · bắt buộc
string
max 100

Lệnh mẫu

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

Item trong thư viện media của tài khoản

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

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.
type
query · tuỳ chọn
"all" | "image" | "video" | "file" | "audio"
default "all"
search
query · tuỳ chọn
string
max 200
folder_id
query · tuỳ chọn
integer-1 = chưa có thư mục
page
query · tuỳ chọn
integer
≥ 1 · default 1
limit
query · tuỳ chọn
integer
≥ 1 · ≤ 200 · default 50

Lệnh mẫu

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

Đưa file đã upload vào thư viện

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

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.

Body (JSON)

upload_id
bắt buộc
string
name
tuỳ chọn
string
max 200
tags
tuỳ chọn
string
max 500 · default ""
folder_id
tuỳ chọn
integer | null

Lệnh mẫu

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":""}'

Đổi tên, tag, thư mục, yêu thích

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

Tham số

uuid
path · bắt buộc
string
max 100

Body (JSON)

name
tuỳ chọn
string
max 200
tags
tuỳ chọn
string
max 500
folder_id
tuỳ chọn
integer | null
is_favorite
tuỳ chọn
boolean
alt_text
tuỳ chọn
string
max 500

Lệnh mẫu

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}'

Xoá item khỏi thư viện

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

Tham số

uuid
path · bắt buộc
string
max 100

Lệnh mẫu

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

Tải file của item

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

Tham số

uuid
path · bắt buộc
string
max 100

Lệnh mẫu

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

Ảnh thu nhỏ của item

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

Tham số

uuid
path · bắt buộc
string
max 100

Lệnh mẫu

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

Thư mục thư viện

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

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.
type
query · tuỳ chọn
string
max 20

Lệnh mẫu

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

Tạo thư mục

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

Tham số

accountId
path · bắt buộc
string
max 200
ID tài khoản (accounts.zalo_id). Facebook dùng Facebook ID, Telegram dùng ID tài khoản Telegram.

Body (JSON)

name
bắt buộc
string
max 200
color
tuỳ chọn
string
max 20

Lệnh mẫu

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"}'

Đổi tên thư mục

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

Tham số

accountId
path · bắt buộc
string
max 200
folderId
path · bắt buộc
integer
≥ 1

Body (JSON)

name
bắt buộc
string
max 200

Lệnh mẫu

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"}'

Xoá thư mục (file bên trong chuyển ra ngoài, không bị xoá)

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

Tham số

accountId
path · bắt buộc
string
max 200
folderId
path · bắt buộc
integer
≥ 1

Lệnh mẫu

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