Skip to content

Get a single RAG chunk

GET
/wp-json/wp2tutor/rag/v1/chunk/{id_chunk}
curl --request GET \
--url https://example.com/wp-json/wp2tutor/rag/v1/chunk/42 \
--header 'X-WP-Nonce: <X-WP-Nonce>'

Full text of one chunk for the current site (get_current_blog_id) by path id_chunk (absint). PHP find_by_chunk_id: no row → 404 { message: Not found } (not WP_Error). Requires manage_options.

id_chunk
required
integer
>= 1

Chunk id in RAG SQLite (id_chunk). PHP absint from path (?P<id_chunk>\\d+).

Example
42

Chunk row plus status_icon, metadata_html, created_at_human, word_count.

Media typeapplication/json
object
id_chunk

Chunk id (same as the path).

integer
id_post

Source WordPress post id.

integer
status_icon

Same as DataTables: 🟢 ACTIVE, 🔵 INDEXING, 🔴 ERROR, ⚪ otherwise.

string
content

Full chunk text from SQLite, not the preview.

string
content_hash

MD5 of full content (ChunkSyncService: md5($content)), 32 hex chars from the content_hash column.

string
metadata_html

Same HTML as format_metadata_html in DataTables.

string
created_at

UTC mysql datetime.

string
created_at_human

Local d.m.Y H:i.

string
word_count

PostRagChunkGenerator::count_words — unicode word count (letters/digits) of content with HTML stripped.

integer
Example
{
"id_chunk": 42,
"id_post": 15,
"status_icon": "🟢",
"content": "Embedding is a vector representation of a text chunk.",
"content_hash": "5d41402abc4b2a76b9719d911017c592",
"metadata_html": "<div class=\"wp2tutor-rag-meta\"><h4>Source</h4><ul><li><strong>post_type:</strong> page</li></ul></div>",
"created_at": "2026-09-13 10:00:00",
"created_at_human": "13.09.2026 13:00",
"word_count": 6
}

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
}
}

No chunk for this id_chunk on the current site. PHP: WP_REST_Response { message: Not found }, not WP_Error.

Media typeapplication/json
object
message

PHP literal Not found (not i18n).

string
Example
{
"message": "Not found"
}