Skip to main content

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

🔗Endpoint Staging

http POST https://staging-manage.api.miniai.vn/api/external/news/{id}/items

🔗Endpoint Production

http POST https://manage-api.miniap.vn/api/external/news/{id}/items

A note on the path

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:

HeaderValueRequired
x-api-keyminiai-partner <YOUR_API_KEY>Bắt buộc
Content-Typeapplication/jsonBắt buộc
No need to send shopId

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

ParameterTypeRequiredDescription
idstringBắt buộcID of the news article to attach products to (24-character hex ObjectId)

Request Body

Parameters

FieldTypeRequiredDescription
newsIdsstring[]Bắt buộcList of product IDs to attach to the article (see note below)
The newsIds field actually holds PRODUCT IDs

Despite its name, newsIds accepts product IDs, not news article IDs. You can get product IDs from the Get Product List API.

No duplicates to worry about

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.

The system does not verify that products exist

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.

{
"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.

{
"success": true
}

Common Errors

CodeCause
400Missing newsIds, or newsIds is not an array of strings
404No news article found with the given id
401Missing x-api-key header, wrong miniai-partner prefix, or invalid API key
429Rate limit exceeded (see the Rate Limit section below)
500id or an element in newsIds is not a valid ObjectId format, or a system error occurred
{
"statusCode": 400,
"error": "Bad Request",
"message": "Validation failed",
"validation": {
"body": {
"source": "body",
"keys": ["newsIds"],
"message": "\"newsIds\" is required"
}
}
}

Rate Limit

100 requests / minute

Each shop can make at most 100 requests per minute across the entire External API. Exceeding this limit returns a 429 status.

Next Steps