امتثال
واجهة البرمجة

Copilot

GET
/v1/copilot/sessions

PRD-007 S-51 (session history). Newest-first, with message_count + last_message_at per session. # ponytail ceiling: no search param in v1 (S-51 asks for search over history — deferred; see the FE handoff gap register).

Authorization

BearerAuth
headerAuthorizationBearer <token>

JWT access token. Obtain via POST /v1/auth/login.

Query Parameters

limit?Limit
Range1 <= value <= 100
Default20
offset?Offset
Range0 <= value
Default0

Response Body

Successful Response

application/json
  1. response
sessions*array<>
curl -X GET 'https://api.aisc.sa/v1/copilot/sessions'
{  "sessions": [    {      "code_id": "string",      "created_at": "2019-08-24T14:15:22Z",      "ended_at": "2019-08-24T14:15:22Z",      "last_message_at": "2019-08-24T14:15:22Z",      "message_count": 0,      "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82",      "updated_at": "2019-08-24T14:15:22Z"    }  ]}
POST
/v1/copilot/sessions

PRD-007 S-50 (session-persistent Copilot panel). Opens an agent.sessions row scoped to the caller + optionally a project. code_id selects which code's corpus subsequent messages in this session will query against — stored as the session's first agent.messages system row (see module docstring; agent.sessions has no code_id column, this is a v1 convention, not a schema change).

Authorization

BearerAuth
headerAuthorizationBearer <token>

JWT access token. Obtain via POST /v1/auth/login.

Request Body

application/json
  1. body
code_id*Code Id

Short code id (e.g. '801').

Length1 <= length <= 50
project_id?|

Optional project this session is scoped to.

Response Body

Session created.

application/json
  1. response
created_at*Created At
Formatdate-time
session_id*Session Id
Formatuuid
curl -X POST 'https://api.aisc.sa/v1/copilot/sessions' \  -H 'Content-Type: application/json' \  -d '{  "code_id": "string"}'
{  "created_at": "2019-08-24T14:15:22Z",  "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82"}
GET
/v1/copilot/sessions/{session_id}/messages

PRD-007 S-50 (session-persistent panel). Ordered role/content/model/created_at rows; the bookkeeping role='system' row (see module docstring's code_id convention) is excluded — only user/assistant/tool chat turns are returned.

Authorization

BearerAuth
headerAuthorizationBearer <token>

JWT access token. Obtain via POST /v1/auth/login.

Path Parameters

session_id*Session Id
Formatuuid

Response Body

Successful Response

application/json
  1. response
messages*array<>
curl -X GET 'https://api.aisc.sa/v1/copilot/sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/messages'
{  "messages": [    {      "content": "string",      "created_at": "2019-08-24T14:15:22Z",      "model": "string",      "role": "string"    }  ]}
POST
/v1/copilot/sessions/{session_id}/messages

Runs the SAME hardened pipeline as POST /codes/{code_id}/qa — rate limit, retrieval, LLM synthesis, AG-C1 recovery, citation policy, CODE_QA_INTERACTION audit emit — scoped to the session's code_id (set at session creation). Persists both the user question and the assistant answer as agent.messages rows (see module docstring for the assistant JSON-envelope convention) and returns the QAResponse shape plus session_id/message ids and an optional plan (numbered-step surface parsed from the answer — no executor; lands with the G2 lanes).

Authorization

BearerAuth
headerAuthorizationBearer <token>

JWT access token. Obtain via POST /v1/auth/login.

Path Parameters

session_id*Session Id
Formatuuid

Request Body

application/json
  1. body
lang?Lang
Default"ar"
Value in"ar""en"
question_text*Question Text
Length1 <= length <= 2000

Response Body

Answer + citations + session/message ids.

application/json
  1. response

QAResponse + session/message ids + the optional step-plan surface.

answer_text*Answer Text

Final answer in the requested language.

assistant_message_id*Assistant Message Id
Formatuuid
citations?array<>

Rules the LLM grounded its answer in.

dropped_sentence_count?Dropped Sentence Count

PRD-004 enforcement (emt-zi2): sentences removed from the raw LLM answer because a citation marker did not resolve to a retrieved rule. 0 = the model cited cleanly. Additive field; wire-compatible.

Range0 <= value
Default0
lang*Lang

Language of answer_text (echoes request.lang).

Value in"ar""en"
model_version*Model Version

LLM model_version used for synthesis (e.g. 'qwen.qwen3-235b-a22b-2507-v1:0').

plan?array<string>|

Numbered-step structure parsed from answer_text, when present. SURFACE ONLY — no executor; see module docstring.

prompt_hash*Prompt Hash

sha256: of the rendered prompt — replay-by-hash anchor.

prompt_version*Prompt Version

Version string of the prompt template (e.g. 'system_qa_ar.v1').

session_id*Session Id
Formatuuid
user_message_id*User Message Id
Formatuuid
curl -X POST 'https://api.aisc.sa/v1/copilot/sessions/497f6eca-6276-4993-bfeb-53cbbbba6f08/messages' \  -H 'Content-Type: application/json' \  -d '{  "question_text": "string"}'
{  "answer_text": "string",  "assistant_message_id": "bb34c082-20a7-446a-a2d9-976d65d15191",  "citations": [    {      "code_edition_id": "4a5f38c5-02cb-48ac-ba22-00d46bdf8402",      "recovered": false,      "relevance_score": 0,      "rule_id": "string",      "rule_text_ar": "string",      "rule_text_en": "string",      "section_number": "string"    }  ],  "dropped_sentence_count": 0,  "lang": "ar",  "model_version": "string",  "plan": [    "string"  ],  "prompt_hash": "string",  "prompt_version": "string",  "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82",  "user_message_id": "1798585b-bc85-46b6-801b-ecb7c9ceed07"}