Developer documentation

Build with the O My Syria interfaces available today

Use the implemented REST contract and restricted web Widget safely. This documentation is explicit about what is available now and what remains planned.

Quick start

Check the API in one request

The public system ping is the smallest safe request for checking that the API is reachable and ready. It needs no key.

  1. 1Open a terminal (or point the request at your own deployment's origin).
  2. 2Send the request from your terminal.
  3. 3Expect a 200 response with the standard data envelope.
GET /v1/system/ping
curl --request GET "https://omysyria.com/v1/system/ping"

Authentication boundaries

Choose credentials by endpoint, not by convenience

Every operation in the reference declares its actual security scheme. Credentials remain scoped to one purpose and must never be exchanged for another.

Implemented

Server secret API key

Trusted backends call POST /v1/answers with X-AHS-API-Key and no browser Origin. An optional exact IP allowlist can restrict the source. Never place this secret in browser or mobile code.

Implemented

Management session

Dashboard and management routes use the secure ahs_session cookie. State-changing browser requests also require the paired X-CSRF-Token header. These routes are not a server-key API.

Implemented

Publishable Widget key

Widget routes accept X-AHS-Publishable-Key only from an allowed browser origin. Conversation operations also use a short-lived X-AHS-Conversation-Token. A publishable key is restricted, browser-visible, and not an administrative secret.

Trusted backend storage only

Never send the server key or conversation reference to browser code, mobile apps, or logs. Treat conversation_ref as opaque metadata and do not place customer questions or O My Syria answers in operational logs.

Base URLsHTTPS encrypted

Base URLs and environments

Test and Production share one base URL; the server key you send decides which environment answers.

Production environment

Production

https://omysyria.com

Requires an ahs_sk_live_... server key.

Test environment

Test

https://omysyria.com

Same base URL with an ahs_sk_test_... key for the Test environment.

REST endpointsJSON over HTTP

Available Messages endpoints

These are the endpoints your platform or mobile app uses to send customer questions and receive answers grounded in your knowledge.

POST /v1/answersPrimary

Send a message and get the answer

Send a customer question and receive a grounded answer, with multi-turn context and idempotent retries.

DELETE /v1/server-conversationsLifecycle

End and delete a conversation

Delete retained conversation history by its opaque reference when the session ends or the customer asks.

Code samples and ready client helpers

Pick a scenario and a language to copy integration code or a full client wrapper.

curl --request POST "https://omysyria.com/v1/answers" \
  --header "Content-Type: application/json" \
  --header "X-AHS-API-Key: ahs_sk_live_••••••••••••" \
  --data '{
    "message_id": "support-msg-101",
    "question": "كيف أسحب رصيدي من المحفظة؟",
    "language": "ar"
  }'

Response envelope (200 OK)

200 OK
{
  "data": {
    "status": "grounded",
    "answer": "يمكنك سحب الرصيد المتاح من صفحة المحفظة في التطبيق: اختر طلب سحب ثم أدخل البيانات البنكية المطلوبة.",
    "conversation_ref": "ahs_conv_live_9f83a27e01b44298a0c6d9124e8371b29a8f",
    "message_id": "support-msg-101",
    "handoff_suggested": false,
    "citations": [
      {
        "citation_id": "cite_01",
        "source_filename": "wallet-and-payouts.md"
      }
    ]
  }
}

Conversation flow

How multi-turn memory works across requests with the opaque conversation_ref.

  1. 1

    First turn

    Send question and a unique message_id without conversation_ref. O My Syria returns the answer and a conversation_ref.

  2. 2

    Store the reference

    Your server stores conversation_ref next to the customer’s support session.

  3. 3

    Follow-up turns

    Send the next question with conversation_ref and a new message_id so the dialogue context is kept.

  4. 4

    Handoff or end

    If handoff_suggested is true, route the customer to a human agent; call DELETE when the session ends.

Parameters and fields

Field constraints, accepted patterns and payload limits for each request and response.

Request headers

HeaderStatusDescription and constraints
X-AHS-API-KeyRequiredServer secret API key (ahs_sk_live_... or ahs_sk_test_...). Never expose it to browser or mobile code.
Content-Typeapplication/jsonThe request body must be sent as application/json.
X-AHS-Conversation-RefRequired for DELETE onlySent with DELETE /v1/server-conversations to name the conversation to delete.

Request body (POST /v1/answers)

FieldTypeStatusDescription and constraints
questionstringRequiredThe customer’s message text. At most 8 KB of UTF-8 text.
message_idstringRecommendedUnique client message ID (pattern ^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$, 1–128 characters) for idempotent retries and ordering.
conversation_refstringOptionalOpaque conversation reference (pattern ^ahs_conv_live_[A-Za-z0-9_-]{43}$) returned by an earlier turn, used to resume the dialogue.
languagestringOptionalAnswer language, "ar" or "en". Defaults to "ar".

Response fields (data object)

FieldTypeMeaning and possible values
statusstringAnswer status: grounded (answered from your knowledge), insufficient_context (the knowledge is not enough), out_of_scope, or safety_flagged.
answerstringThe customer-facing answer, built from your documents and policies.
conversation_refstringThe opaque conversation reference to store and send with follow-up turns.
message_idstringThe client message ID from the request.
handoff_suggestedbooleanTrue when a human agent should take over.
citationsarraySources the answer is based on: [{ citation_id, source_filename }].
Possible values of status:groundedinsufficient_contextout_of_scopesafety_flagged

Error codes

Every failed response uses the standard ErrorEnvelope.

CodeHTTPMeaning
invalid_api_key401The server API key is missing, invalid, or revoked.
invalid_input422The request does not match the schema or size limit (empty question or more than 8 KB).
invalid_message_id422message_id does not match the accepted pattern.
conversation_not_found404The conversation reference is unknown, expired (after 30 days) or deleted.
request_in_progress409The message is still being processed. Read the Retry-After header and retry.
idempotency_conflict409The same message_id was reused with a different payload.
rate_limited429Rate limit exceeded (200 requests per minute per server key and 60 per minute per IP address).
grounded_answer_unavailable503Answer generation or the knowledge base is temporarily unavailable.