{"openapi":"3.1.0","info":{"title":"AIVI API","version":"1.0.0","description":"Server-to-server REST API. Base URL: https://<your AIVI domain>/ignite/api/v1 (e.g. app.aivi.io, uk.aivi.io)."},"servers":[{"url":"/ignite/api/v1"}],"tags":[{"name":"Organizations"},{"name":"Phone Numbers"},{"name":"AI Agents"},{"name":"Experts"},{"name":"Contacts"},{"name":"Insights"},{"name":"Calls"},{"name":"Call Intelligence"},{"name":"Recordings"},{"name":"Messages"},{"name":"Emails"},{"name":"Workflows"},{"name":"Enrollments"},{"name":"Rubrics"},{"name":"Scorecards"},{"name":"Chat Widgets"},{"name":"Landing Pages"},{"name":"Auth"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"An API key (`aivi_sk_…`) or an OAuth access token. OAuth callers select the organization with the `X-Aivi-Organization` header."}},"schemas":{"Error":{"type":"object","properties":{"success":{"type":"boolean","enum":[false]},"error":{"type":"string"},"code":{"type":"string"},"timestamp":{"type":"string"}},"required":["success","error","code","timestamp"]}},"parameters":{}},"paths":{"/auth/token":{"post":{"tags":["Auth"],"summary":"Exchange an authorization code or refresh token for an access token","description":"No authentication required.","x-aivi-scope":null,"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/organizations":{"get":{"tags":["Organizations"],"summary":"List organizations the caller can act on","description":"Requires authentication; no scope required.","security":[{"bearerAuth":[]}],"x-aivi-scope":null,"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"]},"description":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"business_industry":{"type":["string","null"]},"business_website":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"role":{"type":"string","enum":["owner","admin","member","agent","api_key","superuser"]},"is_hub":{"type":"boolean"},"is_active":{"type":"boolean"}},"required":["id","name","slug","logo","description","settings","business_industry","business_website","created_at","updated_at","role"]}}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Organizations"],"summary":"Create a sub-organization (agency keys)","description":"Required scope: `organizations:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"organizations:write","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":255,"description":"Makes the request safely retryable: the first response for a key is stored for 24h and replayed (with `Idempotent-Replayed: true`) for a retry with the same request. Only 2xx and 400/404/422 responses are stored."},"required":true,"name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"slug":{"type":"string","maxLength":63},"description":{"type":"string","maxLength":2000},"settings":{"type":"object","properties":{"timezone":{"type":"string","minLength":1,"maxLength":64},"language":{"type":"string","pattern":"^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"},"currency":{"type":"string","pattern":"^[A-Z]{3}$"},"dateFormat":{"type":"string","minLength":1,"maxLength":32}},"additionalProperties":false},"clone_from":{"type":"string","format":"uuid"},"billing":{"type":"object","properties":{"funds":{"type":"string","enum":["agency","own"]},"subscription_price_cents":{"type":"integer","minimum":0,"maximum":2147483647}},"additionalProperties":false}},"required":["name"],"additionalProperties":false}}}},"responses":{"202":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"]},"description":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"business_industry":{"type":["string","null"]},"business_website":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"is_hub":{"type":"boolean"},"is_active":{"type":"boolean"},"billing":{"type":"object","properties":{"funds":{"type":"string","enum":["agency","own"]},"subscription_price_cents":{"type":["integer","null"]}},"required":["funds","subscription_price_cents"]},"provisioning":{"type":"object","properties":{"status":{"type":"string","enum":["pending","ready","failed"]},"billing":{"type":"string","enum":["pending","ready","failed"]},"telephony":{"type":"string","enum":["pending","ready","failed"]},"voice":{"type":"string","enum":["pending","ready","failed"]},"email":{"type":"string","enum":["pending","ready","failed","skipped"]}},"required":["status","billing","telephony","voice","email"]}},"required":["id","name","slug","logo","description","settings","business_industry","business_website","created_at","updated_at","is_hub","is_active","billing","provisioning"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope: not an agency key (or, for OAuth, not an admin of an agency hub); hub_not_agency: the key's organization is no longer an active agency hub; organization_not_accessible: clone_from is not an active organization of this agency; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"organization_limit_reached; slug_taken; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"idempotency_key_reused; price_below_floor; or: Idempotency-Key reused with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/organizations/me":{"get":{"tags":["Organizations"],"summary":"Get the current organization","description":"Required scope: `organizations:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"organizations:read","responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"]},"description":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"business_industry":{"type":["string","null"]},"business_website":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","name","slug","logo","description","settings","business_industry","business_website","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/organizations/{id}":{"get":{"tags":["Organizations"],"summary":"Get an organization with its billing and provisioning state","description":"Required scope: `organizations:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"organizations:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"]},"description":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"business_industry":{"type":["string","null"]},"business_website":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"is_hub":{"type":"boolean"},"is_active":{"type":"boolean"},"billing":{"type":"object","properties":{"funds":{"type":"string","enum":["agency","own"]},"subscription_price_cents":{"type":["integer","null"]}},"required":["funds","subscription_price_cents"]},"provisioning":{"type":"object","properties":{"status":{"type":"string","enum":["pending","ready","failed"]},"billing":{"type":"string","enum":["pending","ready","failed"]},"telephony":{"type":"string","enum":["pending","ready","failed"]},"voice":{"type":"string","enum":["pending","ready","failed"]},"email":{"type":"string","enum":["pending","ready","failed","skipped"]}},"required":["status","billing","telephony","voice","email"]}},"required":["id","name","slug","logo","description","settings","business_industry","business_website","created_at","updated_at","is_hub","is_active","billing","provisioning"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Organizations"],"summary":"Update a sub-organization (agency keys)","description":"Required scope: `organizations:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"organizations:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":120},"description":{"type":"string","maxLength":2000},"settings":{"type":"object","properties":{"timezone":{"type":"string","minLength":1,"maxLength":64},"language":{"type":"string","pattern":"^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$"},"currency":{"type":"string","pattern":"^[A-Z]{3}$"},"dateFormat":{"type":"string","minLength":1,"maxLength":32}},"additionalProperties":false},"billing":{"type":"object","properties":{"funds":{"type":"string","enum":["agency","own"]},"subscription_price_cents":{"type":["integer","null"],"minimum":0,"maximum":2147483647}},"additionalProperties":false}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"slug":{"type":"string"},"logo":{"type":["string","null"]},"description":{"type":["string","null"]},"settings":{"type":"object","additionalProperties":{}},"business_industry":{"type":["string","null"]},"business_website":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"is_hub":{"type":"boolean"},"is_active":{"type":"boolean"},"billing":{"type":"object","properties":{"funds":{"type":"string","enum":["agency","own"]},"subscription_price_cents":{"type":["integer","null"]}},"required":["funds","subscription_price_cents"]},"provisioning":{"type":"object","properties":{"status":{"type":"string","enum":["pending","ready","failed"]},"billing":{"type":"string","enum":["pending","ready","failed"]},"telephony":{"type":"string","enum":["pending","ready","failed"]},"voice":{"type":"string","enum":["pending","ready","failed"]},"email":{"type":"string","enum":["pending","ready","failed","skipped"]}},"required":["status","billing","telephony","voice","email"]}},"required":["id","name","slug","logo","description","settings","business_industry","business_website","created_at","updated_at","is_hub","is_active","billing","provisioning"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"insufficient_scope: not an agency key (or, for OAuth, not an admin of an agency hub); hub_not_agency: the key's organization is no longer an active agency hub; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"hub_billing_not_allowed: billing can only be set on sub-organizations; price_below_floor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone_numbers":{"get":{"tags":["Phone Numbers"],"summary":"List phone numbers","description":"Required scope: `phone_numbers:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"phone_numbers:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"is_active","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"ai_enabled","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|phone_number)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"phone_number":{"type":"string"},"friendly_name":{"type":["string","null"]},"capabilities":{"type":["object","null"],"properties":{"voice":{"type":"boolean"},"sms":{"type":"boolean"},"mms":{"type":"boolean"},"fax":{"type":"boolean"}}},"is_default":{"type":"boolean"},"is_active":{"type":"boolean"},"ai_enabled":{"type":"boolean"},"inbound_agent_id":{"type":["string","null"],"format":"uuid"},"outbound_agent_id":{"type":["string","null"],"format":"uuid"},"forward_to":{"type":["string","null"]},"assigned_to":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","phone_number","friendly_name","capabilities","is_default","is_active","ai_enabled","inbound_agent_id","outbound_agent_id","forward_to","assigned_to","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Phone Numbers"],"summary":"Buy a phone number","description":"Required scope: `phone_numbers:purchase`","security":[{"bearerAuth":[]}],"x-aivi-scope":"phone_numbers:purchase","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":255,"description":"Makes the request safely retryable: the first response for a key is stored for 24h and replayed (with `Idempotent-Replayed: true`) for a retry with the same request. Only 2xx and 400/404/422 responses are stored."},"required":true,"name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"phone_number":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"friendly_name":{"type":"string","maxLength":64},"inbound_agent_id":{"type":"string","format":"uuid"},"outbound_agent_id":{"type":"string","format":"uuid"}},"required":["phone_number"],"additionalProperties":false}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"phone_number":{"type":"string"},"friendly_name":{"type":["string","null"]},"capabilities":{"type":["object","null"],"properties":{"voice":{"type":"boolean"},"sms":{"type":"boolean"},"mms":{"type":"boolean"},"fax":{"type":"boolean"}}},"is_default":{"type":"boolean"},"is_active":{"type":"boolean"},"ai_enabled":{"type":"boolean"},"inbound_agent_id":{"type":["string","null"],"format":"uuid"},"outbound_agent_id":{"type":["string","null"],"format":"uuid"},"forward_to":{"type":["string","null"]},"assigned_to":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","phone_number","friendly_name","capabilities","is_default","is_active","ai_enabled","inbound_agent_id","outbound_agent_id","forward_to","assigned_to","created_at","updated_at"]},"warnings":{"type":"array","items":{"type":"string"}}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Insufficient funds","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Trial organizations cannot buy numbers via the API; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Number unavailable or organization not ready; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Regulatory bundle required; or: Idempotency-Key reused with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Storage failed (storage_failed) — the number was released; or server error (server_error) — nothing was bought","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Carrier error (twilio_error) or purchase incomplete (purchase_incomplete) — see code","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone_numbers/available":{"get":{"tags":["Phone Numbers"],"summary":"Search phone numbers available to buy","description":"Required scope: `phone_numbers:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"phone_numbers:read","parameters":[{"schema":{"type":"string","minLength":2,"maxLength":2,"default":"US"},"required":false,"name":"country","in":"query"},{"schema":{"type":"string","enum":["local","toll_free","mobile"],"default":"local"},"required":false,"name":"type","in":"query"},{"schema":{"type":"string","pattern":"^\\d{3}$"},"required":false,"name":"area_code","in":"query"},{"schema":{"type":"string","pattern":"^[0-9*]{1,10}$"},"required":false,"name":"contains","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":50,"default":20},"required":false,"name":"limit","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"phone_number":{"type":"string"},"friendly_name":{"type":"string"},"locality":{"type":["string","null"]},"region":{"type":["string","null"]},"postal_code":{"type":["string","null"]},"iso_country":{"type":"string"},"capabilities":{"type":"object","properties":{"voice":{"type":"boolean"},"sms":{"type":"boolean"},"mms":{"type":"boolean"},"fax":{"type":"boolean"}},"required":["voice","sms","mms","fax"]},"requires_bundle":{"type":"boolean"},"monthly_price_cents":{"type":"integer"},"setup_price_cents":{"type":"integer"}},"required":["phone_number","friendly_name","locality","region","postal_code","iso_country","capabilities","requires_bundle","monthly_price_cents","setup_price_cents"]}}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Server error (server_error) — pricing or the phone configuration could not be read; retry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/phone_numbers/{id}":{"get":{"tags":["Phone Numbers"],"summary":"Get a phone number","description":"Required scope: `phone_numbers:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"phone_numbers:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"phone_number":{"type":"string"},"friendly_name":{"type":["string","null"]},"capabilities":{"type":["object","null"],"properties":{"voice":{"type":"boolean"},"sms":{"type":"boolean"},"mms":{"type":"boolean"},"fax":{"type":"boolean"}}},"is_default":{"type":"boolean"},"is_active":{"type":"boolean"},"ai_enabled":{"type":"boolean"},"inbound_agent_id":{"type":["string","null"],"format":"uuid"},"outbound_agent_id":{"type":["string","null"],"format":"uuid"},"forward_to":{"type":["string","null"]},"assigned_to":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","phone_number","friendly_name","capabilities","is_default","is_active","ai_enabled","inbound_agent_id","outbound_agent_id","forward_to","assigned_to","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Phone Numbers"],"summary":"Update a phone number","description":"Required scope: `phone_numbers:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"phone_numbers:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"friendly_name":{"type":"string","maxLength":64},"inbound_agent_id":{"type":["string","null"],"format":"uuid"},"outbound_agent_id":{"type":["string","null"],"format":"uuid"},"forward_to":{"type":["string","null"],"pattern":"^\\+[1-9]\\d{1,14}$"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"phone_number":{"type":"string"},"friendly_name":{"type":["string","null"]},"capabilities":{"type":["object","null"],"properties":{"voice":{"type":"boolean"},"sms":{"type":"boolean"},"mms":{"type":"boolean"},"fax":{"type":"boolean"}}},"is_default":{"type":"boolean"},"is_active":{"type":"boolean"},"ai_enabled":{"type":"boolean"},"inbound_agent_id":{"type":["string","null"],"format":"uuid"},"outbound_agent_id":{"type":["string","null"],"format":"uuid"},"forward_to":{"type":["string","null"]},"assigned_to":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","phone_number","friendly_name","capabilities","is_default","is_active","ai_enabled","inbound_agent_id","outbound_agent_id","forward_to","assigned_to","created_at","updated_at"]},"warnings":{"type":"array","items":{"type":"string"}}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Phone number not found or released (not_found); or: Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"phone_number_provider_conflict: the inbound and outbound agents use different call providers","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Server error (server_error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Carrier error (twilio_error)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Phone Numbers"],"summary":"Release a phone number","description":"Required scope: `phone_numbers:purchase`","security":[{"bearerAuth":[]}],"x-aivi-scope":"phone_numbers:purchase","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"action":{"type":"string","enum":["released","disconnected"]}},"required":["id","action"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Phone number not found or already released (not_found); or: Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Organization telephony not set up (organization_not_ready)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Server error (server_error) — the message says whether the number was already released","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"Carrier error (twilio_error) — nothing was changed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai_agents":{"get":{"tags":["AI Agents"],"summary":"List AI agents","description":"Required scope: `ai_agents:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"ai_agents:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","enum":["draft","active","inactive","archived"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["inbound","outbound","both"]},"required":false,"name":"call_direction","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":false,"name":"search","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"is_template","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|updated_at|name)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["draft","active","inactive","archived"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"]},"language":{"type":"string"},"llm_provider":{"type":"string","enum":["gemini","openai","mercury","anthropic"]},"model_name":{"type":["string","null"]},"system_prompt":{"type":"string"},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"custom_instructions":{"type":["string","null"]},"phone_number_id":{"type":["string","null"],"format":"uuid"},"recording_enabled":{"type":"boolean"},"transcription_enabled":{"type":"boolean"},"is_template":{"type":"boolean"},"is_default":{"type":"boolean"},"transfer_number":{"type":["string","null"]},"sms_enabled":{"type":"boolean"},"consent_script":{"type":["string","null"]},"transfer_rotation":{"type":["string","null"],"enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"transfer_global_rules":{"type":"array","items":{"type":"object","additionalProperties":{}}},"transfer_type":{"type":["string","null"],"enum":["cold","warm"]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":["boolean","null"]},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":["integer","null"]},"transfer_connect_timeout_seconds":{"type":["integer","null"]},"transfer_hold_music_timeout_seconds":{"type":["integer","null"]},"email_enabled":{"type":["boolean","null"]},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer"},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer"},"video_enabled":{"type":["boolean","null"]},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"]},"video_primary_color":{"type":["string","null"]},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":["string","null"]},"video_brand_name":{"type":["string","null"]},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"]},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"sync_status":{"type":["string","null"],"enum":["pending","synced","failed","skipped"]},"sync_stage":{"type":["string","null"]},"sync_error":{"type":["string","null"]},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","status","call_direction","voice_provider","voice_id","language","llm_provider","model_name","system_prompt","voice_system_prompt","sms_system_prompt","greeting_message","greeting_message_inbound","custom_instructions","phone_number_id","recording_enabled","transcription_enabled","is_template","is_default","transfer_number","sms_enabled","consent_script","transfer_rotation","transfer_targets","transfer_global_rules","transfer_type","transfer_caller_id_mode","transfer_whisper_message","transfer_notify_unanswered","transfer_announcement","transfer_failure_message","transfer_answer_timeout_seconds","transfer_connect_timeout_seconds","transfer_hold_music_timeout_seconds","email_enabled","email_sender_id","sms_human_takeover_enabled","sms_human_takeover_mode","sms_human_takeover_hours","email_human_takeover_enabled","email_human_takeover_mode","email_human_takeover_hours","video_enabled","live_avatar_id","live_avatar_preview_url","video_primary_color","video_position","video_cta_label","video_brand_name","video_launcher_style","video_subtitle","video_aspect_ratio","video_theme","video_offset_x","video_offset_y","video_greeting_message","sync_status","sync_stage","sync_error","phone_number_ids","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["AI Agents"],"summary":"Create an AI agent","description":"Required scope: `ai_agents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"ai_agents:write","parameters":[{"schema":{"type":"string","minLength":1,"maxLength":255,"description":"Makes the request safely retryable: the first response for a key is stored for 24h and replayed (with `Idempotent-Replayed: true`) for a retry with the same request. Only 2xx and 400/404/422 responses are stored."},"required":false,"name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":["string","null"],"maxLength":5000},"status":{"type":"string","enum":["draft","active","inactive"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"language":{"type":"string","enum":["multi","en-US","en-GB","en-AU","en-IN","es-ES","es-MX","fr-FR","de-DE","pt-BR","pt-PT","it-IT","nl-NL","pl-PL","ja-JP","ko-KR","zh-CN","hi-IN","ru-RU","sv-SE","da-DK"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"],"maxLength":100},"system_prompt":{"type":"string","minLength":1},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"consent_script":{"type":["string","null"]},"is_default":{"type":"boolean"},"transfer_rotation":{"type":"string","enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"},"phoneNumber":{"type":"string","maxLength":40},"sipUri":{"type":"string","maxLength":500},"sipTrunkId":{"type":"string","maxLength":255},"label":{"type":"string","maxLength":200},"percentage":{"type":"number","minimum":0,"maximum":100},"description":{"type":"string","maxLength":2000},"isCustom":{"type":"boolean"}},"additionalProperties":false},"maxItems":50},"transfer_global_rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","maxLength":100},"condition":{"type":"string","minLength":1,"maxLength":2000},"target":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"},"phoneNumber":{"type":"string","maxLength":40},"sipUri":{"type":"string","maxLength":500},"sipTrunkId":{"type":"string","maxLength":255},"label":{"type":"string","maxLength":200},"percentage":{"type":"number","minimum":0,"maximum":100},"description":{"type":"string","maxLength":2000},"isCustom":{"type":"boolean"}},"additionalProperties":false},"announcement":{"type":"string","maxLength":2000},"failureMessage":{"type":"string","maxLength":2000}},"required":["condition","target"],"additionalProperties":false},"maxItems":50},"transfer_type":{"type":"string","enum":["cold","warm"]},"transfer_caller_id_mode":{"type":"string","enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":"boolean"},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":"integer","minimum":15,"maximum":600},"transfer_connect_timeout_seconds":{"type":"integer","minimum":15,"maximum":600},"transfer_hold_music_timeout_seconds":{"anyOf":[{"type":"number","enum":[0]},{"type":"integer","minimum":15,"maximum":600}]},"sms_enabled":{"type":"boolean"},"email_enabled":{"type":"boolean"},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer","minimum":1,"maximum":720},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer","minimum":1,"maximum":720},"video_enabled":{"type":"boolean"},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"],"format":"uri"},"video_primary_color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":"string","maxLength":100},"video_brand_name":{"type":["string","null"],"maxLength":100},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"],"maxLength":140},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"agent_functions":{"type":"array","items":{"type":"object","additionalProperties":{}},"maxItems":100},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":50}},"required":["name","system_prompt"],"additionalProperties":false}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["draft","active","inactive","archived"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"]},"language":{"type":"string"},"llm_provider":{"type":"string","enum":["gemini","openai","mercury","anthropic"]},"model_name":{"type":["string","null"]},"system_prompt":{"type":"string"},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"custom_instructions":{"type":["string","null"]},"phone_number_id":{"type":["string","null"],"format":"uuid"},"recording_enabled":{"type":"boolean"},"transcription_enabled":{"type":"boolean"},"is_template":{"type":"boolean"},"is_default":{"type":"boolean"},"transfer_number":{"type":["string","null"]},"sms_enabled":{"type":"boolean"},"consent_script":{"type":["string","null"]},"transfer_rotation":{"type":["string","null"],"enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"transfer_global_rules":{"type":"array","items":{"type":"object","additionalProperties":{}}},"transfer_type":{"type":["string","null"],"enum":["cold","warm"]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":["boolean","null"]},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":["integer","null"]},"transfer_connect_timeout_seconds":{"type":["integer","null"]},"transfer_hold_music_timeout_seconds":{"type":["integer","null"]},"email_enabled":{"type":["boolean","null"]},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer"},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer"},"video_enabled":{"type":["boolean","null"]},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"]},"video_primary_color":{"type":["string","null"]},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":["string","null"]},"video_brand_name":{"type":["string","null"]},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"]},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"sync_status":{"type":["string","null"],"enum":["pending","synced","failed","skipped"]},"sync_stage":{"type":["string","null"]},"sync_error":{"type":["string","null"]},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","status","call_direction","voice_provider","voice_id","language","llm_provider","model_name","system_prompt","voice_system_prompt","sms_system_prompt","greeting_message","greeting_message_inbound","custom_instructions","phone_number_id","recording_enabled","transcription_enabled","is_template","is_default","transfer_number","sms_enabled","consent_script","transfer_rotation","transfer_targets","transfer_global_rules","transfer_type","transfer_caller_id_mode","transfer_whisper_message","transfer_notify_unanswered","transfer_announcement","transfer_failure_message","transfer_answer_timeout_seconds","transfer_connect_timeout_seconds","transfer_hold_music_timeout_seconds","email_enabled","email_sender_id","sms_human_takeover_enabled","sms_human_takeover_mode","sms_human_takeover_hours","email_human_takeover_enabled","email_human_takeover_mode","email_human_takeover_hours","video_enabled","live_avatar_id","live_avatar_preview_url","video_primary_color","video_position","video_cta_label","video_brand_name","video_launcher_style","video_subtitle","video_aspect_ratio","video_theme","video_offset_x","video_offset_y","video_greeting_message","sync_status","sync_stage","sync_error","phone_number_ids","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"phone_number_provider_conflict: a phone number is used by an agent on another call provider; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Idempotency-Key reused with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai_agents/{id}":{"get":{"tags":["AI Agents"],"summary":"Get an AI agent","description":"Required scope: `ai_agents:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"ai_agents:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["draft","active","inactive","archived"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"]},"language":{"type":"string"},"llm_provider":{"type":"string","enum":["gemini","openai","mercury","anthropic"]},"model_name":{"type":["string","null"]},"system_prompt":{"type":"string"},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"custom_instructions":{"type":["string","null"]},"phone_number_id":{"type":["string","null"],"format":"uuid"},"recording_enabled":{"type":"boolean"},"transcription_enabled":{"type":"boolean"},"is_template":{"type":"boolean"},"is_default":{"type":"boolean"},"transfer_number":{"type":["string","null"]},"sms_enabled":{"type":"boolean"},"consent_script":{"type":["string","null"]},"transfer_rotation":{"type":["string","null"],"enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"transfer_global_rules":{"type":"array","items":{"type":"object","additionalProperties":{}}},"transfer_type":{"type":["string","null"],"enum":["cold","warm"]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":["boolean","null"]},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":["integer","null"]},"transfer_connect_timeout_seconds":{"type":["integer","null"]},"transfer_hold_music_timeout_seconds":{"type":["integer","null"]},"email_enabled":{"type":["boolean","null"]},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer"},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer"},"video_enabled":{"type":["boolean","null"]},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"]},"video_primary_color":{"type":["string","null"]},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":["string","null"]},"video_brand_name":{"type":["string","null"]},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"]},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"sync_status":{"type":["string","null"],"enum":["pending","synced","failed","skipped"]},"sync_stage":{"type":["string","null"]},"sync_error":{"type":["string","null"]},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","status","call_direction","voice_provider","voice_id","language","llm_provider","model_name","system_prompt","voice_system_prompt","sms_system_prompt","greeting_message","greeting_message_inbound","custom_instructions","phone_number_id","recording_enabled","transcription_enabled","is_template","is_default","transfer_number","sms_enabled","consent_script","transfer_rotation","transfer_targets","transfer_global_rules","transfer_type","transfer_caller_id_mode","transfer_whisper_message","transfer_notify_unanswered","transfer_announcement","transfer_failure_message","transfer_answer_timeout_seconds","transfer_connect_timeout_seconds","transfer_hold_music_timeout_seconds","email_enabled","email_sender_id","sms_human_takeover_enabled","sms_human_takeover_mode","sms_human_takeover_hours","email_human_takeover_enabled","email_human_takeover_mode","email_human_takeover_hours","video_enabled","live_avatar_id","live_avatar_preview_url","video_primary_color","video_position","video_cta_label","video_brand_name","video_launcher_style","video_subtitle","video_aspect_ratio","video_theme","video_offset_x","video_offset_y","video_greeting_message","sync_status","sync_stage","sync_error","phone_number_ids","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["AI Agents"],"summary":"Update an AI agent","description":"Required scope: `ai_agents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"ai_agents:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":["string","null"],"maxLength":5000},"status":{"type":"string","enum":["draft","active","inactive"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"language":{"type":"string","enum":["multi","en-US","en-GB","en-AU","en-IN","es-ES","es-MX","fr-FR","de-DE","pt-BR","pt-PT","it-IT","nl-NL","pl-PL","ja-JP","ko-KR","zh-CN","hi-IN","ru-RU","sv-SE","da-DK"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"],"maxLength":100},"system_prompt":{"type":"string","minLength":1},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"consent_script":{"type":["string","null"]},"is_default":{"type":"boolean"},"transfer_rotation":{"type":"string","enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":"array","items":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"},"phoneNumber":{"type":"string","maxLength":40},"sipUri":{"type":"string","maxLength":500},"sipTrunkId":{"type":"string","maxLength":255},"label":{"type":"string","maxLength":200},"percentage":{"type":"number","minimum":0,"maximum":100},"description":{"type":"string","maxLength":2000},"isCustom":{"type":"boolean"}},"additionalProperties":false},"maxItems":50},"transfer_global_rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","maxLength":100},"condition":{"type":"string","minLength":1,"maxLength":2000},"target":{"type":"object","properties":{"userId":{"type":"string","format":"uuid"},"phoneNumber":{"type":"string","maxLength":40},"sipUri":{"type":"string","maxLength":500},"sipTrunkId":{"type":"string","maxLength":255},"label":{"type":"string","maxLength":200},"percentage":{"type":"number","minimum":0,"maximum":100},"description":{"type":"string","maxLength":2000},"isCustom":{"type":"boolean"}},"additionalProperties":false},"announcement":{"type":"string","maxLength":2000},"failureMessage":{"type":"string","maxLength":2000}},"required":["condition","target"],"additionalProperties":false},"maxItems":50},"transfer_type":{"type":"string","enum":["cold","warm"]},"transfer_caller_id_mode":{"type":"string","enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":"boolean"},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":"integer","minimum":15,"maximum":600},"transfer_connect_timeout_seconds":{"type":"integer","minimum":15,"maximum":600},"transfer_hold_music_timeout_seconds":{"anyOf":[{"type":"number","enum":[0]},{"type":"integer","minimum":15,"maximum":600}]},"sms_enabled":{"type":"boolean"},"email_enabled":{"type":"boolean"},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer","minimum":1,"maximum":720},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer","minimum":1,"maximum":720},"video_enabled":{"type":"boolean"},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"],"format":"uri"},"video_primary_color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":"string","maxLength":100},"video_brand_name":{"type":["string","null"],"maxLength":100},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"],"maxLength":140},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"agent_functions":{"type":"array","items":{"type":"object","additionalProperties":{}},"maxItems":100},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"},"maxItems":50}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["draft","active","inactive","archived"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"]},"language":{"type":"string"},"llm_provider":{"type":"string","enum":["gemini","openai","mercury","anthropic"]},"model_name":{"type":["string","null"]},"system_prompt":{"type":"string"},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"custom_instructions":{"type":["string","null"]},"phone_number_id":{"type":["string","null"],"format":"uuid"},"recording_enabled":{"type":"boolean"},"transcription_enabled":{"type":"boolean"},"is_template":{"type":"boolean"},"is_default":{"type":"boolean"},"transfer_number":{"type":["string","null"]},"sms_enabled":{"type":"boolean"},"consent_script":{"type":["string","null"]},"transfer_rotation":{"type":["string","null"],"enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"transfer_global_rules":{"type":"array","items":{"type":"object","additionalProperties":{}}},"transfer_type":{"type":["string","null"],"enum":["cold","warm"]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":["boolean","null"]},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":["integer","null"]},"transfer_connect_timeout_seconds":{"type":["integer","null"]},"transfer_hold_music_timeout_seconds":{"type":["integer","null"]},"email_enabled":{"type":["boolean","null"]},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer"},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer"},"video_enabled":{"type":["boolean","null"]},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"]},"video_primary_color":{"type":["string","null"]},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":["string","null"]},"video_brand_name":{"type":["string","null"]},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"]},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"sync_status":{"type":["string","null"],"enum":["pending","synced","failed","skipped"]},"sync_stage":{"type":["string","null"]},"sync_error":{"type":["string","null"]},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","status","call_direction","voice_provider","voice_id","language","llm_provider","model_name","system_prompt","voice_system_prompt","sms_system_prompt","greeting_message","greeting_message_inbound","custom_instructions","phone_number_id","recording_enabled","transcription_enabled","is_template","is_default","transfer_number","sms_enabled","consent_script","transfer_rotation","transfer_targets","transfer_global_rules","transfer_type","transfer_caller_id_mode","transfer_whisper_message","transfer_notify_unanswered","transfer_announcement","transfer_failure_message","transfer_answer_timeout_seconds","transfer_connect_timeout_seconds","transfer_hold_music_timeout_seconds","email_enabled","email_sender_id","sms_human_takeover_enabled","sms_human_takeover_mode","sms_human_takeover_hours","email_human_takeover_enabled","email_human_takeover_mode","email_human_takeover_hours","video_enabled","live_avatar_id","live_avatar_preview_url","video_primary_color","video_position","video_cta_label","video_brand_name","video_launcher_style","video_subtitle","video_aspect_ratio","video_theme","video_offset_x","video_offset_y","video_greeting_message","sync_status","sync_stage","sync_error","phone_number_ids","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"phone_number_provider_conflict: a phone number is used by an agent on another call provider; agent_archived: the agent is archived and the body does not restore it with a status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["AI Agents"],"summary":"Archive or permanently delete an AI agent","description":"Required scope: `ai_agents:delete`","security":[{"bearerAuth":[]}],"x-aivi-scope":"ai_agents:delete","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","enum":["true","false"]},"required":false,"name":"permanent","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"anyOf":[{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["draft","active","inactive","archived"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"]},"language":{"type":"string"},"llm_provider":{"type":"string","enum":["gemini","openai","mercury","anthropic"]},"model_name":{"type":["string","null"]},"system_prompt":{"type":"string"},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"custom_instructions":{"type":["string","null"]},"phone_number_id":{"type":["string","null"],"format":"uuid"},"recording_enabled":{"type":"boolean"},"transcription_enabled":{"type":"boolean"},"is_template":{"type":"boolean"},"is_default":{"type":"boolean"},"transfer_number":{"type":["string","null"]},"sms_enabled":{"type":"boolean"},"consent_script":{"type":["string","null"]},"transfer_rotation":{"type":["string","null"],"enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"transfer_global_rules":{"type":"array","items":{"type":"object","additionalProperties":{}}},"transfer_type":{"type":["string","null"],"enum":["cold","warm"]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":["boolean","null"]},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":["integer","null"]},"transfer_connect_timeout_seconds":{"type":["integer","null"]},"transfer_hold_music_timeout_seconds":{"type":["integer","null"]},"email_enabled":{"type":["boolean","null"]},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer"},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer"},"video_enabled":{"type":["boolean","null"]},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"]},"video_primary_color":{"type":["string","null"]},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":["string","null"]},"video_brand_name":{"type":["string","null"]},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"]},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"sync_status":{"type":["string","null"],"enum":["pending","synced","failed","skipped"]},"sync_stage":{"type":["string","null"]},"sync_error":{"type":["string","null"]},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","status","call_direction","voice_provider","voice_id","language","llm_provider","model_name","system_prompt","voice_system_prompt","sms_system_prompt","greeting_message","greeting_message_inbound","custom_instructions","phone_number_id","recording_enabled","transcription_enabled","is_template","is_default","transfer_number","sms_enabled","consent_script","transfer_rotation","transfer_targets","transfer_global_rules","transfer_type","transfer_caller_id_mode","transfer_whisper_message","transfer_notify_unanswered","transfer_announcement","transfer_failure_message","transfer_answer_timeout_seconds","transfer_connect_timeout_seconds","transfer_hold_music_timeout_seconds","email_enabled","email_sender_id","sms_human_takeover_enabled","sms_human_takeover_mode","sms_human_takeover_hours","email_human_takeover_enabled","email_human_takeover_mode","email_human_takeover_hours","video_enabled","live_avatar_id","live_avatar_preview_url","video_primary_color","video_position","video_cta_label","video_brand_name","video_launcher_style","video_subtitle","video_aspect_ratio","video_theme","video_offset_x","video_offset_y","video_greeting_message","sync_status","sync_stage","sync_error","phone_number_ids","created_at","updated_at"]},{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"deleted":{"type":"boolean","enum":[true]}},"required":["id","deleted"]}]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"System agent, call history, or IVR route reference","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/ai_agents/{id}/duplicate":{"post":{"tags":["AI Agents"],"summary":"Duplicate an AI agent","description":"Required scope: `ai_agents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"ai_agents:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","minLength":1,"maxLength":255,"description":"Makes the request safely retryable: the first response for a key is stored for 24h and replayed (with `Idempotent-Replayed: true`) for a retry with the same request. Only 2xx and 400/404/422 responses are stored."},"required":false,"name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200}},"additionalProperties":false}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"status":{"type":"string","enum":["draft","active","inactive","archived"]},"call_direction":{"type":"string","enum":["inbound","outbound","both"]},"voice_provider":{"type":"string","enum":["cartesia","elevenlabs","fishaudio"]},"voice_id":{"type":["string","null"]},"language":{"type":"string"},"llm_provider":{"type":"string","enum":["gemini","openai","mercury","anthropic"]},"model_name":{"type":["string","null"]},"system_prompt":{"type":"string"},"voice_system_prompt":{"type":["string","null"]},"sms_system_prompt":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"greeting_message_inbound":{"type":["string","null"]},"custom_instructions":{"type":["string","null"]},"phone_number_id":{"type":["string","null"],"format":"uuid"},"recording_enabled":{"type":"boolean"},"transcription_enabled":{"type":"boolean"},"is_template":{"type":"boolean"},"is_default":{"type":"boolean"},"transfer_number":{"type":["string","null"]},"sms_enabled":{"type":"boolean"},"consent_script":{"type":["string","null"]},"transfer_rotation":{"type":["string","null"],"enum":["round_robin","percentage","priority","dynamic","simultaneous"]},"transfer_targets":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"transfer_global_rules":{"type":"array","items":{"type":"object","additionalProperties":{}}},"transfer_type":{"type":["string","null"],"enum":["cold","warm"]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number"]},"transfer_whisper_message":{"type":["string","null"]},"transfer_notify_unanswered":{"type":["boolean","null"]},"transfer_announcement":{"type":["string","null"]},"transfer_failure_message":{"type":["string","null"]},"transfer_answer_timeout_seconds":{"type":["integer","null"]},"transfer_connect_timeout_seconds":{"type":["integer","null"]},"transfer_hold_music_timeout_seconds":{"type":["integer","null"]},"email_enabled":{"type":["boolean","null"]},"email_sender_id":{"type":["string","null"],"format":"uuid"},"sms_human_takeover_enabled":{"type":"boolean"},"sms_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"sms_human_takeover_hours":{"type":"integer"},"email_human_takeover_enabled":{"type":"boolean"},"email_human_takeover_mode":{"type":"string","enum":["window","indefinite"]},"email_human_takeover_hours":{"type":"integer"},"video_enabled":{"type":["boolean","null"]},"live_avatar_id":{"type":["string","null"]},"live_avatar_preview_url":{"type":["string","null"]},"video_primary_color":{"type":["string","null"]},"video_position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"video_cta_label":{"type":["string","null"]},"video_brand_name":{"type":["string","null"]},"video_launcher_style":{"type":"string","enum":["pill","bubble","avatar"]},"video_subtitle":{"type":["string","null"]},"video_aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1"]},"video_theme":{"type":"string","enum":["dark","light"]},"video_offset_x":{"type":"integer"},"video_offset_y":{"type":"integer"},"video_greeting_message":{"type":["string","null"]},"sync_status":{"type":["string","null"],"enum":["pending","synced","failed","skipped"]},"sync_stage":{"type":["string","null"]},"sync_error":{"type":["string","null"]},"phone_number_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","status","call_direction","voice_provider","voice_id","language","llm_provider","model_name","system_prompt","voice_system_prompt","sms_system_prompt","greeting_message","greeting_message_inbound","custom_instructions","phone_number_id","recording_enabled","transcription_enabled","is_template","is_default","transfer_number","sms_enabled","consent_script","transfer_rotation","transfer_targets","transfer_global_rules","transfer_type","transfer_caller_id_mode","transfer_whisper_message","transfer_notify_unanswered","transfer_announcement","transfer_failure_message","transfer_answer_timeout_seconds","transfer_connect_timeout_seconds","transfer_hold_music_timeout_seconds","email_enabled","email_sender_id","sms_human_takeover_enabled","sms_human_takeover_mode","sms_human_takeover_hours","email_human_takeover_enabled","email_human_takeover_mode","email_human_takeover_hours","video_enabled","live_avatar_id","live_avatar_preview_url","video_primary_color","video_position","video_cta_label","video_brand_name","video_launcher_style","video_subtitle","video_aspect_ratio","video_theme","video_offset_x","video_offset_y","video_greeting_message","sync_status","sync_stage","sync_error","phone_number_ids","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"system_agent: system agents cannot be duplicated; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Idempotency-Key reused with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/experts":{"get":{"tags":["Experts"],"summary":"List experts","description":"Required scope: `experts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"experts:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","enum":["draft","pending_cert","validated","certified","live","rejected"]},"required":false,"name":"cert_status","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/experts/{id}":{"get":{"tags":["Experts"],"summary":"Get an expert","description":"Required scope: `experts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"experts:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/experts/{id}/invoke":{"post":{"tags":["Experts"],"summary":"Invoke an expert","description":"Required scope: `experts:invoke`","security":[{"bearerAuth":[]}],"x-aivi-scope":"experts:invoke","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"call_id":{"type":"string","format":"uuid"},"ai_agent_id":{"type":"string","format":"uuid"},"args":{"type":"object","additionalProperties":{}}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts":{"get":{"tags":["Contacts"],"summary":"List contacts","description":"Required scope: `contacts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string"},"required":false,"name":"tags","in":"query"},{"schema":{"type":"string"},"required":false,"name":"search","in":"query"},{"schema":{"type":"string"},"required":false,"name":"email","in":"query"},{"schema":{"type":"string"},"required":false,"name":"phone","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"assigned_to","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|updated_at|first_name|last_name|email|phone|status)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"first_name":{"type":["string","null"]},"last_name":{"type":["string","null"]},"full_name":{"type":["string","null"]},"email":{"type":["string","null"],"format":"email"},"phone":{"type":["string","null"]},"secondary_phone":{"type":["string","null"]},"address":{"type":["object","null"],"additionalProperties":{}},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","additionalProperties":{}},"assigned_to":{"type":["string","null"],"format":"uuid"},"source":{"type":["string","null"]},"last_contacted_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"phones":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"phone":{"type":"string"},"type":{"type":"string","enum":["mobile","home","work","main","fax","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","phone","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}},"emails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"type":{"type":"string","enum":["personal","work","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","email","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}}},"required":["id","first_name","last_name","full_name","email","phone","secondary_phone","address","status","tags","custom_fields","assigned_to","source","last_contacted_at","created_at","updated_at","phones","emails"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Contacts"],"summary":"Create a contact","description":"Required scope: `contacts:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string","minLength":1,"maxLength":100},"last_name":{"type":"string","minLength":1,"maxLength":100},"email":{"type":"string","format":"email"},"phone":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"secondary_phone":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"phones":{"type":"array","items":{"type":"object","properties":{"phone":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"type":{"type":"string","enum":["mobile","home","work","main","fax","other"]},"is_primary":{"type":"boolean"}},"required":["phone"],"additionalProperties":false},"maxItems":20},"emails":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string","format":"email"},"type":{"type":"string","enum":["personal","work","other"]},"is_primary":{"type":"boolean"}},"required":["email"],"additionalProperties":false},"maxItems":20},"address":{"type":"object","properties":{}},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64},"maxItems":50},"custom_fields":{"type":"object","additionalProperties":{}},"assigned_to":{"type":"string","format":"uuid"},"source":{"type":"string","maxLength":100},"trigger_flows_on_duplicates":{"type":"boolean"}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"first_name":{"type":["string","null"]},"last_name":{"type":["string","null"]},"full_name":{"type":["string","null"]},"email":{"type":["string","null"],"format":"email"},"phone":{"type":["string","null"]},"secondary_phone":{"type":["string","null"]},"address":{"type":["object","null"],"additionalProperties":{}},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","additionalProperties":{}},"assigned_to":{"type":["string","null"],"format":"uuid"},"source":{"type":["string","null"]},"last_contacted_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"phones":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"phone":{"type":"string"},"type":{"type":"string","enum":["mobile","home","work","main","fax","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","phone","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}},"emails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"type":{"type":"string","enum":["personal","work","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","email","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}}},"required":["id","first_name","last_name","full_name","email","phone","secondary_phone","address","status","tags","custom_fields","assigned_to","source","last_contacted_at","created_at","updated_at","phones","emails"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}":{"get":{"tags":["Contacts"],"summary":"Get a contact","description":"Required scope: `contacts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"first_name":{"type":["string","null"]},"last_name":{"type":["string","null"]},"full_name":{"type":["string","null"]},"email":{"type":["string","null"],"format":"email"},"phone":{"type":["string","null"]},"secondary_phone":{"type":["string","null"]},"address":{"type":["object","null"],"additionalProperties":{}},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","additionalProperties":{}},"assigned_to":{"type":["string","null"],"format":"uuid"},"source":{"type":["string","null"]},"last_contacted_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"phones":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"phone":{"type":"string"},"type":{"type":"string","enum":["mobile","home","work","main","fax","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","phone","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}},"emails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"type":{"type":"string","enum":["personal","work","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","email","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}}},"required":["id","first_name","last_name","full_name","email","phone","secondary_phone","address","status","tags","custom_fields","assigned_to","source","last_contacted_at","created_at","updated_at","phones","emails"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Contacts"],"summary":"Update a contact","description":"Required scope: `contacts:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":["string","null"],"minLength":1,"maxLength":100},"last_name":{"type":["string","null"],"minLength":1,"maxLength":100},"email":{"type":["string","null"],"format":"email"},"phone":{"type":["string","null"],"pattern":"^\\+[1-9]\\d{1,14}$"},"secondary_phone":{"type":["string","null"],"pattern":"^\\+[1-9]\\d{1,14}$"},"phones":{"type":"array","items":{"type":"object","properties":{"phone":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"type":{"type":"string","enum":["mobile","home","work","main","fax","other"]},"is_primary":{"type":"boolean"}},"required":["phone"],"additionalProperties":false},"maxItems":20},"emails":{"type":"array","items":{"type":"object","properties":{"email":{"type":"string","format":"email"},"type":{"type":"string","enum":["personal","work","other"]},"is_primary":{"type":"boolean"}},"required":["email"],"additionalProperties":false},"maxItems":20},"address":{"type":["object","null"],"properties":{}},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64},"maxItems":50},"custom_fields":{"type":"object","additionalProperties":{}},"assigned_to":{"type":["string","null"],"format":"uuid"},"source":{"type":["string","null"],"maxLength":100}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"first_name":{"type":["string","null"]},"last_name":{"type":["string","null"]},"full_name":{"type":["string","null"]},"email":{"type":["string","null"],"format":"email"},"phone":{"type":["string","null"]},"secondary_phone":{"type":["string","null"]},"address":{"type":["object","null"],"additionalProperties":{}},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","additionalProperties":{}},"assigned_to":{"type":["string","null"],"format":"uuid"},"source":{"type":["string","null"]},"last_contacted_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"phones":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"phone":{"type":"string"},"type":{"type":"string","enum":["mobile","home","work","main","fax","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","phone","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}},"emails":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"email":{"type":"string"},"type":{"type":"string","enum":["personal","work","other"]},"is_primary":{"type":"boolean"},"position":{"type":"integer"},"is_dnc":{"type":"boolean"},"dnc_added_at":{"type":["string","null"],"format":"date-time"},"dnc_reason":{"type":["string","null"],"enum":["litigator","complaint","sms_stop","unsubscribe","caller_request","manual","imported","crm_sync"]}},"required":["id","email","type","is_primary","position","is_dnc","dnc_added_at","dnc_reason"]}}},"required":["id","first_name","last_name","full_name","email","phone","secondary_phone","address","status","tags","custom_fields","assigned_to","source","last_contacted_at","created_at","updated_at","phones","emails"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Contacts"],"summary":"Delete a contact","description":"Required scope: `contacts:delete`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:delete","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"deleted":{"type":"boolean","enum":[true]}},"required":["id","deleted"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/enrich":{"post":{"tags":["Insights"],"summary":"Enrich a contact","description":"Required scope: `insights:enrich`","security":[{"bearerAuth":[]}],"x-aivi-scope":"insights:enrich","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"enriched_fields":{"type":"integer"},"apis_with_data":{"type":"array","items":{"type":"string"}},"tier":{"type":["string","null"]},"tier_label":{"type":["string","null"]},"tier_action":{"type":["string","null"]},"fields":{"type":"object","additionalProperties":{}},"enriched_at":{"type":"string","format":"date-time"},"contact_id":{"type":"string","format":"uuid"}},"required":["enriched_fields","apis_with_data","tier","tier_label","tier_action","fields","enriched_at","contact_id"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/dnc":{"get":{"tags":["Contacts"],"summary":"List a contact's do-not-contact records","description":"Required scope: `contacts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Contacts"],"summary":"Add a do-not-contact record to a contact","description":"Required scope: `contacts:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","enum":["manual","complaint"],"default":"manual"},"notes":{"type":"string","maxLength":2000},"channel":{"type":"string","enum":["all","voice","sms","email"],"default":"all"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Contacts"],"summary":"Revoke a contact's do-not-contact records","description":"Required scope: `contacts:dnc_manage`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:dnc_manage","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500},"channel":{"type":"string","enum":["all","voice","sms","email"]}},"required":["reason"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/phones/{point_id}/dnc":{"post":{"tags":["Contacts"],"summary":"Add a do-not-contact record to a contact phone number","description":"Required scope: `contacts:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"point_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","enum":["manual","complaint"],"default":"manual"},"notes":{"type":"string","maxLength":2000},"channel":{"type":"string","enum":["all","voice","sms","email"],"default":"all"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Contacts"],"summary":"Revoke a do-not-contact record on a contact phone number","description":"Required scope: `contacts:dnc_manage`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:dnc_manage","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"point_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500},"channel":{"type":"string","enum":["all","voice","sms","email"]}},"required":["reason"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/emails/{point_id}/dnc":{"post":{"tags":["Contacts"],"summary":"Add a do-not-contact record to a contact email address","description":"Required scope: `contacts:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"point_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","enum":["manual","complaint"],"default":"manual"},"notes":{"type":"string","maxLength":2000},"channel":{"type":"string","enum":["all","voice","sms","email"],"default":"all"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Contacts"],"summary":"Revoke a do-not-contact record on a contact email address","description":"Required scope: `contacts:dnc_manage`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:dnc_manage","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"point_id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","minLength":1,"maxLength":500},"channel":{"type":"string","enum":["all","voice","sms","email"]}},"required":["reason"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/insights":{"post":{"tags":["Insights"],"summary":"Query insights","description":"Required scope: `insights:enrich`","security":[{"bearerAuth":[]}],"x-aivi-scope":"insights:enrich","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"phone":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"first_name":{"type":"string","minLength":1,"maxLength":100},"last_name":{"type":"string","minLength":1,"maxLength":100},"email":{"type":"string","format":"email"},"address":{"type":"string","maxLength":255},"city":{"type":"string","maxLength":100},"state":{"type":"string","maxLength":100},"zip":{"type":"string","maxLength":20}},"required":["phone"],"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"enriched_fields":{"type":"integer"},"apis_with_data":{"type":"array","items":{"type":"string"}},"tier":{"type":["string","null"]},"tier_label":{"type":["string","null"]},"tier_action":{"type":["string","null"]},"fields":{"type":"object","additionalProperties":{}},"enriched_at":{"type":"string","format":"date-time"}},"required":["enriched_fields","apis_with_data","tier","tier_label","tier_action","fields","enriched_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/calls":{"get":{"tags":["Calls"],"summary":"List calls","description":"Required scope: `calls:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"calls:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","enum":["inbound","outbound"]},"required":false,"name":"direction","in":"query"},{"schema":{"type":"string","enum":["initiated","ringing","in-progress","completed","busy","failed","no-answer","cancelled"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","enum":["answered","no-answer","busy","voicemail","failed","canceled","transferred"]},"required":false,"name":"outcome","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from_date","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to_date","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|started_at|ended_at|duration)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"status":{"type":"string","enum":["initiated","ringing","in-progress","completed","busy","failed","no-answer","cancelled"]},"outcome":{"type":["string","null"],"enum":["answered","no-answer","busy","voicemail","failed","canceled","transferred"]},"phone_number":{"type":["string","null"]},"from_number":{"type":["string","null"]},"to_number":{"type":["string","null"]},"initiated_at":{"type":["string","null"],"format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"ended_at":{"type":["string","null"],"format":"date-time"},"duration":{"type":"integer"},"call_summary":{"type":["string","null"]},"source":{"type":"string","enum":["phone","upload"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","direction","status","outcome","phone_number","from_number","to_number","initiated_at","started_at","ended_at","duration","call_summary","source","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Calls"],"summary":"Initiate a call","description":"Required scope: `calls:initiate`","security":[{"bearerAuth":[]}],"x-aivi-scope":"calls:initiate","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"agent_id":{"type":"string","format":"uuid"},"to_number":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"from_phone_number_id":{"type":"string","format":"uuid"},"contact_id":{"type":"string","format":"uuid"},"system_prompt_override":{"type":"string","minLength":1,"maxLength":20000},"greeting_override":{"type":"string","minLength":1,"maxLength":2000},"metadata":{"type":"object","additionalProperties":{}}},"required":["agent_id","to_number","from_phone_number_id"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"call_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["initiated"]},"direction":{"type":"string","enum":["outbound"]},"from_number":{"type":"string"},"to_number":{"type":"string"},"initiated_at":{"type":"string","format":"date-time"}},"required":["call_id","status","direction","from_number","to_number","initiated_at"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Agent not active or not ready","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/calls/{id}":{"get":{"tags":["Calls"],"summary":"Get a call","description":"Required scope: `calls:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"calls:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"status":{"type":"string","enum":["initiated","ringing","in-progress","completed","busy","failed","no-answer","cancelled"]},"outcome":{"type":["string","null"],"enum":["answered","no-answer","busy","voicemail","failed","canceled","transferred"]},"phone_number":{"type":["string","null"]},"from_number":{"type":["string","null"]},"to_number":{"type":["string","null"]},"initiated_at":{"type":["string","null"],"format":"date-time"},"started_at":{"type":["string","null"],"format":"date-time"},"ended_at":{"type":["string","null"],"format":"date-time"},"duration":{"type":"integer"},"call_summary":{"type":["string","null"]},"source":{"type":"string","enum":["phone","upload"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"transcript_text":{"type":["string","null"]},"transcript_object":{"type":["array","null"],"items":{}},"call_intelligence":{"type":"object","additionalProperties":{}},"recording_url":{"type":["string","null"]},"recording_duration":{"type":["integer","null"]}},"required":["id","contact_id","direction","status","outcome","phone_number","from_number","to_number","initiated_at","started_at","ended_at","duration","call_summary","source","created_at","updated_at","transcript_text","transcript_object","call_intelligence","recording_url","recording_duration"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/call_intelligence/{call_id}":{"get":{"tags":["Call Intelligence"],"summary":"Get call intelligence for a call","description":"Required scope: `calls:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"calls:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"call_id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"call_id":{"type":"string","format":"uuid"},"call_summary":{"type":["string","null"]},"intelligence":{"type":"object","additionalProperties":{}},"ended_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["call_id","call_summary","intelligence","ended_at","created_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/recordings/{call_id}":{"get":{"tags":["Recordings"],"summary":"Download a call recording","description":"Required scope: `calls:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"calls:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"call_id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/messages":{"get":{"tags":["Messages"],"summary":"List messages","description":"Required scope: `messages:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"messages:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"conversation_id","in":"query"},{"schema":{"type":"string","enum":["sms","mms","whatsapp"]},"required":false,"name":"channel","in":"query"},{"schema":{"type":"string","enum":["inbound","outbound"]},"required":false,"name":"direction","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from_date","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to_date","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|sent_at|delivered_at)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"channel":{"type":"string","enum":["sms","mms","whatsapp"]},"status":{"type":"string","enum":["accepted","queued","sent","delivered","undelivered","failed","received"]},"from_number":{"type":"string"},"to_number":{"type":"string"},"body":{"type":"string"},"media_urls":{"type":["array","null"],"items":{"type":"string"}},"is_read":{"type":"boolean"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"},"message_sid":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","conversation_id","direction","channel","status","from_number","to_number","body","media_urls","is_read","sent_at","delivered_at","read_at","message_sid","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Messages"],"summary":"Send a message","description":"Required scope: `messages:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"messages:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"from_number":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"body":{"type":"string","minLength":1,"maxLength":1600},"media_urls":{"type":"array","items":{"type":"string"},"maxItems":10}},"required":["contact_id","from_number","body"],"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"channel":{"type":"string","enum":["sms","mms","whatsapp"]},"status":{"type":"string","enum":["accepted","queued","sent","delivered","undelivered","failed","received"]},"from_number":{"type":"string"},"to_number":{"type":"string"},"body":{"type":"string"},"media_urls":{"type":["array","null"],"items":{"type":"string"}},"is_read":{"type":"boolean"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"},"message_sid":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","conversation_id","direction","channel","status","from_number","to_number","body","media_urls","is_read","sent_at","delivered_at","read_at","message_sid","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/messages/{id}":{"get":{"tags":["Messages"],"summary":"Get a message","description":"Required scope: `messages:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"messages:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":"string","format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"channel":{"type":"string","enum":["sms","mms","whatsapp"]},"status":{"type":"string","enum":["accepted","queued","sent","delivered","undelivered","failed","received"]},"from_number":{"type":"string"},"to_number":{"type":"string"},"body":{"type":"string"},"media_urls":{"type":["array","null"],"items":{"type":"string"}},"is_read":{"type":"boolean"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"read_at":{"type":["string","null"],"format":"date-time"},"message_sid":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","conversation_id","direction","channel","status","from_number","to_number","body","media_urls","is_read","sent_at","delivered_at","read_at","message_sid","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/emails":{"get":{"tags":["Emails"],"summary":"List emails","description":"Required scope: `emails:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"emails:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"conversation_id","in":"query"},{"schema":{"type":"string","enum":["inbound","outbound"]},"required":false,"name":"direction","in":"query"},{"schema":{"type":"string","enum":["queued","sent","delivered","opened","clicked","bounced","dropped","failed"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from_date","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to_date","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|sent_at|delivered_at)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":["string","null"],"format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"status":{"type":"string","enum":["queued","sent","delivered","opened","clicked","bounced","dropped","failed"]},"from_email":{"type":"string","format":"email"},"from_name":{"type":["string","null"]},"to_email":{"type":"string","format":"email"},"reply_to":{"type":["string","null"],"format":"email"},"subject":{"type":"string"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"opened_at":{"type":["string","null"],"format":"date-time"},"clicked_at":{"type":["string","null"],"format":"date-time"},"open_count":{"type":"integer"},"click_count":{"type":"integer"},"is_read":{"type":"boolean"},"sendgrid_message_id":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","conversation_id","direction","status","from_email","from_name","to_email","reply_to","subject","sent_at","delivered_at","opened_at","clicked_at","open_count","click_count","is_read","sendgrid_message_id","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Emails"],"summary":"Send an email","description":"Required scope: `emails:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"emails:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"subject":{"type":"string","minLength":1,"maxLength":998},"body":{"type":"string","minLength":1},"html_body":{"type":"string"},"cc":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"bcc":{"type":"array","items":{"type":"string","format":"email"},"maxItems":50},"reply_to":{"type":"string","format":"email"},"from_sender_id":{"type":"string","format":"uuid"}},"required":["contact_id","subject","body"],"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/emails/{id}":{"get":{"tags":["Emails"],"summary":"Get an email","description":"Required scope: `emails:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"emails:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"contact_id":{"type":["string","null"],"format":"uuid"},"conversation_id":{"type":["string","null"],"format":"uuid"},"direction":{"type":"string","enum":["inbound","outbound"]},"status":{"type":"string","enum":["queued","sent","delivered","opened","clicked","bounced","dropped","failed"]},"from_email":{"type":"string","format":"email"},"from_name":{"type":["string","null"]},"to_email":{"type":"string","format":"email"},"reply_to":{"type":["string","null"],"format":"email"},"subject":{"type":"string"},"sent_at":{"type":["string","null"],"format":"date-time"},"delivered_at":{"type":["string","null"],"format":"date-time"},"opened_at":{"type":["string","null"],"format":"date-time"},"clicked_at":{"type":["string","null"],"format":"date-time"},"open_count":{"type":"integer"},"click_count":{"type":"integer"},"is_read":{"type":"boolean"},"sendgrid_message_id":{"type":["string","null"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"body":{"type":["string","null"]},"html_body":{"type":["string","null"]},"cc":{"type":["array","null"],"items":{"type":"string"}},"bcc":{"type":["array","null"],"items":{"type":"string"}},"bounced_at":{"type":["string","null"],"format":"date-time"},"error_message":{"type":["string","null"]},"error_code":{"type":["string","null"]}},"required":["id","contact_id","conversation_id","direction","status","from_email","from_name","to_email","reply_to","subject","sent_at","delivered_at","opened_at","clicked_at","open_count","click_count","is_read","sendgrid_message_id","created_at","updated_at","body","html_body","cc","bcc","bounced_at","error_message","error_code"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows":{"get":{"tags":["Workflows"],"summary":"List workflows","description":"Required scope: `workflows:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","enum":["active","completed","failed","draft","archived"]},"required":false,"name":"status","in":"query"},{"schema":{"anyOf":[{"type":"string","enum":["true"]},{"type":"string","enum":["false"]}]},"required":false,"name":"include_inactive","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|updated_at|name)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Workflows"],"summary":"Create a workflow","description":"Required scope: `workflows:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255},"description":{"type":["string","null"],"maxLength":2000},"trigger":{"type":"object","properties":{"type":{"type":"string","minLength":1},"config":{"type":"object","additionalProperties":{}}},"required":["type"]},"timezone":{"type":["string","null"],"maxLength":64},"nodes":{"type":"array","items":{"type":"object","properties":{"node_key":{"type":"string","minLength":1,"maxLength":255},"node_type":{"type":"string","minLength":1},"action_type":{"type":["string","null"]},"label":{"type":["string","null"],"maxLength":255},"config":{"type":"object","additionalProperties":{}},"position_x":{"type":"integer"},"position_y":{"type":"integer"}},"required":["node_key","node_type"]},"minItems":1,"maxItems":500},"edges":{"type":"array","items":{"type":"object","properties":{"edge_key":{"type":"string","minLength":1,"maxLength":255},"source_node_key":{"type":"string","minLength":1},"target_node_key":{"type":"string","minLength":1},"source_handle":{"type":["string","null"],"maxLength":50},"target_handle":{"type":["string","null"],"maxLength":50},"label":{"type":"string","maxLength":100},"config":{"type":"object","additionalProperties":{}}},"required":["edge_key","source_node_key","target_node_key"]},"maxItems":2000}},"required":["name","trigger","nodes","edges"]}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows/{id}":{"get":{"tags":["Workflows"],"summary":"Get a workflow","description":"Required scope: `workflows:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Workflows"],"summary":"Update a workflow","description":"Required scope: `workflows:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":255},"description":{"type":["string","null"],"maxLength":2000},"trigger":{"type":"object","properties":{"type":{"type":"string","minLength":1},"config":{"type":"object","additionalProperties":{}}},"required":["type"]},"timezone":{"type":["string","null"],"maxLength":64},"nodes":{"type":"array","items":{"type":"object","properties":{"node_key":{"type":"string","minLength":1,"maxLength":255},"node_type":{"type":"string","minLength":1},"action_type":{"type":["string","null"]},"label":{"type":["string","null"],"maxLength":255},"config":{"type":"object","additionalProperties":{}},"position_x":{"type":"integer"},"position_y":{"type":"integer"}},"required":["node_key","node_type"]},"minItems":1,"maxItems":500},"edges":{"type":"array","items":{"type":"object","properties":{"edge_key":{"type":"string","minLength":1,"maxLength":255},"source_node_key":{"type":"string","minLength":1},"target_node_key":{"type":"string","minLength":1},"source_handle":{"type":["string","null"],"maxLength":50},"target_handle":{"type":["string","null"],"maxLength":50},"label":{"type":"string","maxLength":100},"config":{"type":"object","additionalProperties":{}}},"required":["edge_key","source_node_key","target_node_key"]},"maxItems":2000}},"required":["name","trigger","nodes","edges"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Workflows"],"summary":"Delete a workflow","description":"Required scope: `workflows:delete`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:delete","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows/{id}/enroll":{"post":{"tags":["Workflows"],"summary":"Enroll a contact in a workflow","description":"Required scope: `workflows:enroll`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:enroll","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"}},"required":["contact_id"]}}}},"responses":{"202":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows/{id}/activate":{"post":{"tags":["Workflows"],"summary":"Activate a workflow","description":"Required scope: `workflows:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows/{id}/deactivate":{"post":{"tags":["Workflows"],"summary":"Deactivate a workflow","description":"Required scope: `workflows:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows/{id}/duplicate":{"post":{"tags":["Workflows"],"summary":"Duplicate a workflow","description":"Required scope: `workflows:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflow_enrollments":{"get":{"tags":["Enrollments"],"summary":"List workflow enrollments","description":"Required scope: `workflows:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"contact_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"workflow_id","in":"query"},{"schema":{"type":"string","enum":["active","completed","failed","paused","looping","skipped","cancelled","paused_insufficient_funds"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from_date","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to_date","in":"query"},{"schema":{"type":"string","pattern":"^(enrolled_at|started_at|completed_at|last_executed_at)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflow_enrollments/{id}":{"delete":{"tags":["Enrollments"],"summary":"Cancel a workflow enrollment","description":"Required scope: `workflows:enroll`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:enroll","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/rubrics":{"get":{"tags":["Rubrics"],"summary":"List rubrics","description":"Required scope: `rubrics:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"rubrics:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","enum":["ai","live","both"]},"required":false,"name":"agent_type","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"is_active","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"auto_evaluate","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|updated_at|name)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"criteria":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"weight":{"type":"number","minimum":0,"maximum":100},"max_score":{"type":"number","minimum":1,"maximum":100},"evaluation_guidance":{"type":"string","maxLength":4000},"type":{"type":"string","enum":["boolean","scale"]},"required":{"type":"boolean"}},"required":["id","name","description","weight","max_score","evaluation_guidance","type","required"]}},"agent_type":{"type":"string","enum":["ai","live","both"]},"is_active":{"type":"boolean"},"auto_evaluate":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","criteria","agent_type","is_active","auto_evaluate","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Rubrics"],"summary":"Create a rubric","description":"Required scope: `rubrics:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"rubrics:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"criteria":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"weight":{"type":"number","minimum":0,"maximum":100},"max_score":{"type":"number","minimum":1,"maximum":100},"evaluation_guidance":{"type":"string","maxLength":4000},"type":{"type":"string","enum":["boolean","scale"]},"required":{"type":"boolean"}},"required":["id","name","description","weight","max_score","evaluation_guidance","type","required"]},"minItems":1,"maxItems":50},"agent_type":{"type":"string","enum":["ai","live","both"],"default":"both"},"is_active":{"type":"boolean","default":true},"auto_evaluate":{"type":"boolean","default":true}},"required":["name","criteria"],"additionalProperties":false}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"criteria":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"weight":{"type":"number","minimum":0,"maximum":100},"max_score":{"type":"number","minimum":1,"maximum":100},"evaluation_guidance":{"type":"string","maxLength":4000},"type":{"type":"string","enum":["boolean","scale"]},"required":{"type":"boolean"}},"required":["id","name","description","weight","max_score","evaluation_guidance","type","required"]}},"agent_type":{"type":"string","enum":["ai","live","both"]},"is_active":{"type":"boolean"},"auto_evaluate":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","criteria","agent_type","is_active","auto_evaluate","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/rubrics/{id}":{"get":{"tags":["Rubrics"],"summary":"Get a rubric","description":"Required scope: `rubrics:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"rubrics:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"description":{"type":["string","null"]},"criteria":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1},"name":{"type":"string","minLength":1,"maxLength":200},"description":{"type":"string","maxLength":2000},"weight":{"type":"number","minimum":0,"maximum":100},"max_score":{"type":"number","minimum":1,"maximum":100},"evaluation_guidance":{"type":"string","maxLength":4000},"type":{"type":"string","enum":["boolean","scale"]},"required":{"type":"boolean"}},"required":["id","name","description","weight","max_score","evaluation_guidance","type","required"]}},"agent_type":{"type":"string","enum":["ai","live","both"]},"is_active":{"type":"boolean"},"auto_evaluate":{"type":"boolean"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","description","criteria","agent_type","is_active","auto_evaluate","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/scorecards":{"get":{"tags":["Scorecards"],"summary":"List scorecards","description":"Required scope: `scorecards:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"scorecards:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"call_id","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"rubric_id","in":"query"},{"schema":{"type":"string","enum":["pass","fail","review"]},"required":false,"name":"result","in":"query"},{"schema":{"type":"string","enum":["ai","human","hybrid"]},"required":false,"name":"evaluator_type","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"maximum":100},"required":false,"name":"min_percentage","in":"query"},{"schema":{"type":["number","null"],"minimum":0,"maximum":100},"required":false,"name":"max_percentage","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"from_date","in":"query"},{"schema":{"type":"string","format":"date-time"},"required":false,"name":"to_date","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|percentage_score)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"call_id":{"type":"string","format":"uuid"},"rubric_id":{"type":["string","null"],"format":"uuid"},"evaluator_type":{"type":"string","enum":["ai","human","hybrid"]},"overall_score":{"type":["number","null"]},"max_possible_score":{"type":["number","null"]},"percentage_score":{"type":["number","null"]},"result":{"type":["string","null"],"enum":["pass","fail","review"]},"criteria_scores":{"type":"array","items":{"type":"object","properties":{"criterion_name":{"type":"string"},"criterion_id":{"type":"string"},"score":{"type":"number"},"max_score":{"type":"number"},"result":{"type":"string","enum":["pass","fail","review"]},"evidence":{"type":"string"},"transcript_index":{"type":"integer"},"notes":{"type":"string"}},"required":["criterion_name","score","max_score","result","evidence","notes"]}},"ai_notes":{"type":["string","null"]},"reviewed_by":{"type":["string","null"],"format":"uuid"},"reviewed_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","call_id","rubric_id","evaluator_type","overall_score","max_possible_score","percentage_score","result","criteria_scores","ai_notes","reviewed_by","reviewed_at","created_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/scorecards/{id}":{"get":{"tags":["Scorecards"],"summary":"Get a scorecard","description":"Required scope: `scorecards:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"scorecards:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"call_id":{"type":"string","format":"uuid"},"rubric_id":{"type":["string","null"],"format":"uuid"},"evaluator_type":{"type":"string","enum":["ai","human","hybrid"]},"overall_score":{"type":["number","null"]},"max_possible_score":{"type":["number","null"]},"percentage_score":{"type":["number","null"]},"result":{"type":["string","null"],"enum":["pass","fail","review"]},"criteria_scores":{"type":"array","items":{"type":"object","properties":{"criterion_name":{"type":"string"},"criterion_id":{"type":"string"},"score":{"type":"number"},"max_score":{"type":"number"},"result":{"type":"string","enum":["pass","fail","review"]},"evidence":{"type":"string"},"transcript_index":{"type":"integer"},"notes":{"type":"string"}},"required":["criterion_name","score","max_score","result","evidence","notes"]}},"ai_notes":{"type":["string","null"]},"reviewed_by":{"type":["string","null"],"format":"uuid"},"reviewed_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","call_id","rubric_id","evaluator_type","overall_score","max_possible_score","percentage_score","result","criteria_scores","ai_notes","reviewed_by","reviewed_at","created_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chat_widgets":{"get":{"tags":["Chat Widgets"],"summary":"List chat widgets","description":"Required scope: `chat_widgets:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"chat_widgets:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":["boolean","null"]},"required":false,"name":"is_active","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|updated_at|name)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"ai_agent_id":{"type":["string","null"],"format":"uuid"},"primary_color":{"type":["string","null"]},"position":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"placeholder_text":{"type":["string","null"]},"brand_name":{"type":["string","null"]},"brand_logo_url":{"type":["string","null"]},"form_enabled":{"type":"boolean"},"form_title":{"type":["string","null"]},"form_fields":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"form_submit_label":{"type":["string","null"]},"allowed_domains":{"type":["array","null"],"items":{"type":"string"}},"is_active":{"type":"boolean"},"launcher_style":{"type":["string","null"]},"launcher_label":{"type":["string","null"]},"subtitle":{"type":["string","null"]},"theme":{"type":["string","null"]},"offset_x":{"type":["integer","null"]},"offset_y":{"type":["integer","null"]},"auto_open_delay":{"type":["integer","null"]},"video_avatar_agent_id":{"type":["string","null"],"format":"uuid"},"embed_key":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","ai_agent_id","primary_color","position","greeting_message","placeholder_text","brand_name","brand_logo_url","form_enabled","form_title","form_fields","form_submit_label","allowed_domains","is_active","launcher_style","launcher_label","subtitle","theme","offset_x","offset_y","auto_open_delay","video_avatar_agent_id","embed_key","created_by","created_at","updated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Chat Widgets"],"summary":"Create a chat widget","description":"Required scope: `chat_widgets:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"chat_widgets:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"ai_agent_id":{"type":["string","null"],"format":"uuid"},"primary_color":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"greeting_message":{"type":["string","null"],"maxLength":2000},"placeholder_text":{"type":["string","null"],"maxLength":200},"brand_name":{"type":["string","null"],"maxLength":100},"brand_logo_url":{"type":["string","null"],"format":"uri"},"form_enabled":{"type":"boolean"},"form_title":{"type":["string","null"],"maxLength":200},"form_fields":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}},"maxItems":50},"form_submit_label":{"type":["string","null"],"maxLength":100},"allowed_domains":{"type":["array","null"],"items":{"type":"string","minLength":1,"maxLength":255},"maxItems":50},"is_active":{"type":"boolean"},"launcher_style":{"type":"string","enum":["bubble","pill"]},"launcher_label":{"type":["string","null"],"maxLength":60},"subtitle":{"type":["string","null"],"maxLength":140},"theme":{"type":"string","enum":["auto","light","dark"]},"offset_x":{"type":"integer","minimum":0,"maximum":400},"offset_y":{"type":"integer","minimum":0,"maximum":400},"auto_open_delay":{"type":["integer","null"],"minimum":0,"maximum":600},"video_avatar_agent_id":{"type":["string","null"],"format":"uuid"}},"required":["name"]}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"ai_agent_id":{"type":["string","null"],"format":"uuid"},"primary_color":{"type":["string","null"]},"position":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"placeholder_text":{"type":["string","null"]},"brand_name":{"type":["string","null"]},"brand_logo_url":{"type":["string","null"]},"form_enabled":{"type":"boolean"},"form_title":{"type":["string","null"]},"form_fields":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"form_submit_label":{"type":["string","null"]},"allowed_domains":{"type":["array","null"],"items":{"type":"string"}},"is_active":{"type":"boolean"},"launcher_style":{"type":["string","null"]},"launcher_label":{"type":["string","null"]},"subtitle":{"type":["string","null"]},"theme":{"type":["string","null"]},"offset_x":{"type":["integer","null"]},"offset_y":{"type":["integer","null"]},"auto_open_delay":{"type":["integer","null"]},"video_avatar_agent_id":{"type":["string","null"],"format":"uuid"},"embed_key":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","ai_agent_id","primary_color","position","greeting_message","placeholder_text","brand_name","brand_logo_url","form_enabled","form_title","form_fields","form_submit_label","allowed_domains","is_active","launcher_style","launcher_label","subtitle","theme","offset_x","offset_y","auto_open_delay","video_avatar_agent_id","embed_key","created_by","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/chat_widgets/{id}":{"get":{"tags":["Chat Widgets"],"summary":"Get a chat widget","description":"Required scope: `chat_widgets:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"chat_widgets:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"ai_agent_id":{"type":["string","null"],"format":"uuid"},"primary_color":{"type":["string","null"]},"position":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"placeholder_text":{"type":["string","null"]},"brand_name":{"type":["string","null"]},"brand_logo_url":{"type":["string","null"]},"form_enabled":{"type":"boolean"},"form_title":{"type":["string","null"]},"form_fields":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"form_submit_label":{"type":["string","null"]},"allowed_domains":{"type":["array","null"],"items":{"type":"string"}},"is_active":{"type":"boolean"},"launcher_style":{"type":["string","null"]},"launcher_label":{"type":["string","null"]},"subtitle":{"type":["string","null"]},"theme":{"type":["string","null"]},"offset_x":{"type":["integer","null"]},"offset_y":{"type":["integer","null"]},"auto_open_delay":{"type":["integer","null"]},"video_avatar_agent_id":{"type":["string","null"],"format":"uuid"},"embed_key":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","ai_agent_id","primary_color","position","greeting_message","placeholder_text","brand_name","brand_logo_url","form_enabled","form_title","form_fields","form_submit_label","allowed_domains","is_active","launcher_style","launcher_label","subtitle","theme","offset_x","offset_y","auto_open_delay","video_avatar_agent_id","embed_key","created_by","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Chat Widgets"],"summary":"Update a chat widget","description":"Required scope: `chat_widgets:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"chat_widgets:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","minLength":1,"maxLength":200},"ai_agent_id":{"type":["string","null"],"format":"uuid"},"primary_color":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"position":{"type":["string","null"],"enum":["bottom-right","bottom-left","top-right","top-left"]},"greeting_message":{"type":["string","null"],"maxLength":2000},"placeholder_text":{"type":["string","null"],"maxLength":200},"brand_name":{"type":["string","null"],"maxLength":100},"brand_logo_url":{"type":["string","null"],"format":"uri"},"form_enabled":{"type":"boolean"},"form_title":{"type":["string","null"],"maxLength":200},"form_fields":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}},"maxItems":50},"form_submit_label":{"type":["string","null"],"maxLength":100},"allowed_domains":{"type":["array","null"],"items":{"type":"string","minLength":1,"maxLength":255},"maxItems":50},"is_active":{"type":"boolean"},"launcher_style":{"type":"string","enum":["bubble","pill"]},"launcher_label":{"type":["string","null"],"maxLength":60},"subtitle":{"type":["string","null"],"maxLength":140},"theme":{"type":"string","enum":["auto","light","dark"]},"offset_x":{"type":"integer","minimum":0,"maximum":400},"offset_y":{"type":"integer","minimum":0,"maximum":400},"auto_open_delay":{"type":["integer","null"],"minimum":0,"maximum":600},"video_avatar_agent_id":{"type":["string","null"],"format":"uuid"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"organization_id":{"type":"string","format":"uuid"},"name":{"type":"string"},"ai_agent_id":{"type":["string","null"],"format":"uuid"},"primary_color":{"type":["string","null"]},"position":{"type":["string","null"]},"greeting_message":{"type":["string","null"]},"placeholder_text":{"type":["string","null"]},"brand_name":{"type":["string","null"]},"brand_logo_url":{"type":["string","null"]},"form_enabled":{"type":"boolean"},"form_title":{"type":["string","null"]},"form_fields":{"type":["array","null"],"items":{"type":"object","additionalProperties":{}}},"form_submit_label":{"type":["string","null"]},"allowed_domains":{"type":["array","null"],"items":{"type":"string"}},"is_active":{"type":"boolean"},"launcher_style":{"type":["string","null"]},"launcher_label":{"type":["string","null"]},"subtitle":{"type":["string","null"]},"theme":{"type":["string","null"]},"offset_x":{"type":["integer","null"]},"offset_y":{"type":["integer","null"]},"auto_open_delay":{"type":["integer","null"]},"video_avatar_agent_id":{"type":["string","null"],"format":"uuid"},"embed_key":{"type":"string"},"created_by":{"type":["string","null"],"format":"uuid"},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}},"required":["id","organization_id","name","ai_agent_id","primary_color","position","greeting_message","placeholder_text","brand_name","brand_logo_url","form_enabled","form_title","form_fields","form_submit_label","allowed_domains","is_active","launcher_style","launcher_label","subtitle","theme","offset_x","offset_y","auto_open_delay","video_avatar_agent_id","embed_key","created_by","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Chat Widgets"],"summary":"Delete a chat widget","description":"Required scope: `chat_widgets:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"chat_widgets:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Widget has conversations","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/landing_pages":{"get":{"tags":["Landing Pages"],"summary":"List landing pages","description":"Required scope: `landing_pages:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"landing_pages:read","parameters":[{"schema":{"type":"integer","minimum":1,"default":1},"required":false,"name":"page","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":20},"required":false,"name":"page_size","in":"query"},{"schema":{"type":"string","enum":["provisioning","active","paused","expired"]},"required":false,"name":"status","in":"query"},{"schema":{"type":"string","minLength":3,"maxLength":63,"pattern":"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"},"required":false,"name":"subdomain","in":"query"},{"schema":{"type":"string","minLength":1,"maxLength":200},"required":false,"name":"search","in":"query"},{"schema":{"type":"string","pattern":"^(created_at|updated_at|subdomain|company_name)(:asc|:desc)?$"},"required":false,"name":"sort","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"subdomain":{"type":"string"},"company_name":{"type":["string","null"]},"logo_url":{"type":["string","null"]},"favicon_url":{"type":["string","null"]},"thumbnail_url":{"type":["string","null"]},"primary_color":{"type":["string","null"]},"secondary_color":{"type":["string","null"]},"html_source":{"type":["string","null"]},"html_compiled":{"type":["string","null"]},"scraped_assets":{"type":["object","null"],"additionalProperties":{}},"reference_urls":{"type":"array","items":{"type":"string"}},"industry":{"type":["string","null"]},"webhook_url":{"type":["string","null"]},"webhook_token":{"type":["string","null"]},"chat_widget_embed_key":{"type":["string","null"]},"phone_number":{"type":["string","null"]},"status":{"type":"string","enum":["provisioning","active","paused","expired"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_migrated_at":{"type":["string","null"],"format":"date-time"}},"required":["id","org_id","subdomain","company_name","logo_url","favicon_url","thumbnail_url","primary_color","secondary_color","html_source","html_compiled","scraped_assets","reference_urls","industry","webhook_url","webhook_token","chat_widget_embed_key","phone_number","status","created_at","updated_at","last_migrated_at"]}},"pagination":{"type":"object","properties":{"page":{"type":"integer"},"page_size":{"type":"integer"},"total":{"type":"integer"},"total_pages":{"type":"integer"}},"required":["page","page_size","total","total_pages"]}},"required":["success","data","pagination"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Landing Pages"],"summary":"Create a landing page","description":"Required scope: `landing_pages:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"landing_pages:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"subdomain":{"type":"string","minLength":3,"maxLength":63,"pattern":"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$"},"company_name":{"type":"string","minLength":1,"maxLength":200},"html_source":{"type":"string"},"html_compiled":{"type":"string"},"scraped_assets":{"type":"object","additionalProperties":{}},"reference_urls":{"type":"array","items":{"type":"string"}},"logo_url":{"type":"string","format":"uri"},"favicon_url":{"type":"string","format":"uri"},"primary_color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"secondary_color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"industry":{"type":"string","minLength":1,"maxLength":60},"chat_widget_embed_key":{"type":"string","pattern":"^[a-f0-9]{16,64}$"},"phone_number":{"type":"string","minLength":1,"maxLength":20},"status":{"type":"string","enum":["provisioning","active","paused","expired"]}},"required":["subdomain","company_name"]}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"subdomain":{"type":"string"},"company_name":{"type":["string","null"]},"logo_url":{"type":["string","null"]},"favicon_url":{"type":["string","null"]},"thumbnail_url":{"type":["string","null"]},"primary_color":{"type":["string","null"]},"secondary_color":{"type":["string","null"]},"html_source":{"type":["string","null"]},"html_compiled":{"type":["string","null"]},"scraped_assets":{"type":["object","null"],"additionalProperties":{}},"reference_urls":{"type":"array","items":{"type":"string"}},"industry":{"type":["string","null"]},"webhook_url":{"type":["string","null"]},"webhook_token":{"type":["string","null"]},"chat_widget_embed_key":{"type":["string","null"]},"phone_number":{"type":["string","null"]},"status":{"type":"string","enum":["provisioning","active","paused","expired"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_migrated_at":{"type":["string","null"],"format":"date-time"}},"required":["id","org_id","subdomain","company_name","logo_url","favicon_url","thumbnail_url","primary_color","secondary_color","html_source","html_compiled","scraped_assets","reference_urls","industry","webhook_url","webhook_token","chat_widget_embed_key","phone_number","status","created_at","updated_at","last_migrated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/landing_pages/{id}":{"get":{"tags":["Landing Pages"],"summary":"Get a landing page","description":"Required scope: `landing_pages:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"landing_pages:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"subdomain":{"type":"string"},"company_name":{"type":["string","null"]},"logo_url":{"type":["string","null"]},"favicon_url":{"type":["string","null"]},"thumbnail_url":{"type":["string","null"]},"primary_color":{"type":["string","null"]},"secondary_color":{"type":["string","null"]},"html_source":{"type":["string","null"]},"html_compiled":{"type":["string","null"]},"scraped_assets":{"type":["object","null"],"additionalProperties":{}},"reference_urls":{"type":"array","items":{"type":"string"}},"industry":{"type":["string","null"]},"webhook_url":{"type":["string","null"]},"webhook_token":{"type":["string","null"]},"chat_widget_embed_key":{"type":["string","null"]},"phone_number":{"type":["string","null"]},"status":{"type":"string","enum":["provisioning","active","paused","expired"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_migrated_at":{"type":["string","null"],"format":"date-time"}},"required":["id","org_id","subdomain","company_name","logo_url","favicon_url","thumbnail_url","primary_color","secondary_color","html_source","html_compiled","scraped_assets","reference_urls","industry","webhook_url","webhook_token","chat_widget_embed_key","phone_number","status","created_at","updated_at","last_migrated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Landing Pages"],"summary":"Update a landing page","description":"Required scope: `landing_pages:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"landing_pages:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"company_name":{"type":"string","minLength":1,"maxLength":200},"logo_url":{"type":["string","null"],"format":"uri"},"favicon_url":{"type":["string","null"],"format":"uri"},"primary_color":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"secondary_color":{"type":["string","null"],"pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"industry":{"type":["string","null"],"minLength":1,"maxLength":60},"chat_widget_embed_key":{"type":["string","null"],"pattern":"^[a-f0-9]{16,64}$"},"phone_number":{"type":["string","null"],"minLength":1,"maxLength":20},"status":{"type":"string","enum":["provisioning","active","paused","expired"]}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"org_id":{"type":"string","format":"uuid"},"subdomain":{"type":"string"},"company_name":{"type":["string","null"]},"logo_url":{"type":["string","null"]},"favicon_url":{"type":["string","null"]},"thumbnail_url":{"type":["string","null"]},"primary_color":{"type":["string","null"]},"secondary_color":{"type":["string","null"]},"html_source":{"type":["string","null"]},"html_compiled":{"type":["string","null"]},"scraped_assets":{"type":["object","null"],"additionalProperties":{}},"reference_urls":{"type":"array","items":{"type":"string"}},"industry":{"type":["string","null"]},"webhook_url":{"type":["string","null"]},"webhook_token":{"type":["string","null"]},"chat_widget_embed_key":{"type":["string","null"]},"phone_number":{"type":["string","null"]},"status":{"type":"string","enum":["provisioning","active","paused","expired"]},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"},"last_migrated_at":{"type":["string","null"],"format":"date-time"}},"required":["id","org_id","subdomain","company_name","logo_url","favicon_url","thumbnail_url","primary_color","secondary_color","html_source","html_compiled","scraped_assets","reference_urls","industry","webhook_url","webhook_token","chat_widget_embed_key","phone_number","status","created_at","updated_at","last_migrated_at"]}},"required":["success","data"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Landing Pages"],"summary":"Delete a landing page","description":"Required scope: `landing_pages:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"landing_pages:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{}},"required":["success"]}}}},"400":{"description":"Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}