AI operations

Search, retrieval, threads and the AI configuration of the app.

Docs menu

ai

ai.ask

Ask a question against a knowledge collection.

Route
ANY ask
Auth
App key or user session; your security rules apply none
CLI
substrio op ai.ask

Parameters

NameInTypeRequiredDescription
collectionbodystringYes
questionbodystringYes

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URLask" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.ask.route

Ask a question against a knowledge collection over HTTP.

Route
POST /v1/{collection}/_ask
Auth
App key or user session; your security rules apply none
MCP tool
substrio_ask
CLI
substrio op ai.ask.route

Parameters

NameInTypeRequiredDescription
collectionpathstringYesThe collection's name, as collection.list names it.
questionbodystringYes
search_kbodyintegerNo
expand_beforebodyintegerNo
expand_afterbodyintegerNo

Response

FieldTypePresentDescription
contextarray of objectAlways
citationsarray of integerAlways
source_documentsarray of integerWhen set
search_hitsintegerAlways
chunks_usedintegerAlways
collectionstringAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/$COLLECTION/_ask" \
  -H "Authorization: Bearer $SUBSTRIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question":"question"}'

ai.audit

Read the agent requests of the app's audit trail (action agent.request in audit.list), newest first: each has its actor, the operation it called and its outcome. Options: since (Unix seconds; the last hour when neither since nor context_id is given), limit (default 50), context_id (an agent session id) and tool_name (needs since or context_id).

Route
GET /v1/_ai/audit
Auth
App key tenant
MCP tool
substrio_ai_audit
CLI
substrio op ai.audit

Parameters

NameInTypeRequiredDescription
limitqueryinteger (0 or more)Nothe most items to return.
sincequeryinteger (0 or more)Noonly entries at or after this Unix time, in seconds.
context_idquerystringNoonly audit entries of this agent context.
tool_namequerystringNoonly audit entries of this tool.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/_ai/audit" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.expand

Expand context around a chunk.

Route
ANY expand
Auth
App key or user session; your security rules apply none
CLI
substrio op ai.expand

Parameters

NameInTypeRequiredDescription
collectionbodystringYes
chunk_idbodystringYes

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URLexpand" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.expand.route

Expand one knowledge chunk of a collection with its surrounding chunks; see the schema.

Route
POST /v1/{collection}/_expand
Auth
App key or user session; your security rules apply none
MCP tool
substrio_expand
CLI
substrio op ai.expand.route

Parameters

NameInTypeRequiredDescription
collectionpathstringYesThe collection's name, as collection.list names it.
_idbodystring or integerYes
beforebodyintegerNo
afterbodyintegerNo

Response

FieldTypePresentDescription
chunksarray of objectAlways
_parent_idintegerAlways
_chunk_totalintegerAlways
expandable_beforeintegerAlways
expandable_afterintegerAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/$COLLECTION/_expand" \
  -H "Authorization: Bearer $SUBSTRIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"_id":"_id"}'

ai.feedback

Record search relevance feedback.

Route
ANY feedback
Auth
App key or user session; your security rules apply none
CLI
substrio op ai.feedback

Parameters

NameInTypeRequiredDescription
collectionbodystringYes
query_hashbodystringYes
document_idbodystringYes
signalbodystringYes

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URLfeedback" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.feedback.analytics

Read aggregated search feedback.

Route
GET /v1/{collection}/_feedback/analytics
Auth
App key or user session; your security rules apply none
CLI
substrio op ai.feedback.analytics

Parameters

NameInTypeRequiredDescription
collectionpathstringYesThe collection's name, as collection.list names it.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/$COLLECTION/_feedback/analytics" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.feedback.list

List recent search feedback.

Route
GET /v1/{collection}/_feedback
Auth
App key or user session; your security rules apply none
CLI
substrio op ai.feedback.list

Parameters

NameInTypeRequiredDescription
collectionpathstringYesThe collection's name, as collection.list names it.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/$COLLECTION/_feedback" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.feedback.write

Record search relevance feedback over HTTP.

Route
POST /v1/{collection}/_feedback
Auth
App key or user session; your security rules apply none
MCP tool
substrio_feedback
CLI
substrio op ai.feedback.write

Parameters

NameInTypeRequiredDescription
collectionpathstringYesThe collection's name, as collection.list names it.
querybodystringYes
doc_idbodystring or integerYes
signalbody"click" | "star" | "irrelevant"Yes
user_idbodystringNo

Response

FieldTypePresentDescription
recordedanyAlways
query_hashstringAlways
aggregate_scorenumberAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/$COLLECTION/_feedback" \
  -H "Authorization: Bearer $SUBSTRIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"query":"query","doc_id":"doc_id","signal":"click"}'

ai.models

List the distinct provider and model pairs the app's collections' RAG configurations use.

Route
GET /v1/_models
Auth
App key tenant
MCP tool
substrio_ai_models
CLI
substrio op ai.models

Parameters

No parameters.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/_models" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.search

Search a knowledge collection.

Route
ANY search
Auth
App key or user session; your security rules apply none
CLI
substrio op ai.search

Parameters

NameInTypeRequiredDescription
collectionbodystringYes
querybodystringYes

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URLsearch" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

ai.tool.invoke

Invoke a discovered administrative tool by operation ID.

Route
POST /v1/_tools/invoke
Auth
App key tenant
MCP tool
substrio_tool_invoke
CLI
substrio op ai.tool.invoke

Parameters

NameInTypeRequiredDescription
operation_idbodyintegerYesMinimum 1.
methodbodystringNo
capturesbodyarray of stringNo
payloadbodyanyNo

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/_tools/invoke" \
  -H "Authorization: Bearer $SUBSTRIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"operation_id":1}'

ai.tools

Describe administration tools available to the caller.

Route
GET /v1/_tools
Auth
App key tenant
CLI
substrio op ai.tools

Parameters

No parameters.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/_tools" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

mcp

mcp.rpc

Serve the tenant's tools to AI agents over MCP (JSON-RPC, Streamable HTTP).

Route
MCP and CLI only
Auth
App key or user session; your security rules apply none
CLI
substrio op mcp.rpc

Parameters

No parameters.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

substrio op mcp.rpc

search.analytics

Read search analytics for a collection.

Route
GET /v1/{collection}/_analytics/search
Auth
App key or user session; your security rules apply none
CLI
substrio op search.analytics

Parameters

NameInTypeRequiredDescription
collectionpathstringYesThe collection's name, as collection.list names it.
sincequeryinteger (0 or more)Noonly entries at or after this Unix time, in seconds.
top_nqueryinteger (0 or more)Nohow many top search terms to return.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/$COLLECTION/_analytics/search" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread

thread.ask

Ask one question in an agent thread by id; see the schema.

Route
POST /v1/_threads/{id}/_ask
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_ask
CLI
substrio op thread.ask

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
questionbodystringYes
search_kbodyintegerNo
max_context_messagesbodyintegerNo
max_context_tokensbodyintegerNo

Response

FieldTypePresentDescription
contextarray of objectAlways
citationsarray of integerAlways
conversationarray of objectAlways
search_hitsintegerAlways
rag_chunksintegerAlways
thread_idstringAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/_threads/$ID/_ask" \
  -H "Authorization: Bearer $SUBSTRIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question":"question"}'

thread.create

Create an agent thread, a conversation record; see the schema.

Route
POST /v1/_threads
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_create
CLI
substrio op thread.create

Parameters

NameInTypeRequiredDescription
titlebodystringNo
max_messagesbodyintegerNo
max_context_tokensbodyintegerNo
max_context_messagesbodyintegerNo
search_kbodyintegerNo
expand_beforebodyintegerNo
expand_afterbodyintegerNo
system_promptbodystringNo
modelbodystringNo
auto_titlebodybooleanNo
rag_collectionsbodyarray of stringNo
tool_presetbody"read_only" | "analyst" | "curator" | "operator"No
tool_budget_max_callsbodyintegerNo
tool_budget_max_writesbodyintegerNo
write_collectionsbodyarray of stringNo
memory_collectionbodystringNo
metadatabodyanyNoAny value, stored as given.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/_threads" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.delete

Delete one agent thread by its id (the route's {id}, as thread.list shows it).

Route
DELETE /v1/_threads/{id}
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_delete
CLI
substrio op thread.delete

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.

Response

FieldTypePresentDescription
deletedanyAlways
idstringAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X DELETE "$SUBSTRIO_URL/v1/_threads/$ID" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.get

Read one agent thread by its id (the route's {id}, as thread.list shows it).

Route
GET /v1/_threads/{id}
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_get
CLI
substrio op thread.get

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.

Response

A JSON object.

Errors

  • THREAD_NOT_FOUND: call thread.list to find the right one.

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/_threads/$ID" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.list

List the app's agent threads (conversation records); thread.get reads one by its id.

Route
GET /v1/_threads
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_list
CLI
substrio op thread.list

Parameters

No parameters.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/_threads" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.message

Append one message to an agent thread by id.

Route
POST /v1/_threads/{id}/messages
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_message
CLI
substrio op thread.message

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
rolebody"user" | "assistant" | "system" | "tool" | "summary"Yes
contentbodystringYes
metadatabodyanyNoAny value, stored as given.

Response

FieldTypePresentDescription
idstringAlways
role"user" | "assistant" | "system" | "tool" | "summary"Always
created_atintegerAlways
token_countintegerAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/_threads/$ID/messages" \
  -H "Authorization: Bearer $SUBSTRIO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"role":"user","content":"content"}'

thread.message.delete

Delete one message of an agent thread: the route's thread {id} and {message_id}.

Route
DELETE /v1/_threads/{id}/messages/{message_id}
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_message_delete
CLI
substrio op thread.message.delete

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
message_idpathstring or integerYesThe message's id, as thread.messages.list returned it.

Response

FieldTypePresentDescription
deletedanyAlways
idstringAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X DELETE "$SUBSTRIO_URL/v1/_threads/$ID/messages/$MESSAGE_ID" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.messages.list

List the messages of one agent thread by id: options limit and order (asc or desc, default desc).

Route
GET /v1/_threads/{id}/messages
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_messages_list
CLI
substrio op thread.messages.list

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
limitqueryinteger (0 or more)Nothe most items to return.
orderquery"asc" | "desc"Noasc lists oldest first; desc (the default) newest first.

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl "$SUBSTRIO_URL/v1/_threads/$ID/messages" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.prune

Prune selected messages from an agent thread.

Route
POST /v1/_threads/{id}/_prune
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_prune
CLI
substrio op thread.prune

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
msg_idsbodyarray of stringNo
rolebodystringNo
keep_lastbodyintegerNo

Response

FieldTypePresentDescription
prunedanyAlways
deletedintegerAlways
remainingintegerAlways

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/_threads/$ID/_prune" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.summarize

Summarize one agent thread by its id (the route's {id}); see the schema for the options.

Route
POST /v1/_threads/{id}/_summarize
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_summarize
CLI
substrio op thread.summarize

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
keep_lastbodyintegerNo

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X POST "$SUBSTRIO_URL/v1/_threads/$ID/_summarize" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"

thread.update

Change one agent thread by id; see the schema.

Route
PATCH /v1/_threads/{id}
Auth
App key or user session; your security rules apply none
MCP tool
substrio_thread_update
CLI
substrio op thread.update

Parameters

NameInTypeRequiredDescription
idpathstring or integerYesThe thread's id, as thread.list or thread.create returned it.
titlebodystringNo
statusbody"active" | "archived"No
max_messagesbodyintegerNo
max_context_tokensbodyintegerNo
max_context_messagesbodyintegerNo
search_kbodyintegerNo
expand_beforebodyintegerNo
expand_afterbodyintegerNo
system_promptbodystringNo
modelbodystringNo

Response

A JSON object.

Errors

A failed call answers the error envelope with a typed code.

Example

curl -X PATCH "$SUBSTRIO_URL/v1/_threads/$ID" \
  -H "Authorization: Bearer $SUBSTRIO_KEY"