Skip to content

Run copilot query

POST/ai/copilot/query

Submits a natural-language query to the AI Copilot and returns the model's response. Queries are evaluated against the tenant's active governance policies before execution; requests that violate a policy will be blocked and logged. Use for ad-hoc AI assistance in any CRM context (e.g. draft an email, summarise a ticket, analyse a deal).

Request

Request body

Content type application/json (required).

FieldTypeRequiredDescription
promptstringYes

The natural-language instruction or question for the AI model.

Max length: 8000

template_idinteger, nullableNo

ID of a saved prompt template to use as the base for this query.

contextobjectNo

Structured context data passed to the AI model (e.g. customer_id, module name).

streambooleanNo

When true, the response is returned as a server-sent event stream.

Default: false

Example

{
  "prompt": "Summarise the last 5 support tickets for Acme Corp and identify the most common issue.",
  "template_id": 12,
  "context": {
    "customer_id": 88,
    "module": "support"
  },
  "stream": false
}

Responses

200 AI copilot response returned

Content type application/json, object · AiCopilotQueryResponseV1.

FieldTypeRequiredDescription
idstringNo

Unique query identifier for logging and audit.

promptstringNo

The original prompt submitted.

responsestringNo

The AI model's generated response text.

modelstringNo

The AI model identifier used to generate the response.

policy_resultstringNo

Result of the governance policy evaluation for this query.

One of: "allowed", "blocked", "flagged"

tokens_usedintegerNo

Total tokens consumed by the prompt and response.

created_atstring (date-time)No

Example

{
  "id": "qry_01HXM4K2P3N7V8QRST",
  "prompt": "Summarise the last 5 support tickets for Acme Corp and identify the most common issue.",
  "response": "Acme Corp's 5 most recent tickets (Apr 2–7) all relate to login failures after the SSO migration. Root cause appears to be an Okta domain mismatch in their identity config.",
  "model": "claude-3-haiku-20240307",
  "policy_result": "allowed",
  "tokens_used": 812,
  "created_at": "2026-04-08T10:15:00Z"
}

403 Query blocked by an active AI governance policy

422 Validation failed — check prompt length or template_id

Example request

curl -X POST "https://{tenant}.faciotech.net/api/v1/ai/copilot/query" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Summarise the last 5 support tickets for Acme Corp and identify the most common issue.", "template_id": 12, "context": {"customer_id": 88, "module": "support"}, "stream": false}'
Loading