MojarMojar
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

ParameterTypeDescription
chunkIdnumberDatabase 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

ParameterTypeDescription
chunkIdnumberDatabase ID of the chunk to restore.
versionIdnumberID 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

StatusCondition
400 Bad RequestchunkId or versionId missing.
401 UnauthorizedInvalid or missing API key.
403 ForbiddenThe authenticated agent does not own the source document.
404 Not FoundChunk not found, no edit history exists, or the specified version ID is not in the history.
422 Unprocessable EntityThe target version entry does not include a previous_content value to restore.

On this page