DevelopersRAG-API reference
Chunks
Edit chunk content in place and roll back to a previous version.
The chunks endpoints let you surgically modify individual chunks within a knowledge base. Edits are re-embedded automatically so semantic search reflects the change immediately.
Authentication: Bearer API key required on all endpoints (see Authentication).
PATCH /chunks/:chunkId
Replaces the text content of an existing chunk and re-embeds it. Use this for targeted corrections — factual errors, outdated figures, or small clarifications. Provide the complete new content, not a diff.
If your edit changes the content by more than 35%, you must provide a large_change_justification. Requests without it will be rejected.
Path parameters
| Parameter | Type | Description |
|---|---|---|
chunkId | number | Database ID of the chunk to edit. |
Request body
Prop
Type
Example
curl -X PATCH https://api.mojar.ai/chunks/8821 \
-H "Authorization: Bearer nest-YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"new_content": "The Starter tier is priced at $59/month (updated April 2026)...",
"change_summary": "Updated Starter tier price from $49 to $59",
"reason": "Price increase effective April 2026"
}'const response = await fetch("https://api.mojar.ai/chunks/8821", {
method: "PATCH",
headers: {
Authorization: "Bearer nest-YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
new_content: "The Starter tier is priced at $59/month (updated April 2026)...",
change_summary: "Updated Starter tier price from $49 to $59",
reason: "Price increase effective April 2026",
}),
});
const result = await response.json();Response — 200 OK
{
"chunkId": 8821,
"message": "Chunk edited successfully"
}PATCH /chunks/:chunkId/rollback/:versionId
Restores a chunk to a previous version from its edit history.
Path parameters
| Parameter | Type | Description |
|---|---|---|
chunkId | number | Database ID of the chunk to restore. |
versionId | number | ID of the edit-history entry to roll back to. Retrieve version IDs from the chunk's metadata.edit_history array. |
Example
curl -X PATCH https://api.mojar.ai/chunks/8821/rollback/3 \
-H "Authorization: Bearer nest-YOUR_API_KEY"const response = await fetch("https://api.mojar.ai/chunks/8821/rollback/3", {
method: "PATCH",
headers: {
Authorization: "Bearer nest-YOUR_API_KEY",
},
});
const result = await response.json();Response — 200 OK
{
"message": "Chunk rolled back successfully",
"chunkId": 8821,
"restoredVersionId": 3
}Error cases
| Status | Condition |
|---|---|
400 Bad Request | chunkId or versionId missing. |
401 Unauthorized | Invalid or missing API key. |
403 Forbidden | The authenticated agent does not own the source document. |
404 Not Found | Chunk not found, no edit history exists, or the specified version ID is not in the history. |
422 Unprocessable Entity | The target version entry does not include a previous_content value to restore. |