API EndpointsListsAdd Entity to List

Add Entity to List

Endpoint

URL: /:projectId/lists/add-entity

Method: PATCH

Authentication Required: Yes (Access Token in Authorization Header)


Description

This endpoint allows users to add an entity to a specified list. The list must belong to the authenticated user, and the entity must not already be in the list.


Request

Path Parameters

ParameterTypeRequiredDescription
projectIdstringYesThe project ID associated with the request.

Headers

HeaderTypeRequiredDescription
AuthorizationstringYesBearer token for authentication.

Body Parameters

ParameterTypeRequiredDescription
listIdstringYesThe ID of the list to update.
entityIdstringYesThe ID of the entity to be added.

Example Request

PATCH /12345/lists/add-entity
Content-Type: application/json
Authorization: Bearer <ACCESS_TOKEN>
 
{
  "listId": "67890",
  "entityId": "entity123"
}

Response

Success Response (200 OK)

{
  "id": "67890",
  "projectId": "12345",
  "userId": "56789",
  "parentId": "123",
  "name": "My List",
  "entityIds": ["entity123", "entity456"],
  "entities": [
    {
      "id": "entity123",
      "title": "Sample Entity 123",
      "content": "This is the content of entity 123."
    },
    {
      "id": "entity456",
      "title": "Sample Entity 456",
      "content": "This is the content of entity 456."
    }
  ],
  "createdAt": "2024-02-12T10:00:00Z",
  "updatedAt": "2024-02-12T10:05:00Z"
}

Error Responses

Missing or Invalid Data (400 Bad Request)

{
  "error": "Missing projectId, entityId or listId in request body"
}

List Not Found (404 Not Found)

{
  "error": "List not found"
}

Server Error (500 Internal Server Error)

{
  "error": "Server error"
}

Notes

  • The authenticated user must own the list.
  • The entity must not already be in the list.
  • The response includes the updated list details with the newly added entity.