Endpoint #
POST /wp-json/rtcl/v1/listing/fb/image/sort
Description #
Reorders images in a listing’s gallery by updating the menu_order of each attachment. The order of attachment IDs in the request determines their new position (0-indexed).
Authentication #
Requires valid authentication with both API key and JWT token.
Required Headers:
| Header | Description |
|---|---|
X-API-KEY | API key configured in plugin settings |
Authorization | Bearer token (JWT) for authenticated user requests |
Content-Type #
application/json
Request Parameters #
| Parameter | Type | Required | Description |
|---|---|---|---|
listing_id | integer | Yes | The listing ID containing the images |
attachment_ids | array | Yes | Array of attachment IDs in the desired order |
form_id | integer | Yes | The Form Builder form ID |
Request Examples #
JSON Body (Recommended) #
bash
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/fb/image/sort" \
-H "X-API-KEY: your-api-key" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"listing_id": 405,
"attachment_ids": [408, 406, 407, 409],
"form_id": 5
}'
Form URL Encoded #
bash
curl -X POST "https://example.com/wp-json/rtcl/v1/listing/fb/image/sort" \
-H "X-API-KEY: your-api-key" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "listing_id=405&attachment_ids[]=408&attachment_ids[]=406&attachment_ids[]=407&attachment_ids[]=409&form_id=5"
Success Response (200 OK) #
Returns null on success (no response body).
Note: The endpoint does not return a response body on success. A 200 OK status indicates the sort operation completed successfully.
Error Responses #
403 Forbidden – Permission Denied #
json
{
"code": "FORBIDDEN",
"message": "You do not have sufficient permissions to set.",
"data": {
"status": 403
}
}
403 Forbidden – Empty Attachment IDs #
json
{
"code": "FORBIDDEN",
"message": "Attachment ids not exist.",
"data": {
"status": 403
}
}
401 Unauthorized – Missing API Key #
json
{
"status": "error",
"error": "MISSING_X_API_KEY_HEADER",
"code": "401",
"error_message": "X_API_KEY header not received. Either authorization header was not sent or it was removed by your server due to security reasons."
}
401 Unauthorized – Invalid API Key #
json
{
"status": "error",
"error": "INVALID_API_KEY",
"code": "401",
"error_message": "Sorry, you are using invalid API Key."
}
403 Forbidden – REST API Disabled #
json
{
"code": "DENIED_REST_API",
"message": "Denied api call",
"data": {
"status": 403
}
}