Update Entity

Endpoint

URL: https://api.replyke.com/:projectId/entities/:entityId

Method: PATCH

Authentication Required: Optional (If updating a user-owned entity, authentication is required)


Description

This endpoint updates an existing entity. Only fields that are explicitly provided in the request body will be updated. If the entity belongs to a user, authentication is required to ensure the request is authorized.


Request

Headers

  • Authorization: Bearer <accessToken> (Required if updating a user-owned entity)

URL Parameters

ParameterTypeRequiredDescription
projectIdstringYesThe project ID associated with the request.
entityIdstringYesThe ID of the entity to update.

Body Parameters

ParameterTypeRequiredDescription
titlestringNoThe updated title of the entity.
contentstringNoThe updated content of the entity.
mediaobject[]NoAn array of media objects. Media format is free-form.
keywordsstring[]NoAn array of keywords associated with the entity.
metadataobjectNoJSON object containing additional metadata.
mentionsarrayNoAn array of mentions, each containing an id and username.
locationobjectNoAn object representing the location of the entity, formatted as: {"type": "Point", "coordinates": [longitude, latitude]}

Example Request

{
  "title": "Updated Entity Title",
  "content": "Updated content for the entity.",
  "keywords": ["example", "update"],
  "metadata": { "category": "news" },
  "mentions": [{ "id": "user-1111", "username": "john_doe" }],
  "location": { "type": "Point", "coordinates": [120.982, 14.604] }
}

Response

Success Response (200 OK)

{
  "id": "<ENTITY_ID>",
  "projectId": "<PROJECT_ID>",
  "referenceId": "<REFERENCE_ID>",
  "userId": "<USER_ID>",
  "title": "Updated Entity Title",
  "content": "Updated content for the entity.",
  "keywords": ["example", "update"],
  "mentions": [{ "id": "user-1111", "username": "john_doe" }],
  "location": { "type": "Point", "coordinates": [120.982, 14.604] },
  "upvotes": [],
  "downvotes": [],
  "sharesCount": 0,
  "views": 0,
  "score": 0,
  "metadata": { "category": "news" },
  "createdAt": "<TIMESTAMP>",
  "updatedAt": "<TIMESTAMP>",
  "deletedAt": null
}

Error Responses

Invalid Entity ID (400 Bad Request)

{
  "error": "Invalid entityID"
}

Unauthorized (403 Forbidden)

{
  "error": "You do not have permission to update this entity."
}

Entity Not Found (404 Not Found)

{
  "error": "Entity not found"
}

Server Error (500 Internal Server Error)

{
  "error": "Failed to update the entity"
}

Notes

  • If the entity is user-owned, only the user who created it can update it.
  • Only provided fields will be updated; unspecified fields remain unchanged.
  • media is a free-form array and its structure depends on the project implementation.
  • mentions should be passed as an array of objects containing id and username fields.
  • location should be passed in GeoJSON format (type: "Point").