Skip to content

Trigger embedding sync

POST
/wp-json/wp2tutor/embedding/v1/sync
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.

Media typeapplication/json
object
ids

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.

Array<integer>
Example
{
"ids": [
42,
43
]
}

Ok true. processed is how many ids went into batches (after intval/unique). message is usually OK or No ids.

Media typeapplication/json
object
ok

True on 200 (including empty ids). false on HTTP 400 — vectors were not written (or a batch failed).

boolean
processed

Number of ids after normalize that went through embed+upsert batches. On ok false PHP sets 0. On No ids. — 0.

integer
message

Short SyncService outcome: OK, No ids., or a failure reason (chunk source, API key, sqlite-vec, Embedding API failed for a batch, exception).

string
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().

Media typeapplication/json
object
ok

True on 200 (including empty ids). false on HTTP 400 — vectors were not written (or a batch failed).

boolean
processed

Number of ids after normalize that went through embed+upsert batches. On ok false PHP sets 0. On No ids. — 0.

integer
message

Short SyncService outcome: OK, No ids., or a failure reason (chunk source, API key, sqlite-vec, Embedding API failed for a batch, exception).

string
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.

Media typeapplication/json
object
code

WP_Error code. For POST /chat 401 — rest_forbidden. DualRest cookie — rest_forbidden / rest_not_logged_in / rest_cookie_invalid_nonce.

string
message

WP_Error message (for the chat secret — Missing or invalid secret.).

string
data

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.

Media typeapplication/json
object
code

WP_Error code. For POST /chat 401 — rest_forbidden. DualRest cookie — rest_forbidden / rest_not_logged_in / rest_cookie_invalid_nonce.

string
message

WP_Error message (for the chat secret — Missing or invalid secret.).

string
data

Usually { status: HTTP code }, as PHP stores in WP_Error data.

object
Example
{
"code": "rest_forbidden",
"message": "Missing or invalid secret.",
"data": {
"status": 401
}
}