MoveCollections#
To use this method, you must have a WhatsApp Business account.
The method is designed to change the order (reorder) of collections in the catalog list.
WhatsApp-side limitations
If catalog methods are called frequently, WhatsApp may temporarily restrict access to the Business Catalog API. Do not send a large number of requests to catalog methods over a short period of time.
Request#
To move collections, you need to send a request to the address:
{{apiUrl}}/waInstance{{idInstance}}/moveCollections/{{apiTokenInstance}}
To obtain the request parameters idInstance and apiTokenInstance, refer to the section Before you start.
Request parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
collections | array | Yes | A non-empty array of objects with information about moving each collection |
Collection move object:
| Field | Type | Required | Description |
|---|---|---|---|
collectionId | string | Yes | Unique identifier of the collection to be moved |
fromIndex | integer | Yes | Current index of the collection (an integer, starts at 0) |
toIndex | integer | Yes | New index of the collection (an integer, starts at 0) |
The collectionId, fromIndex, and toIndex values must not repeat within the array: each of the three fields is checked for duplicates separately.
Request body example#
{
"collections": [
{ "collectionId": "2205593430194788", "fromIndex": 0, "toIndex": 1 },
{ "collectionId": "25790827003925602", "fromIndex": 1, "toIndex": 0 }
]
}
Response#
Response fields#
| Field | Type | Description |
|---|---|---|
moved | boolean | Returns true if the move was successful |
collections | array | Array of objects confirming the move for each collection |
Response body example#
{
"moved": true,
"collections": [
{
"collectionId": "2205593430194788",
"fromIndex": 0,
"toIndex": 1
},
{
"collectionId": "25790827003925602",
"fromIndex": 1,
"toIndex": 0
}
]
}
MoveCollections errors#
For a list of common errors for all methods, see the section Common errors
| HTTP code | Error identifier | Description |
|---|---|---|
| 400 | Catalog mutations require a business account | WhatsApp-side restriction that occurs when catalog methods are called frequently. Returned even when the request is made from a Business account |
Code examples#
import requests
url = "{{apiUrl}}/waInstance{{idInstance}}/moveCollections/{{apiTokenInstance}}"
payload = {
"collections": [
{"collectionId": "2205593430194788", "fromIndex": 0, "toIndex": 1},
{"collectionId": "25790827003925602", "fromIndex": 1, "toIndex": 0}
]
}
headers = {
'Content-Type': 'application/json'
}
response = requests.post(url, json=payload, headers=headers)
print(response.text.encode('utf8'))
curl --location '{{apiUrl}}/waInstance{{idInstance}}/moveCollections/{{apiTokenInstance}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"collections": [
{"collectionId": "2205593430194788", "fromIndex": 0, "toIndex": 1},
{"collectionId": "25790827003925602", "fromIndex": 1, "toIndex": 0}
]
}'