Trigger embedding sync
const url = 'https://example.com/wp-json/wp2tutor/embedding/v1/sync';const options = { method: 'POST', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"ids":[42,43]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/wp-json/wp2tutor/embedding/v1/sync \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "ids": [ 42, 43 ] }'Computes vectors for the given RAG chunk ids (id_chunk) and upserts them into sqlite-vec. PHP EmbeddingRestController::sync → SyncService::sync_chunk_ids. Chunk source comes from filter wp2tutor/embedding/chunk_source (RAG module).
JSON body { ids: int[] }; non-array is treated as empty. PHP intval + unique. Empty list → 200, ok true, processed 0, message No ids.
Not WP_Error: success and failure share { ok, processed, message }. ok false → HTTP 400 (no chunk source, empty embedding API key, unresolved model, sqlite-vec load failure, batch failure, etc.). ok true → 200, processed = id count after normalize, message OK.
Requires manage_options. Cookie + X-WP-Nonce or Application Password.
Authorizations
Section titled “Authorizations”Request Body
Section titled “Request Body”object
RAG chunk ids (id_chunk), not WordPress post ids. PHP: non-array treated as []. intval, unique. Empty → 200 ok true processed 0 message No ids.
Example
{ "ids": [ 42, 43 ]}Responses
Section titled “Responses”Ok true. processed is how many ids went into batches (after intval/unique). message is usually OK or No ids.
object
True on 200 (including empty ids). false on HTTP 400 — vectors were not written (or a batch failed).
Number of ids after normalize that went through embed+upsert batches. On ok false PHP sets 0. On No ids. — 0.
Short SyncService outcome: OK, No ids., or a failure reason (chunk source, API key, sqlite-vec, Embedding API failed for a batch, exception).
Example
{ "ok": true, "processed": 2, "message": "OK"}Ok false, same body (not WP_Error). Typical PHP message: Chunk source unavailable (enable RAG + chunks DB).; Unknown embedding model configuration.; Embedding API key is empty.; Chunk database path missing.; sqlite-vec extension could not load (see lib/sqlite-vec/README.md).; Embedding API failed for a batch.; or exception getMessage().
object
True on 200 (including empty ids). false on HTTP 400 — vectors were not written (or a batch failed).
Number of ids after normalize that went through embed+upsert batches. On ok false PHP sets 0. On No ids. — 0.
Short SyncService outcome: OK, No ids., or a failure reason (chunk source, API key, sqlite-vec, Embedding API failed for a batch, exception).
Example
{ "ok": false, "processed": 0, "message": "Embedding API key is empty."}Not authenticated. DualRest: rest_forbidden (status 401) when there is no cookie session. Cookie + X-WP-Nonce or Application Password.
object
WP_Error code. For POST /chat 401 — rest_forbidden. DualRest cookie — rest_forbidden / rest_not_logged_in / rest_cookie_invalid_nonce.
WP_Error message (for the chat secret — Missing or invalid secret.).
Usually { status: HTTP code }, as PHP stores in WP_Error data.
object
Example
{ "code": "rest_forbidden", "message": "Missing or invalid secret.", "data": { "status": 401 }}Missing manage_options or invalid REST nonce. WordPress REST: rest_forbidden / rest_cookie_invalid_nonce.
object
WP_Error code. For POST /chat 401 — rest_forbidden. DualRest cookie — rest_forbidden / rest_not_logged_in / rest_cookie_invalid_nonce.
WP_Error message (for the chat secret — Missing or invalid secret.).
Usually { status: HTTP code }, as PHP stores in WP_Error data.
object
Example
{ "code": "rest_forbidden", "message": "Missing or invalid secret.", "data": { "status": 401 }}