Create or resume a chat session
const url = 'https://mw.omazy.ai/api/v1/chats';const options = { method: 'POST', headers: {Authorization: '<Authorization>', 'Content-Type': 'application/json'}, body: '{"app_id":"example","bot_profile_id":"example","channel":"example","initial_attachments":["example"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://mw.omazy.ai/api/v1/chats \ --header 'Authorization: <Authorization>' \ --header 'Content-Type: application/json' \ --data '{ "app_id": "example", "bot_profile_id": "example", "channel": "example", "initial_attachments": [ "example" ] }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Session parameters
object
Examplegenerated
{ "app_id": "example", "bot_profile_id": "example", "channel": "example", "initial_attachments": [ "example" ]}Responses
Section titled “Responses”OK
object
object
object
object
Customer_id (migration 000067) — the CRM contact this session resolves to once identity is captured. Required here so SELECT * scans cleanly.
Branch fork columns added by migration 000036. parent_session_id is the source session a branch was forked from; branched_at_message_id is the cut-off ULID — every source row with id <= this lives in the new session as a copy. Both nullable; populated only on sessions created via POST /ouchat/sessions/branch.
Routing audit columns added by migration 000039 (mw#259, RFC 2204 §5). RoutingReason records why this session landed on this app: explicit — caller specified the app and it was active no_app — caller provided no app; routed to OU AI app_not_found — caller specified an unknown app; routed to OU AI app_suspended — caller’s app is suspended; routed to OU AI app_deleted — caller’s app is deleted; routed to OU AI Set at insert time, never updated. Existing sessions stay on their original app even if its status flips later.
Topic is a short subject line shown in the recent-chats list. Seeded from the first user message (see message_service); stays frozen unless explicitly overwritten by a future summariser job.
Widget_deployment_id (migration 000072) — denormalized deployment link for deployment-scoped feeds. Required here or FindActiveSession’s SELECT * fails “missing destination name widget_deployment_id” → widget boot 500s.
Examplegenerated
{ "data": { "app_id": "example", "bot_profile_id": "example", "branched_at_message_id": "example", "channel_switch_count": 1, "context_id": "example", "context_summary": "example", "conversation_id": "example", "created_at": "example", "customer_id": "example", "dispatch_channel": "example", "dispatch_identity_id": "example", "first_response_at": "example", "id": "example", "is_mev_ai": true, "last_message": "example", "last_message_at": "example", "last_message_sender": "example", "last_switch_at": "example", "message_count": 1, "meta": [ 1 ], "origin_channel": "example", "origin_identity_id": "example", "parent_session_id": "example", "priority": "example", "reference_code": "example", "resolved_at": "example", "routing_reason": "example", "segment_seq": 1, "sla_due_at": "example", "status": "example", "tags": [ "example" ], "team_id": "example", "topic": "example", "transferred_to_session_id": "example", "type": "example", "updated_at": "example", "user_id": "example", "widget_deployment_id": "example", "ws_connected": true, "ws_session_id": "example" }, "error": { "code": "example", "message": "example" }, "meta": { "next_cursor": "example", "page": 1, "per_page": 1, "total": 1 }, "success": true}Created
object
object
object
object
Customer_id (migration 000067) — the CRM contact this session resolves to once identity is captured. Required here so SELECT * scans cleanly.
Branch fork columns added by migration 000036. parent_session_id is the source session a branch was forked from; branched_at_message_id is the cut-off ULID — every source row with id <= this lives in the new session as a copy. Both nullable; populated only on sessions created via POST /ouchat/sessions/branch.
Routing audit columns added by migration 000039 (mw#259, RFC 2204 §5). RoutingReason records why this session landed on this app: explicit — caller specified the app and it was active no_app — caller provided no app; routed to OU AI app_not_found — caller specified an unknown app; routed to OU AI app_suspended — caller’s app is suspended; routed to OU AI app_deleted — caller’s app is deleted; routed to OU AI Set at insert time, never updated. Existing sessions stay on their original app even if its status flips later.
Topic is a short subject line shown in the recent-chats list. Seeded from the first user message (see message_service); stays frozen unless explicitly overwritten by a future summariser job.
Widget_deployment_id (migration 000072) — denormalized deployment link for deployment-scoped feeds. Required here or FindActiveSession’s SELECT * fails “missing destination name widget_deployment_id” → widget boot 500s.
Examplegenerated
{ "data": { "app_id": "example", "bot_profile_id": "example", "branched_at_message_id": "example", "channel_switch_count": 1, "context_id": "example", "context_summary": "example", "conversation_id": "example", "created_at": "example", "customer_id": "example", "dispatch_channel": "example", "dispatch_identity_id": "example", "first_response_at": "example", "id": "example", "is_mev_ai": true, "last_message": "example", "last_message_at": "example", "last_message_sender": "example", "last_switch_at": "example", "message_count": 1, "meta": [ 1 ], "origin_channel": "example", "origin_identity_id": "example", "parent_session_id": "example", "priority": "example", "reference_code": "example", "resolved_at": "example", "routing_reason": "example", "segment_seq": 1, "sla_due_at": "example", "status": "example", "tags": [ "example" ], "team_id": "example", "topic": "example", "transferred_to_session_id": "example", "type": "example", "updated_at": "example", "user_id": "example", "widget_deployment_id": "example", "ws_connected": true, "ws_session_id": "example" }, "error": { "code": "example", "message": "example" }, "meta": { "next_cursor": "example", "page": 1, "per_page": 1, "total": 1 }, "success": true}Bad Request
object
object
object
object
Examplegenerated
{ "data": "example", "error": { "code": "example", "message": "example" }, "meta": { "next_cursor": "example", "page": 1, "per_page": 1, "total": 1 }, "success": true}Unauthorized
object
object
object
object
Examplegenerated
{ "data": "example", "error": { "code": "example", "message": "example" }, "meta": { "next_cursor": "example", "page": 1, "per_page": 1, "total": 1 }, "success": true}