{"openapi":"3.1.0","info":{"title":"ZVoice API","version":"1.0.0","description":"Call management API. Every request runs inside the organization of the API key (tenant isolation enforced by PostgreSQL row-level security). Operations are labelled IMPLEMENTED, DEMO or PLANNED (x-zvoice-status); PLANNED operations are proposals and are not routed."},"servers":[{"url":"https://voice.zpaylink.com"}],"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","bearerFormat":"zvk_<env>_<random>","description":"Create keys in Developers -> API Keys (shown once). Scopes: call_requests:read, call_requests:write, comments:write, customers:assign, agents:read, recordings:read, qc:read, commissions:read."}},"schemas":{"CreateCallRequest":{"type":"object","required":["source_department","reason_key","priority"],"properties":{"customer_id":{"type":"string","format":"uuid","description":"Existing customer (or send customer)."},"customer":{"type":"object","properties":{"name":{"type":"string"},"customer_ref":{"type":"string"},"phone":{"type":"string"},"type":{"enum":["prop","broker"]},"source_system":{"enum":["lastprop","fxbo","manual"]}}},"source_department":{"type":"string","description":"Requesting team key."},"reason_key":{"type":"string","description":"Call reason key."},"priority":{"enum":["critical","high","medium","low"]},"tags":{"type":"array","items":{"type":"string"},"maxItems":10},"product":{"type":"string"},"crm_record_ref":{"type":"string"},"summary":{"type":"string","maxLength":2000},"due_at":{"type":"string","format":"date-time"},"agent_id":{"type":"string","format":"uuid"},"idempotency_key":{"type":"string","minLength":8,"maxLength":100}}},"PatchCallRequest":{"type":"object","properties":{"status":{"type":"string"},"priority":{"enum":["critical","high","medium","low"]},"due_at":{"type":"string","format":"date-time"},"tags":{"type":"array","items":{"type":"string"}},"summary":{"type":"string"},"note":{"type":"string","description":"Required when cancelling."}}},"Error":{"type":"object","properties":{"statusCode":{"type":"integer"},"error":{"type":"string"},"message":{"type":"string"}}}}},"x-zvoice-webhook-events":{"customer.registered":{"direction":"incoming","description":"A customer registered in a CRM. Processed by the assignment engine (demo organizations only in this phase).","example":{"source":"lastprop","customer":{"ref":"LP-100231","name":"Jane Doe","type":"prop","product":"Two-Step Pro challenge"}}},"broker.account.created":{"direction":"incoming","description":"A broker account was opened. Registers the customer (if new) and creates a follow-up call request.","example":{"customer":{"ref":"FX-55012","name":"John Doe"},"account_type":"Standard"}},"broker.deposit.completed":{"direction":"incoming","description":"A broker deposit was completed and verified. Creates a conversion and runs attribution.","example":{"customer_ref":"FX-55012","transaction_id":"FXD-889911","amount":1000,"currency":"USD","occurred_at":"2026-10-13T08:00:00Z"}},"prop.challenge.purchased":{"direction":"incoming","description":"A Prop challenge was purchased and verified. Creates a conversion and runs attribution.","example":{"customer_ref":"LP-100231","transaction_id":"LPO-55001","amount":200,"currency":"USD","product":"Two-Step Pro"}},"prop.challenge.drawdown":{"direction":"incoming","description":"A challenge failed on drawdown. Creates a drawdown call request for the customer's Account Manager.","example":{"customer_ref":"LP-100231","challenge":"Two-Step Pro 25K","rule":"daily_drawdown"}},"prop.wallet.withdrawal_requested":{"direction":"incoming","description":"A withdrawal was requested from the Prop wallet without a purchase. Creates a retention call request.","example":{"customer_ref":"LP-100231","amount":150,"currency":"USD"}},"call.request.created":{"direction":"incoming","description":"Another system asks Account Management to call a customer.","example":{"customer_ref":"LP-100231","reason":"deposit_assistance","priority":"high","note":"Card declined twice"}},"call.recording.available":{"direction":"incoming","description":"A telephony recording is available. PLANNED: recordings are imported by the Navatel connector once it exists (acknowledged, not processed).","example":{"provider_call_id":"NV-1234","url":"https://pbx.example/recordings/NV-1234"}},"customer.assigned":{"direction":"outgoing","description":"A customer received (or changed) its primary Account Manager.","example":{"customer_id":"uuid","agent_id":"uuid","strategy":"balanced_random"}},"call.request.assigned":{"direction":"outgoing","description":"A call request was assigned (owner, temporary handler or manual).","example":{"request_id":"CR-000123","agent_id":"uuid","assignment_kind":"owner"}},"call.request.completed":{"direction":"outgoing","description":"A call request was completed.","example":{"request_id":"CR-000123","outcome":"interested"}},"call.comment.created":{"direction":"outgoing","description":"A comment was added to a call request (internal notes flagged).","example":{"request_id":"CR-000123","comment_id":"uuid","internal":false,"idempotency_key":"zv-…"}},"call.qc.completed":{"direction":"outgoing","description":"A Call QC result was recorded or reviewed (kind demo / imported).","example":{"qc_id":"uuid","recording":"REC-0004","kind":"demo","overall":7.1}},"conversion.attributed":{"direction":"outgoing","description":"A conversion was attributed to a call.","example":{"conversion":"CNV-0003","agent_id":"uuid","request_id":"CR-000123"}},"commission.created":{"direction":"outgoing","description":"A commission was calculated (status pending verification or eligible).","example":{"commission":"COM-0007","status":"eligible","amount":4,"currency":"USD","demo_rate":true}}},"paths":{"/api/v1/organization":{"get":{"summary":"Organization and permissions of the calling key","description":"","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":null,"security":[{"apiKey":[]}],"parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"id":"…","name":"Acme Brokers","slug":"acme","kind":"customer","permissions":["requests.read"]}}}}}}}},"/api/v1/call-requests":{"get":{"summary":"List call requests","description":"Filters: status (open | closed | key), priority, reason, tag, source_crm, team, agent, squad, conversion, from, to (YYYY-MM-DD), overdue, q. Scope: call_requests:read.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"call_requests:read","security":[{"apiKey":[]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1},"description":"Page number (default 1)."},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Page size (default 25, max 100)."},{"name":"status","in":"query","schema":{"type":"string"}},{"name":"priority","in":"query","schema":{"type":"string","enum":["critical","high","medium","low"]}},{"name":"tag","in":"query","schema":{"type":"string"}},{"name":"from","in":"query","schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":[{"id":123,"ref":"CR-000123","customer":{"id":"3f6c…","name":"Jane Doe","customer_ref":"LP-100231","phone":"+971 50 000 0000","type":"prop","source":"lastprop"},"owner":{"id":"9a1e…","name":"Agent Name"},"source_crm":"api","product":"Two-Step Pro challenge","source_department":"retention","reason_key":"drawdown","reason_label":"Prop drawdown: failed challenge","tags":[{"key":"drawdown","label":"Drawdown","color":"red"}],"priority":"high","status":"assigned","agent":{"id":"9a1e…","name":"Agent Name"},"assignment_kind":"owner","squad":{"id":"…","name":"Squad A"},"created_at":"2026-10-13T08:00:00.000Z","due_at":"2026-10-13T16:00:00.000Z","last_contact_at":null,"call_attempts":0,"crm_record_ref":"LP-EVT-50211","conversion_status":"none","overdue":false}],"pagination":{"page":1,"size":25,"total":1}}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}},"429":{"description":"rate_limited","content":{"application/json":{"example":{"statusCode":429,"error":"rate_limited","message":"Rate limit exceeded: 120 requests per minute per API key."}}}}}},"post":{"summary":"Create a call request","description":"Routed to the customer's primary Account Manager (temporary handler when unavailable). Idempotent: send idempotency_key; a replay returns the original request with idempotent_replay = true. Scope: call_requests:write.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"call_requests:write","security":[{"apiKey":[]}],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCallRequest"},"example":{"customer_id":"3f6c…","source_department":"retention","reason_key":"drawdown","priority":"high","tags":["drawdown"],"product":"Two-Step Pro challenge","crm_record_ref":"LP-EVT-50211","summary":"Failed on daily drawdown","idempotency_key":"crm-evt-50211"}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"example":{"data":{"id":123,"ref":"CR-000123","customer":{"id":"3f6c…","name":"Jane Doe","customer_ref":"LP-100231","phone":"+971 50 000 0000","type":"prop","source":"lastprop"},"owner":{"id":"9a1e…","name":"Agent Name"},"source_crm":"api","product":"Two-Step Pro challenge","source_department":"retention","reason_key":"drawdown","reason_label":"Prop drawdown: failed challenge","tags":[{"key":"drawdown","label":"Drawdown","color":"red"}],"priority":"high","status":"assigned","agent":{"id":"9a1e…","name":"Agent Name"},"assignment_kind":"owner","squad":{"id":"…","name":"Squad A"},"created_at":"2026-10-13T08:00:00.000Z","due_at":"2026-10-13T16:00:00.000Z","last_contact_at":null,"call_attempts":0,"crm_record_ref":"LP-EVT-50211","conversion_status":"none","overdue":false,"idempotent_replay":false}}}}},"400":{"description":"Bad Request","content":{"application/json":{"example":{"statusCode":400,"error":"Bad Request","message":"priority: Invalid enum value."}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}},"404":{"description":"not_found","content":{"application/json":{"example":{"statusCode":404,"error":"not_found","message":"Call request not found."}}}},"429":{"description":"rate_limited","content":{"application/json":{"example":{"statusCode":429,"error":"rate_limited","message":"Rate limit exceeded: 120 requests per minute per API key."}}}}}}},"/api/v1/call-requests/{id}":{"get":{"summary":"Get a call request with calls and callbacks","description":"Scope: call_requests:read.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"call_requests:read","security":[{"apiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Numeric id or reference (CR-000123)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"id":123,"ref":"CR-000123","customer":{"id":"3f6c…","name":"Jane Doe","customer_ref":"LP-100231","phone":"+971 50 000 0000","type":"prop","source":"lastprop"},"owner":{"id":"9a1e…","name":"Agent Name"},"source_crm":"api","product":"Two-Step Pro challenge","source_department":"retention","reason_key":"drawdown","reason_label":"Prop drawdown: failed challenge","tags":[{"key":"drawdown","label":"Drawdown","color":"red"}],"priority":"high","status":"assigned","agent":{"id":"9a1e…","name":"Agent Name"},"assignment_kind":"owner","squad":{"id":"…","name":"Squad A"},"created_at":"2026-10-13T08:00:00.000Z","due_at":"2026-10-13T16:00:00.000Z","last_contact_at":null,"call_attempts":0,"crm_record_ref":"LP-EVT-50211","conversion_status":"none","overdue":false,"calls":[],"callbacks":[]}}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}},"404":{"description":"not_found","content":{"application/json":{"example":{"statusCode":404,"error":"not_found","message":"Call request not found."}}}}}},"patch":{"summary":"Update status, priority, due date, tags or notes","description":"Scope: call_requests:write.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"call_requests:write","security":[{"apiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Numeric id or reference (CR-000123)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchCallRequest"},"example":{"status":"cancelled","note":"Resolved by Support"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"id":123,"ref":"CR-000123","customer":{"id":"3f6c…","name":"Jane Doe","customer_ref":"LP-100231","phone":"+971 50 000 0000","type":"prop","source":"lastprop"},"owner":{"id":"9a1e…","name":"Agent Name"},"source_crm":"api","product":"Two-Step Pro challenge","source_department":"retention","reason_key":"drawdown","reason_label":"Prop drawdown: failed challenge","tags":[{"key":"drawdown","label":"Drawdown","color":"red"}],"priority":"high","status":"cancelled","agent":{"id":"9a1e…","name":"Agent Name"},"assignment_kind":"owner","squad":{"id":"…","name":"Squad A"},"created_at":"2026-10-13T08:00:00.000Z","due_at":"2026-10-13T16:00:00.000Z","last_contact_at":null,"call_attempts":0,"crm_record_ref":"LP-EVT-50211","conversion_status":"none","overdue":false}}}}},"400":{"description":"Bad Request","content":{"application/json":{"example":{"statusCode":400,"error":"Bad Request","message":"priority: Invalid enum value."}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}},"404":{"description":"not_found","content":{"application/json":{"example":{"statusCode":404,"error":"not_found","message":"Call request not found."}}}}}}},"/api/v1/call-requests/{id}/comments":{"post":{"summary":"Add a comment","description":"Synchronized to the source CRM through the organization's connector (demo adapter in demo organizations; live connectors PLANNED). One CRM note per idempotency key. Scope: comments:write.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"comments:write","security":[{"apiKey":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Numeric id or reference (CR-000123)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"},"example":{"body":"Customer will buy on Thursday.","internal":false,"idempotency_key":"crm-note-0001"}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"example":{"data":{"id":"uuid","idempotent_replay":false,"crm_sync_status":"synced","crm_error":null}}}}},"400":{"description":"Bad Request","content":{"application/json":{"example":{"statusCode":400,"error":"Bad Request","message":"priority: Invalid enum value."}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}},"404":{"description":"not_found","content":{"application/json":{"example":{"statusCode":404,"error":"not_found","message":"Call request not found."}}}}}}},"/api/v1/customers/assign":{"post":{"summary":"Registration event: assign a primary Account Manager","description":"Demo organizations only (live registration needs separate approval). Idempotent on (source, event_id). Scope: customers:assign.","x-zvoice-status":"DEMO","x-zvoice-scope":"customers:assign","security":[{"apiKey":[]}],"parameters":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"},"example":{"source":"lastprop","event_id":"reg-100231","customer":{"ref":"LP-100231","name":"Jane Doe","type":"prop","product":"FastProp"}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":{"duplicate":false,"status":"assigned","customer_id":"uuid","agent_id":"uuid","request_ref":"CR-000124"}}}}},"400":{"description":"Bad Request","content":{"application/json":{"example":{"statusCode":400,"error":"Bad Request","message":"priority: Invalid enum value."}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}}}}},"/api/v1/agents":{"get":{"summary":"List agents","description":"Scope: agents:read.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"agents:read","security":[{"apiKey":[]}],"parameters":[],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":[{"id":"uuid","full_name":"Agent Name","role":"account_manager","squad":"Squad A","status":"active","available":true,"assigned_customers":12,"crm_agent_id":null}]}}}}}}},"/api/v1/call-recordings":{"get":{"summary":"List recording metadata (never the audio)","description":"Scope: recordings:read.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"recordings:read","security":[{"apiKey":[]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1},"description":"Page number (default 1)."},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Page size (default 25, max 100)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":[{"id":"uuid","ref":"REC-0001","duration_s":143.4,"source":"navatel_export","is_real":true,"qc_status":"not_analyzed","qc_label":"NOT ANALYZED"}]}}}}}}},"/api/v1/call-qc":{"get":{"summary":"List Call QC results","description":"label is DEMO RESULT, IMPORTED ANALYSIS or NOT ANALYZED (no result). Scope: qc:read.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"qc:read","security":[{"apiKey":[]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1},"description":"Page number (default 1)."},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Page size (default 25, max 100)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":[{"id":"uuid","recording":"REC-0004","label":"DEMO RESULT","kind":"demo","title":"Drawdown","scores":{"technical":5,"tone":9,"satisfaction":8},"overall":7.1}]}}}}}}},"/api/v1/commissions":{"get":{"summary":"List commissions","description":"rate_is_demo is true while demo rates are in place. Paid is a demo-only status. Scope: commissions:read.","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":"commissions:read","security":[{"apiKey":[]}],"parameters":[{"name":"page","in":"query","schema":{"type":"integer","minimum":1},"description":"Page number (default 1)."},{"name":"size","in":"query","schema":{"type":"integer","minimum":1,"maximum":100},"description":"Page size (default 25, max 100)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"data":[{"ref":"COM-0007","status":"eligible","amount":4,"currency":"USD","rate_pct":2,"rate_is_demo":true}]}}}}}}},"/api/v1/webhooks/inbound/{organization}":{"post":{"summary":"Receive an incoming event (HMAC signed)","description":"Header ZVoice-Signature: t=<unix>,v1=<hex HMAC-SHA256(secret, \"<t>.<raw body>\")>. Timestamp tolerance 300 s; event ids are unique (replay protection). Processing only in demo organizations; other organizations acknowledge with status ignored.","x-zvoice-status":"DEMO","x-zvoice-scope":null,"security":[],"parameters":[{"name":"organization","in":"path","required":true,"schema":{"type":"string"},"description":"Organization slug."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object"},"example":{"id":"evt_7f3a","type":"prop.challenge.drawdown","data":{"customer_ref":"LP-100231","challenge":"Two-Step Pro 25K","rule":"daily_drawdown"}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"example":{"received":true,"duplicate":false,"status":"processed","result":{"request_id":125,"created":true}}}}},"400":{"description":"Bad Request","content":{"application/json":{"example":{"statusCode":400,"error":"Bad Request","message":"priority: Invalid enum value."}}}},"401":{"description":"unauthorized","content":{"application/json":{"example":{"statusCode":401,"error":"unauthorized","message":"Unknown or revoked API key."}}}},"403":{"description":"insufficient_scope","content":{"application/json":{"example":{"statusCode":403,"error":"insufficient_scope","message":"This API key does not have the scope required for this endpoint."}}}},"404":{"description":"not_found","content":{"application/json":{"example":{"statusCode":404,"error":"not_found","message":"Call request not found."}}}},"429":{"description":"rate_limited","content":{"application/json":{"example":{"statusCode":429,"error":"rate_limited","message":"Rate limit exceeded: 120 requests per minute per API key."}}}}}}},"/api/v1/openapi.json":{"get":{"summary":"This OpenAPI document","description":"","x-zvoice-status":"IMPLEMENTED","x-zvoice-scope":null,"security":[],"parameters":[],"responses":{"200":{"description":"OK"}}}},"/api/v1/customers/{id}":{"get":{"summary":"Customer with ownership history","description":"Scope: customers:read.","x-zvoice-status":"PLANNED","x-zvoice-scope":"customers:read","security":[{"apiKey":[]}],"parameters":[],"responses":{"200":{"description":"OK"}}}},"/api/v1/call-recordings/{id}/audio":{"get":{"summary":"Recording audio for an authorized integration","description":"Needs an approved data-sharing scope; the console streams audio only to signed-in users.","x-zvoice-status":"PLANNED","x-zvoice-scope":null,"security":[{"apiKey":[]}],"parameters":[],"responses":{"200":{"description":"OK"}}}},"/api/v1/qc-results":{"post":{"summary":"Import a precomputed QC analysis","description":"Available in the console (Call QC import) today; API access planned.","x-zvoice-status":"PLANNED","x-zvoice-scope":null,"security":[{"apiKey":[]}],"parameters":[],"responses":{"201":{"description":"OK"}}}},"/api/v1/conversions":{"post":{"summary":"Report a verified conversion from a CRM","description":"Today: incoming webhook events broker.deposit.completed / prop.challenge.purchased (DEMO).","x-zvoice-status":"PLANNED","x-zvoice-scope":null,"security":[{"apiKey":[]}],"parameters":[],"responses":{"201":{"description":"OK"}}}},"/api/v1/telephony/click-to-call":{"post":{"summary":"Navatel click-to-call","description":"Needs Navatel API documentation and credentials.","x-zvoice-status":"PLANNED","x-zvoice-scope":null,"security":[{"apiKey":[]}],"parameters":[],"responses":{"201":{"description":"OK"}}}}}}