Upload ảnh cho template
POST/zns/upload/imageGọi qua 360: POST https://partner.quantri360.com/v1/zalo/zns/upload/image
Endpoint ghi — thay đổi dữ liệu trên Zalo OA. Key phải được tạo với tick "Cho phép gọi API ghi", nếu không sẽ nhận 403 write_not_allowed. Mỗi lần gọi được ghi nhật ký.
Mô tả API
Tải logo hoặc ảnh lên để dùng khi tạo / sửa mẫu tin; trả media_id.
- Gửi multipart/form-data, trường
file: JPG / PNG tối đa 500 KB. Logo: PNG 400×96 px; ảnh: tỉ lệ 16:9. - Tối đa 5.000 ảnh / tháng.
Request
Địa chỉ
POST https://partner.quantri360.com/v1/zalo/zns/upload/image
Xác thực & gian hàng
| Tên | Vị trí | Kiểu | Mẫu | Mô tả |
|---|---|---|---|---|
| Authorization | header | header | Bearer q360_live_ab12cd34_… | Khóa API của brand (tạo ở mục API key). Bắt buộc với mọi request. Brand suy từ key — không truyền mã brand. |
| platform_shop_id | query | string | 1173478676788457425 | OA_ID của Zalo OA brand đã nối (GET /v1/platforms). Mỗi brand một OA — có thể bỏ. |
| data | query | string (JSON) | {"offset":0,"count":10} | Nhiều API GET của Zalo nhận tham số gói trong data là chuỗi JSON — gửi nguyên như tài liệu Zalo. |
Tham số request
| Tên | Vị trí | Kiểu | Bắt buộc | Mẫu | Mô tả |
|---|---|---|---|---|---|
| file | body | string | Có | Bắt buộc. |
Ví dụ request
curl -s -X POST "https://partner.quantri360.com/v1/zalo/zns/upload/image" \ -H "Authorization: Bearer $KEY" \ -F "file=@logo.png"
Python
import requests
from contextlib import ExitStack
KEY = "q360_live_..."
with ExitStack() as stack:
files = [("file", stack.enter_context(open("logo.png", "rb")))]
r = requests.post("https://partner.quantri360.com/v1/zalo/zns/upload/image", params={}, data={}, files=files, headers={"Authorization": f"Bearer {KEY}"}, timeout=60)
print(r.status_code, r.json())Node.js
import { readFile } from 'node:fs/promises';
const KEY = 'q360_live_...';
const url = new URL('https://partner.quantri360.com/v1/zalo/zns/upload/image');
const form = new FormData();
form.append("file", new Blob([await readFile("logo.png")]), "logo.png");
const r = await fetch(url, { method: 'POST', headers: { Authorization: `Bearer ${KEY}` }, body: form });
console.log(r.status, await r.json());PHP
<?php
$key = 'q360_live_...';
$ch = curl_init('https://partner.quantri360.com/v1/zalo/zns/upload/image');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer ' . $key]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, ['file' => new CURLFile('logo.png')]);
echo curl_exec($ch);
curl_close($ch);Response
Tham số phản hồi (nguyên của Zalo OA)
| Tên | Kiểu | Mẫu | Mô tả |
|---|---|---|---|
| error | int | 0 | 0 = thành công. |
| message | string | Success | |
| data | object | ||
| media_id | string | demo-media-id | Mã ảnh dùng trong layout của mẫu tin. |
Mẫu phản hồi
{
"error": 0,
"message": "Success",
"data": {
"media_id": "demo-media-id"
}
}
Bắt đầu dùng
- Đăng ký tài khoản Partner
- Mở loại dữ liệu thuộc nhóm ZNS (Zalo Notification Service) ở trang nền tảng
- Tạo API key (tick kênh Zalo OA)
- Gọi theo ví dụ ở trên