Skip to main content

Reorder Collections

This endpoint updates the display order of multiple collections.

Endpoint

POST /api/collections/reorder

Authentication

Authentication is required. User must have admin or creator role.

Request Body

FieldTypeRequiredDescription
collectionIdsArrayYesArray of collection IDs in the desired order

Response

Success Response

  • Status Code: 200 OK
  • Content: Success message
{
"success": true
}

Error Response

  • Status Code: 404 Not Found
  • Content: Error message if a collection is not found
{
"error": "Collection not found"
}
  • Status Code: 403 Forbidden
  • Content: Error message if the user doesn't have permission
{
"error": "Access denied"
}
  • Status Code: 500 Internal Server Error
  • Content: Error message for server errors
{
"error": "Something went wrong"
}

Notes

  • This endpoint updates the position field of each collection based on its index in the collectionIds array.
  • The first collection in the array will have position 1, the second will have position 2, and so on.
  • All collections in the array must belong to the same platform.
  • The order is also synchronized with Firebase Firestore for use in the mobile application.
  • This operation is performed within a database transaction to ensure consistency.
  • If the transaction fails, all changes are rolled back.

Example

curl -X POST "https://api.tribesocial.io/api/collections/reorder" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"collectionIds": [123, 456, 789]
}'