Get a single RAG chunk
const url = 'https://example.com/wp-json/wp2tutor/rag/v1/chunk/42';const options = {method: 'GET', headers: {'X-WP-Nonce': '<X-WP-Nonce>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Chunk id in RAG SQLite (id_chunk). PHP absint from path (?P<id_chunk>\\d+).
Example
42Responses
Section titled “Responses”Chunk row plus status_icon, metadata_html, created_at_human, word_count.
object
Chunk id (same as the path).
Source WordPress post id.
Same as DataTables: 🟢 ACTIVE, 🔵 INDEXING, 🔴 ERROR, ⚪ otherwise.
Full chunk text from SQLite, not the preview.
MD5 of full content (ChunkSyncService: md5($content)), 32 hex chars from the content_hash column.
Same HTML as format_metadata_html in DataTables.
UTC mysql datetime.
Local d.m.Y H:i.
PostRagChunkGenerator::count_words — unicode word count (letters/digits) of content with HTML stripped.
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.
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 }}No chunk for this id_chunk on the current site. PHP: WP_REST_Response { message: Not found }, not WP_Error.
object
PHP literal Not found (not i18n).
Example
{ "message": "Not found"}