Add Related Products to News
This API lets you attach one or more related products to a news article.
Attached products appear in the items field when getting the news list,
letting the Mini App display products alongside the article.
Endpoint
http POST https://staging-manage.api.miniai.vn/api/external/news/{id}/items
http POST https://manage-api.miniap.vn/api/external/news/{id}/items
The news API sits directly under /api/external/news, without the /v1 prefix used by the product and order APIs.
Authentication
Every request must include your API key in the header:
| Header | Value | Required |
|---|---|---|
x-api-key | miniai-partner <YOUR_API_KEY> | Bắt buộc |
Content-Type | application/json | Bắt buộc |
The system automatically determines your shop (shopId) from your API key and assigns it to the request.
So you don't need to send shopId in the body.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Bắt buộc | ID of the news article to attach products to (24-character hex ObjectId) |
Request Body
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
newsIds | string[] | Bắt buộc | List of product IDs to attach to the article (see note below) |
Despite its name, newsIds accepts product IDs, not news article IDs.
You can get product IDs from the Get Product List API.
A product that's already attached will not be added again — calling this API again with the same product ID is safe (idempotent); the related product list still contains each product only once.
This API only checks whether the news article exists. An incorrect product ID (but valid ObjectId format)
is still accepted successfully — a nonexistent product simply won't appear in items when retrieved.
Make sure to use correct IDs from the product API.
- Request Body
- cURL (Staging)
- cURL (Production)
{
"newsIds": [
"68c93dba802d36826bc45d01",
"68c93dba802d36826bc45d02"
]
}
curl -X POST 'https://staging-manage.api.miniai.vn/api/external/news/68c93dba802d36826bc45c9c/items' \
-H 'x-api-key: miniai-partner <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"newsIds": [
"68c93dba802d36826bc45d01",
"68c93dba802d36826bc45d02"
]
}'
curl -X POST 'https://manage-api.miniap.vn/api/external/news/68c93dba802d36826bc45c9c/items' \
-H 'x-api-key: miniai-partner <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"newsIds": [
"68c93dba802d36826bc45d01",
"68c93dba802d36826bc45d02"
]
}'
Response
Success returns 200. The response only contains the success flag — no article data is included.
To see the product list after attaching, call Get News List
and check the article's items field.
- Response
{
"success": true
}
Common Errors
| Code | Cause |
|---|---|
400 | Missing newsIds, or newsIds is not an array of strings |
404 | No news article found with the given id |
401 | Missing x-api-key header, wrong miniai-partner prefix, or invalid API key |
429 | Rate limit exceeded (see the Rate Limit section below) |
500 | id or an element in newsIds is not a valid ObjectId format, or a system error occurred |
- 400 Error - Validation
- 404 Error - Not Found
- 429 Error - Rate Limited
{
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed",
"validation": {
"body": {
"source": "body",
"keys": ["newsIds"],
"message": "\"newsIds\" is required"
}
}
}
{
"error": "Resource not found",
"message": "không tìm thấy tin tức"
}
{
"error": "Too many requests, limit to 100 requests per minute"
}
Rate Limit
Each shop can make at most 100 requests per minute across the entire External API.
Exceeding this limit returns a 429 status.
Next Steps
- Get News List — check the article's
itemsfield after attaching - Remove Related Products from News — detach an attached product
- Get Product List — look up the product IDs you want to attach