{"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":"https://api.aivi.io/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":"Documents"},{"name":"Events"},{"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":true,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","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"}}}},"409":{"description":"client_has_own_plan: the client pays for its own AIVI plan; set its price from the dashboard","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":true,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","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 (insufficient_funds); or plan_required: The organization's free trial has ended and it has no plan. Choose a plan in Settings → Billing.","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",null]},"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",null]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number",null]},"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",null]},"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",null]},"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","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",null]},"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",null]},"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",null]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number",null]},"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",null]},"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",null]},"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",null]},"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",null]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number",null]},"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",null]},"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",null]},"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",null]},"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",null]},"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",null]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number",null]},"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",null]},"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",null]},"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",null]},"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",null]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number",null]},"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",null]},"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",null]},"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","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",null]},"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",null]},"transfer_caller_id_mode":{"type":["string","null"],"enum":["agent_number","contact_number",null]},"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",null]},"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",null]},"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"},{"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"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":{}},"mode":{"type":"string","enum":["live","preview"],"description":"live (default) runs the Skill. preview runs it in shadow — nothing is done — and returns would_contact: the steps that would reach the contact"},"outreach":{"anyOf":[{"type":"string","enum":["none"]},{"type":"object","properties":{"channels":{"type":"array","items":{"type":"string","enum":["sms","email","voice"]},"maxItems":3},"max_sends":{"type":"integer","minimum":1,"maximum":25}},"required":["channels","max_sends"]}],"description":"Limit customer contact from inside the Skill: \"none\", or the channels and number of sends allowed (never more than your own channel scopes). Omitted: your channel scopes, unlimited when you hold messages:write, emails:write and calls:initiate, else 25 sends"}}}}}},"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: the expert, or the contact_id / call_id (for a signed-in user: one they can't see); or: Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"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"}}}}}}},"/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":{}},"timezone":{"type":["string","null"],"description":"The contact's IANA timezone, e.g. America/Chicago; null when unknown."},"timezone_source":{"type":["string","null"],"enum":["manual","caller","integration","inferred",null],"description":"Where the timezone came from: manual (set by a person or the API), caller (the contact said it), integration (a CRM sync), inferred (guessed from address or phone)."},"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",null]}},"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",null]}},"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","timezone","timezone_source","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":{},"additionalProperties":{}},"timezone":{"type":"string","maxLength":64},"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":{}},"timezone":{"type":["string","null"],"description":"The contact's IANA timezone, e.g. America/Chicago; null when unknown."},"timezone_source":{"type":["string","null"],"enum":["manual","caller","integration","inferred",null],"description":"Where the timezone came from: manual (set by a person or the API), caller (the contact said it), integration (a CRM sync), inferred (guessed from address or phone)."},"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",null]}},"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",null]}},"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","timezone","timezone_source","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"}}}},"422":{"description":"assignee_not_member: assigned_to is not a member of this organization","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":{}},"timezone":{"type":["string","null"],"description":"The contact's IANA timezone, e.g. America/Chicago; null when unknown."},"timezone_source":{"type":["string","null"],"enum":["manual","caller","integration","inferred",null],"description":"Where the timezone came from: manual (set by a person or the API), caller (the contact said it), integration (a CRM sync), inferred (guessed from address or phone)."},"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",null]}},"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",null]}},"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","timezone","timezone_source","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":{},"additionalProperties":{}},"timezone":{"type":["string","null"],"maxLength":64},"status":{"type":"string","enum":["active","inactive","scrubbed","followup","deceased"]},"tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":64},"maxItems":50},"remove_tags":{"type":"array","items":{"type":"string","minLength":1,"maxLength":100},"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":{}},"timezone":{"type":["string","null"],"description":"The contact's IANA timezone, e.g. America/Chicago; null when unknown."},"timezone_source":{"type":["string","null"],"enum":["manual","caller","integration","inferred",null],"description":"Where the timezone came from: manual (set by a person or the API), caller (the contact said it), integration (a CRM sync), inferred (guessed from address or phone)."},"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",null]}},"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",null]}},"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","timezone","timezone_source","status","tags","custom_fields","assigned_to","source","last_contacted_at","created_at","updated_at","phones","emails"]}},"required":["success","data"]}}}},"400":{"description":"dnc_tag_managed: remove_tags contains DNC; revoke Do Not Contact with DELETE /contacts/{id}/dnc; reserved_tag: tags adds DNC to a contact that is not Do Not Contact; use POST /contacts/{id}/dnc; or: 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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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":"assignee_not_member: assigned_to is not a member of this organization","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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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"}}}},"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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/score":{"post":{"tags":["Insights"],"summary":"Score a lead (0-100) with the recommended next action; charged once (AIVI Insights price)","description":"Required scope: `insights:enrich`","security":[{"bearerAuth":[]}],"x-aivi-scope":"insights:enrich","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"score":{"type":"integer","minimum":0,"maximum":100},"tier":{"type":"string","enum":["tier_1","tier_2","tier_3"]},"lead_tier":{"type":["string","null"]},"lead_tier_label":{"type":["string","null"]},"recommended_action":{"type":"string"},"recommended_channel":{"type":"string"},"recommended_timing":{"type":["number","null"]},"action_scores":{"type":"object","additionalProperties":{"type":"number"}},"contact_found":{"type":"boolean","enum":[true]},"call_history_count":{"type":"integer"},"call_intelligence":{"type":"array","items":{"type":"object","properties":{"outcome":{"type":"string"},"sentiment":{"type":"string"},"topics":{},"date":{"type":"string"}},"required":["outcome","sentiment","date"]}},"insights_available":{"type":"boolean"},"insights":{"type":["object","null"],"additionalProperties":{}},"insights_message":{"type":["string","null"]},"cost_cents":{"type":"integer"}},"required":["contact_id","score","tier","lead_tier","lead_tier_label","recommended_action","recommended_channel","recommended_timing","action_scores","contact_found","call_history_count","call_intelligence","insights_available","insights","insights_message","cost_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"}}}},"402":{"description":"insufficient_funds","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"org_suspended; 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"}}}},"409":{"description":"Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"contact_has_no_phone; 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"}}}},"503":{"description":"billing_unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/qualify":{"post":{"tags":["Insights"],"summary":"Qualify a lead with AIVI Insights: tier and auto-reject; a cached result (< 30 days) and an auto-reject are free, otherwise charged once","description":"Required scope: `insights:enrich`","security":[{"bearerAuth":[]}],"x-aivi-scope":"insights:enrich","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"qualified":{"type":"boolean"},"auto_reject":{"type":"boolean"},"auto_reject_reason":{"type":["string","null"],"enum":["litigator","invalid_phone","disconnected","failed_qualification_criteria",null]},"lead_tier":{"type":"string"},"lead_tier_label":{"type":"string"},"phone":{"type":"object","additionalProperties":{}},"economic":{"type":"object","additionalProperties":{}},"recommended_sequence":{"type":["string","null"],"enum":["one_day","three_day","twelve_day",null]},"tier_criteria_met":{"type":"array","items":{}},"cost_cents":{"type":"integer"},"cached":{"type":"boolean"},"note":{"type":"string"}},"required":["contact_id","qualified","auto_reject","auto_reject_reason","lead_tier","lead_tier_label","phone","economic","recommended_sequence","tier_criteria_met","cost_cents","cached","note"]}},"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":"org_suspended; 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"}}}},"409":{"description":"insights_unavailable: AIVI Insights is not enabled for the organization; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"contact_has_no_phone; no_enrichment_data; 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"}}}},"502":{"description":"enrichment_error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"billing_unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/next_action":{"get":{"tags":["Insights"],"summary":"Recommended next action (channel and timing) for a contact; free","description":"Required scope: `contacts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"integer","minimum":1,"maximum":1000},"required":false,"name":"sequence_step","in":"query"},{"schema":{"type":"string","format":"uuid"},"required":false,"name":"enrollment_id","in":"query"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"recommended_action":{"type":["string","null"]},"channel":{"type":["string","null"]},"wait_ms":{"type":["number","null"]},"is_compound":{"type":"boolean"},"compound_then_channel":{"type":["string","null"]},"action_scores":{"type":"object","additionalProperties":{"type":"number"}},"confidence":{"type":"number"},"is_exploring":{"type":"boolean"},"profile_id":{"type":["string","null"]},"config_overrides":{},"enrollment_id":{"type":"string"},"sequence_step":{"type":"integer"},"cost_cents":{"type":"number","enum":[0]}},"required":["contact_id","recommended_action","channel","wait_ms","is_compound","compound_then_channel","action_scores","confidence","is_exploring","profile_id","enrollment_id","sequence_step","cost_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"}}}},"404":{"description":"Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"contact_has_no_phone","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"ml_unavailable","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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/block":{"post":{"tags":["Contacts"],"summary":"Block a contact from all calls, texts and emails (cancels its active workflow enrollments; the body is optional: omit it or send {})","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","maxLength":500}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"blocked":{"type":"boolean"}},"required":["blocked"]}},"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":"Unblock a contact (the body is optional: omit it or send {})","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","maxLength":500}},"additionalProperties":false}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"blocked":{"type":"boolean"}},"required":["blocked"]}},"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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/notes":{"get":{"tags":["Contacts"],"summary":"List a contact's notes (newest first)","description":"Required scope: `contacts:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"contacts:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"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"}],"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","format":"uuid"},"body":{"type":"string"},"author_user_id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","body","author_user_id","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"}}}},"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 note 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":{"body":{"type":"string","minLength":1,"maxLength":5000}},"required":["body"],"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"},"contact_id":{"type":"string","format":"uuid"},"body":{"type":"string"},"author_user_id":{"type":"string","format":"uuid"},"created_at":{"type":"string","format":"date-time"}},"required":["id","contact_id","body","author_user_id","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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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":"note_author_required: the API key has no creating user to attribute the note to","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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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"}}}},"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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; 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"}}}},"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",null]},"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","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"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"]}}}},"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":"contact_missing_phone: no to_number was given and the contact has no phone number on file (or the stored value is not a dialable number); or: 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; plan_required: The organization's free trial has ended and it has no plan. Choose a plan in Settings → Billing. Incoming calls and texts are not affected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; dnc_blocked: the contact or the dialed number is on the Do Not Contact list (voice); contact_blocked: the contact (or, without contact_id, the number) is blocked from all communication; rnd_suspended: the contact's consent certificate is suspended or revoked, or the number failed reassigned-number (RND) re-validation. Nothing is held, written or dialed; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found: the contact is not one of the organization's (for a signed-in user: not one they can see)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Agent not active or not ready; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"no_sender_number: no from_phone_number_id was given and the agent has no usable outbound number; phone_not_ai_enabled: from_phone_number_id is not AI-enabled; 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"}}}},"503":{"description":"precall_unavailable: the do-not-contact check could not be completed, the call was not placed (retry after Retry-After)","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",null]},"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","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"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","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":"contact_missing_phone: the contact has no phone number on file (or the stored value is not a dialable number); or: 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; plan_required: The organization's free trial has ended and it has no plan. Choose a plan in Settings → Billing. Incoming calls and texts are not affected.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found: the contact is not one of the organization's (for a signed-in user: not one they can see)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"no_sender_number: no from_number was given and the organization has no usable number to send from (set a default number); compliance_required: the sender number needs A2P 10DLC registration; 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"}}}}}}},"/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","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"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":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found: the contact is not one of the organization's (for a signed-in user: not one they can see)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"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"}}}}}}},"/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","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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"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"}}}},"409":{"description":"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"}}}}}}},"/workflows/generate":{"post":{"tags":["Workflows"],"summary":"Build a ready-to-activate workflow from a description (AI; saves nothing). Returns questions until every choice is made","description":"Required scope: `workflows:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:write","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"description":{"type":"string","minLength":1,"maxLength":4000,"description":"What the workflow should do, in plain language: trigger, steps, message text, timing"},"trigger_type":{"type":"string","enum":["manual","contact_created","contact_updated","webhook","date_time","meta_lead","qa_evaluation.completed","moment_detected","call_completed","message_received","tag_added","document_received","document_reviewed","checklist_completed","email_received","email_opened"],"description":"The trigger to use. Omitted: the generator chooses one"},"details":{"type":"string","maxLength":4000,"description":"Extra details"},"answers":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","minLength":1,"maxLength":100,"description":"The id of the question being answered (from a previous needs_input response)"},"question":{"type":"string","maxLength":1000,"description":"The question's text, as returned"},"answer":{"anyOf":[{"type":"string","maxLength":4000},{"type":"array","items":{"type":"string","maxLength":500},"maxItems":50}],"description":"The chosen option value (single), the chosen values (multi), or free text (text)"}},"required":["id","question","answer"]},"maxItems":40,"description":"Every answer given so far. Send the same description again with all answers until status is ready or blocked"},"base_workflow_id":{"type":"string","format":"uuid","description":"Change this saved workflow instead of building a new one: the description says what to change; every other step, setting and account choice is kept. The result is the whole workflow after the change (save it with PUT /workflows/{id})"}},"required":["description"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"oneOf":[{"type":"object","properties":{"status":{"type":"string","enum":["needs_input"]},"questions":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"question":{"type":"string"},"type":{"type":"string","enum":["single","multi","text"],"description":"single / multi: answer with option value(s); text: free text (an id when the caller can't list the options)"},"options":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string"},"label":{"type":"string"}},"required":["value","label"]}},"steps":{"type":"array","items":{"type":"string"},"description":"The planned steps this answer applies to"}},"required":["id","question","type","steps"]},"description":"Ask the user these, then call again with the same description and all answers"},"notes":{"type":"array","items":{"type":"string"},"description":"Choices made automatically (the organization had only one option)"}},"required":["status","questions","notes"]},{"type":"object","properties":{"status":{"type":"string","enum":["blocked"]},"blockers":{"type":"array","items":{"type":"string"},"description":"Why the workflow can't be built yet (e.g. no AI agent exists), in plain sentences"}},"required":["status","blockers"]},{"type":"object","properties":{"status":{"type":"string","enum":["ready"]},"workflow":{"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"],"description":"A POST /workflows body, ready to activate; create it with POST /workflows"},"notes":{"type":"array","items":{"type":"string"},"description":"Choices made automatically (the organization had only one option)"}},"required":["status","workflow","notes"]}]}},"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: more than 30 AI generations in 10 minutes for this key or user; or: Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"generation_failed: the generator could not produce a workflow that is ready to activate (the message lists why), or is unavailable; retry","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/workflows/{id}":{"get":{"tags":["Workflows"],"summary":"Get a workflow (check=true adds readiness: what would stop it from running)","description":"Required scope: `workflows:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"anyOf":[{"type":"string","enum":["true"]},{"type":"string","enum":["false"]}],"description":"true adds `readiness`: { ready, problems: [{ node_key, message }] } — steps the trigger never reaches, missing branches, settings a step needs to run, ids that are not the organization's, and caller-ID rules. Default false."},"required":false,"description":"true adds `readiness`: { ready, problems: [{ node_key, message }] } — steps the trigger never reaches, missing branches, settings a step needs to run, ids that are not the organization's, and caller-ID rules. Default false.","name":"check","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"}}}},"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"},{"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"contact_id":{"type":"string","format":"uuid"},"options":{"type":"object","properties":{"appointment_booking_add_on":{"type":"boolean"},"voice_id":{"type":"string","minLength":1,"maxLength":200},"outbound_number":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$","description":"Caller ID override; must be a number the organization holds"},"transfer_number":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"}},"additionalProperties":false}},"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"}}}},"402":{"description":"insufficient_funds (premium workflow)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"forbidden: a signed-in user (OAuth) can see the contact, but their role only lets them change contacts they created or are assigned to; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"not_found: the workflow, or the contact (for a signed-in user: one they can't see); or: Not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"outbound_number_not_owned; 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"}}}}}}},"/sequences":{"get":{"tags":["Workflows"],"summary":"List the outreach sequences, the workflow each enrolls into and its price","description":"Required scope: `workflows:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"workflows:read","responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"array","items":{"type":"object","properties":{"sequence_type":{"type":"string","enum":["one_day","three_day","twelve_day"]},"template_name":{"type":"string"},"list_price_cents":{"type":"integer"},"booking_addon_cents":{"type":"integer"},"available":{"type":"boolean","description":"An active workflow for this sequence exists in the organization"},"workflow_id":{"type":["string","null"],"format":"uuid"},"workflow_name":{"type":["string","null"]},"price_cents":{"type":["integer","null"],"description":"What one enrollment costs (the installed template's per-lead price); null when the workflow bills per call/SMS"},"billing":{"type":["string","null"],"enum":["premium_enrollment","per_action",null]}},"required":["sequence_type","template_name","list_price_cents","booking_addon_cents","available","workflow_id","workflow_name","price_cents","billing"]}}},"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"}}}}}}},"/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",null]},"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",null]},"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",null]},"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",null]},"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"}}}}}}},"/landing_pages/generate":{"post":{"tags":["Landing Pages"],"summary":"Generate a branded landing page from a website (asynchronous job: poll GET /landing_pages/jobs/{id})","description":"Required scope: `landing_pages:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"landing_pages: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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","maxLength":2048,"format":"uri","description":"The prospect's website to scrape"},"subdomain":{"type":"string","minLength":3,"maxLength":63,"pattern":"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$","description":"Hosted at {subdomain}.aivisites.io"},"reference_urls":{"type":"array","items":{"type":"string","maxLength":2048,"format":"uri"},"maxItems":5},"primary_color":{"type":"string","pattern":"^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$"},"logo_url":{"type":"string","maxLength":2048,"format":"uri"},"industry":{"type":"string","minLength":1,"maxLength":120},"user_message":{"type":"string","minLength":1,"maxLength":4000},"chat_widget":{"type":"string","enum":["none","existing","create"],"default":"none"},"chat_widget_id":{"type":"string","format":"uuid"}},"required":["url","subdomain"],"additionalProperties":false}}}},"responses":{"202":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"job_id":{"type":"string","format":"uuid"},"state":{"type":"string","enum":["scraping","generating","deployed","failed"]},"subdomain":{"type":"string"},"landing_page_id":{"type":["string","null"],"format":"uuid"},"landing_page_url":{"type":["string","null"]},"chat_widget_embed_key":{"type":["string","null"]},"error":{"type":["string","null"]},"created_at":{"type":"string"},"updated_at":{"type":"string"},"poll_after_ms":{"type":["integer","null"]}},"required":["job_id","state","subdomain","landing_page_id","landing_page_url","chat_widget_embed_key","error","created_at","updated_at","poll_after_ms"]}},"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":"chat_widget_not_found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"subdomain_taken; or: Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"missing_caller_identity: the API key has no creating user; 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"}}}},"503":{"description":"scrape_unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/landing_pages/jobs/{id}":{"get":{"tags":["Landing Pages"],"summary":"Get a landing page generation job","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":{"job_id":{"type":"string","format":"uuid"},"state":{"type":"string","enum":["scraping","generating","deployed","failed"]},"subdomain":{"type":"string"},"landing_page_id":{"type":["string","null"],"format":"uuid"},"landing_page_url":{"type":["string","null"]},"chat_widget_embed_key":{"type":["string","null"]},"error":{"type":["string","null"]},"created_at":{"type":"string"},"updated_at":{"type":"string"},"poll_after_ms":{"type":["integer","null"]}},"required":["job_id","state","subdomain","landing_page_id","landing_page_url","chat_widget_embed_key","error","created_at","updated_at","poll_after_ms"]}},"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"}}}}}}},"/document_types":{"get":{"tags":["Documents"],"summary":"List document types","description":"Required scope: `documents:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents:read","parameters":[{"schema":{"type":"string","enum":["true","false"],"default":"false"},"required":false,"name":"include_archived","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"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"},"contact_hint":{"type":["string","null"]},"aliases":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]}},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","key","name","contact_label","contact_hint","aliases","fields","rules","multi_file","review_mode","sort_order","active","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":"feature_not_enabled: lead documents are not enabled for this organization; or: 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":["Documents"],"summary":"Create a document type","description":"Required scope: `document_types:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"document_types: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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"name":{"type":"string","minLength":1,"maxLength":200},"contact_label":{"type":"string","minLength":1,"maxLength":200},"contact_hint":{"type":["string","null"],"maxLength":500},"aliases":{"type":"array","items":{"type":"string","minLength":1,"maxLength":100},"maxItems":50},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]},"maxItems":50,"default":[]},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]},"maxItems":50,"default":[]},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"}},"required":["key","name","contact_label"]}}}},"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"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"},"contact_hint":{"type":["string","null"]},"aliases":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]}},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","key","name","contact_label","contact_hint","aliases","fields","rules","multi_file","review_mode","sort_order","active","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"validation_error: the definition was refused (the message says why); or: 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":"feature_not_enabled; or: Missing scope or organization not accessible","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"conflict: a document type with this key already exists; 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"}}}}}}},"/document_types/{id}":{"get":{"tags":["Documents"],"summary":"Get a document type","description":"Required scope: `documents:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents: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"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"},"contact_hint":{"type":["string","null"]},"aliases":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]}},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","key","name","contact_label","contact_hint","aliases","fields","rules","multi_file","review_mode","sort_order","active","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":"feature_not_enabled; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Documents"],"summary":"Update a document type (active: true restores an archived one)","description":"Required scope: `document_types:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"document_types: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},"contact_label":{"type":"string","minLength":1,"maxLength":200},"contact_hint":{"type":["string","null"],"maxLength":500},"aliases":{"type":"array","items":{"type":"string","minLength":1,"maxLength":100},"maxItems":50},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]},"maxItems":50},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]},"maxItems":50},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"},"active":{"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"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"},"contact_hint":{"type":["string","null"]},"aliases":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]}},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","key","name","contact_label","contact_hint","aliases","fields","rules","multi_file","review_mode","sort_order","active","created_at","updated_at"]}},"required":["success","data"]}}}},"400":{"description":"validation_error: the definition was refused, or a key was sent (keys never change); or: 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":"feature_not_enabled; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Documents"],"summary":"Archive a document type","description":"Required scope: `document_types:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"document_types: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":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"},"contact_hint":{"type":["string","null"]},"aliases":{"type":"array","items":{"type":"string"}},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"label":{"type":"string","minLength":1},"type":{"type":"string","enum":["date","money","number","year","text","name"]},"required":{"type":"boolean","default":false},"sensitive":{"type":"boolean","default":false},"hint":{"type":"string","maxLength":500},"contactFieldId":{"type":"string","minLength":1}},"required":["key","label","type"]}},"rules":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$"},"kind":{"type":"string","enum":["max_age_days","document_year","not_expired","name_matches_contact","covers_recent_months","custom","matches_document"]},"severity":{"type":"string","enum":["fail","review"]},"label":{"type":"string","minLength":1},"params":{"type":"object","additionalProperties":{}}},"required":["id","kind","severity","label","params"]}},"multi_file":{"type":"boolean"},"review_mode":{"type":"string","enum":["auto","manual"]},"sort_order":{"type":"integer"},"active":{"type":"boolean"},"created_at":{"type":"string"},"updated_at":{"type":"string"}},"required":["id","key","name","contact_label","contact_hint","aliases","fields","rules","multi_file","review_mode","sort_order","active","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":"feature_not_enabled; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/documents":{"get":{"tags":["Documents"],"summary":"Get a contact's document checklist","description":"Required scope: `documents:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents: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":{"contact_id":{"type":"string","format":"uuid"},"checklist":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"opened_at":{"type":"string"},"closed_at":{"type":["string","null"]}},"required":["id","opened_at","closed_at"]},"complete":{"type":"boolean"},"outstanding_item_ids":{"type":"array","items":{"type":"string","format":"uuid"}},"items":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"type":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"}},"required":["id","key","name","contact_label"]},"status":{"type":"string","enum":["needed","reviewing","passed","failed","needs_review","waived"]},"status_changed_at":{"type":"string"},"reasons":{"type":"array","items":{"type":"string"},"description":"Plain-language reasons the contact is shown"},"promised_for":{"type":["string","null"],"description":"When the contact said they'd send it"},"contact_note":{"type":["string","null"]},"last_requested_at":{"type":["string","null"]},"request_count":{"type":"integer"},"files":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"file_name":{"type":"string"},"mime_type":{"type":["string","null"]},"status":{"type":"string"},"created_at":{"type":"string"}},"required":["id","file_name","mime_type","status","created_at"]}},"review":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"verdict":{"type":"string","enum":["passed","failed","needs_review"]},"source":{"type":"string","enum":["review","recheck","cross_check"]},"created_at":{"type":"string"},"rule_results":{"type":"array","items":{"type":"object","additionalProperties":{}}},"fields":{"type":"array","items":{"type":"object","properties":{"documentId":{"type":"string"},"fields":{"type":"object","additionalProperties":{"type":"object","properties":{"value":{"type":["string","null"]},"confidence":{"type":"number"}},"required":["value","confidence"]}}},"required":["documentId","fields"]}}},"required":["id","verdict","source","created_at","rule_results","fields"]}},"required":["id","type","status","status_changed_at","reasons","promised_for","contact_note","last_requested_at","request_count","files","review"]}},"page_link":{"type":["object","null"],"properties":{"url":{"type":"string"},"expires_at":{"type":"string"}},"required":["url","expires_at"],"description":"The contact's upload page"}},"required":["contact_id","checklist","complete","outstanding_item_ids","items","page_link"]}},"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":"feature_not_enabled; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Documents"],"summary":"Upload a document for a contact (base64 JSON, up to 10 MB)","description":"Required scope: `documents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents: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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"file_name":{"type":"string","minLength":1,"maxLength":255},"mime_type":{"type":"string","minLength":1,"description":"image/jpeg, image/png, image/webp or application/pdf"},"content_base64":{"type":"string","minLength":1,"description":"The file, base64-encoded (at most 10 MB decoded)"},"document_type_id":{"type":"string","format":"uuid","description":"File it onto this type's checklist item; omit to let it be sorted"}},"required":["file_name","mime_type","content_base64"]}}}},"responses":{"201":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"document_id":{"type":"string","format":"uuid"},"filing":{"type":"object","properties":{"status":{"type":"string","enum":["filed","pending_classification","skipped"]},"item_id":{"type":"string","format":"uuid"},"reason":{"type":"string"}},"required":["status"]}},"required":["document_id","filing"]}},"required":["success","data"]}}}},"400":{"description":"validation_error: not JPG/PNG/WEBP/PDF, not base64, or document_type_id is not an active type of the organization; or: 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":"feature_not_enabled; 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"}}}},"409":{"description":"Idempotency-Key in progress or outcome unknown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"payload_too_large: more than 10 MB decoded","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"}}}}}}},"/contacts/{id}/document_requests":{"post":{"tags":["Documents"],"summary":"Request documents from a contact, optionally sending the upload link by SMS or email","description":"Required scope: `documents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents: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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required."},"required":false,"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 (method, path, query and body). Keys are scoped to the credential and organization. Only 2xx and 404/422 responses are stored; a request that fails validation is not. Required when the deployment sets API_IDEMPOTENCY_MODE=required.","name":"Idempotency-Key","in":"header"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"document_type_ids":{"type":"array","items":{"type":"string","format":"uuid"},"minItems":1,"maxItems":20},"message":{"type":"string","maxLength":1000},"send_sms":{"type":"boolean"},"from_number":{"type":"string","pattern":"^\\+[1-9]\\d{1,14}$"},"send_email":{"type":"boolean"},"from_sender_id":{"type":"string","format":"uuid"},"to_email":{"type":"string","format":"email"},"email_subject":{"type":"string","maxLength":200}},"required":["document_type_ids"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","enum":[true]},"data":{"type":"object","properties":{"items":{"type":"array","items":{"type":"object","properties":{"item_id":{"type":"string","format":"uuid"},"document_type_id":{"type":"string","format":"uuid"},"status":{"type":"string"},"held":{"type":"boolean"}},"required":["item_id","document_type_id","status","held"]}},"outstanding_labels":{"type":"array","items":{"type":"string"},"description":"What the contact was asked for"},"nothing_outstanding":{"type":"boolean","description":"Everything asked for is already in: nothing was sent"},"duplicate_ask":{"type":"boolean"},"page_link":{"type":["object","null"],"properties":{"url":{"type":"string"},"expires_at":{"type":"string"}},"required":["url","expires_at"]},"sms_sent":{"type":"boolean"},"email_sent":{"type":"boolean"}},"required":["items","outstanding_labels","nothing_outstanding","duplicate_ask","page_link","sms_sent","email_sent"]}},"required":["success","data"]}}}},"400":{"description":"validation_error: the request was refused (the message says why); or: 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":"feature_not_enabled; 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"}}}},"409":{"description":"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"}}}},"502":{"description":"provider_error: the request service could not be reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/documents/items/{item_id}/{action}":{"post":{"tags":["Documents"],"summary":"Approve, reject, waive or re-request a checklist item","description":"Required scope: `documents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents:write","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":"string","format":"uuid"},"required":true,"name":"item_id","in":"path"},{"schema":{"type":"string","enum":["approve","reject","waive","rerequest"]},"required":true,"name":"action","in":"path"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"reason":{"type":"string","maxLength":500,"description":"Required to reject: shown to the contact"}}}}}},"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"},"type":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"key":{"type":"string"},"name":{"type":"string"},"contact_label":{"type":"string"}},"required":["id","key","name","contact_label"]},"status":{"type":"string","enum":["needed","reviewing","passed","failed","needs_review","waived"]},"status_changed_at":{"type":"string"},"reasons":{"type":"array","items":{"type":"string"},"description":"Plain-language reasons the contact is shown"},"promised_for":{"type":["string","null"],"description":"When the contact said they'd send it"},"contact_note":{"type":["string","null"]},"last_requested_at":{"type":["string","null"]},"request_count":{"type":"integer"}},"required":["id","type","status","status_changed_at","reasons","promised_for","contact_note","last_requested_at","request_count"]}},"required":["success","data"]}}}},"400":{"description":"validation_error: reject needs a reason; or: 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":"feature_not_enabled; actor_unknown: the API key has no owning user, so a team decision can't be recorded; 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"}}}},"409":{"description":"checklist_closed","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/documents/close":{"post":{"tags":["Documents"],"summary":"Close the contact's document checklist: the next request starts a new one, and a closed checklist is never re-checked or chased","description":"Required scope: `documents:write`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents: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":{"type":"object","properties":{"closed":{"type":"boolean","description":"Whether a checklist was open. The next request starts a new one."}},"required":["closed"]}},"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":"feature_not_enabled; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/contacts/{id}/events":{"get":{"tags":["Events"],"summary":"List a contact's events after a cursor (oldest first)","description":"Required scope: `events:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"events:read","parameters":[{"schema":{"type":"string","format":"uuid"},"required":true,"name":"id","in":"path"},{"schema":{"type":["integer","null"],"minimum":0,"default":0,"description":"Return events after this seq (the previous page's next_after_seq)"},"required":false,"description":"Return events after this seq (the previous page's next_after_seq)","name":"after_seq","in":"query"},{"schema":{"type":"integer","minimum":1,"maximum":100,"default":50},"required":false,"name":"limit","in":"query"},{"schema":{"type":"string","description":"Comma-separated event types to keep"},"required":false,"description":"Comma-separated event types to keep","name":"types","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"},"seq":{"type":"integer","description":"Increases with every event; order and resume by it"},"type":{"type":"string","enum":["document.requested","document.uploaded","document.unfiled","document.reviewed","document.waived","document.overridden","checklist.completed","message.received","message.sent","call.started","call.ended","call.analyzed","promise.made","promise.due","page.opened","foundry.turn","contact.opted_out"]},"source":{"type":"string","enum":["upload_page","voice","sms","email","foundry","workflow","dashboard","api","system"]},"occurred_at":{"type":"string"},"summary":{"type":"string","description":"One human line, e.g. \"W-2 received\""},"payload":{"type":"object","additionalProperties":{},"description":"Per type; message bodies have card and account numbers masked"},"item_id":{"type":["string","null"],"format":"uuid"},"document_id":{"type":["string","null"],"format":"uuid"},"call_id":{"type":["string","null"],"format":"uuid"},"message_id":{"type":["string","null"],"format":"uuid"},"email_id":{"type":["string","null"],"format":"uuid"},"run_id":{"type":["string","null"],"format":"uuid"}},"required":["id","seq","type","source","occurred_at","summary","payload","item_id","document_id","call_id","message_id","email_id","run_id"]}},"next_after_seq":{"type":"integer","description":"Pass as after_seq for the next page (unchanged when there were none)"},"has_more":{"type":"boolean"}},"required":["success","data","next_after_seq","has_more"]}}}},"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"}}}}}}},"/documents/{id}":{"get":{"tags":["Documents"],"summary":"Get a document file, its latest review and a download URL","description":"Required scope: `documents:read`","security":[{"bearerAuth":[]}],"x-aivi-scope":"documents: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"},"item_id":{"type":["string","null"],"format":"uuid"},"file_name":{"type":"string"},"mime_type":{"type":["string","null"]},"file_size_bytes":{"type":["integer","null"]},"source":{"type":"string"},"status":{"type":"string"},"filing_status":{"type":["string","null"],"enum":["pending_classification","filed","unfiled",null]},"redaction_status":{"type":["string","null"],"enum":["none","clean","redacted","failed",null]},"created_at":{"type":"string"},"superseded_at":{"type":["string","null"]},"review":{"type":["object","null"],"properties":{"id":{"type":"string","format":"uuid"},"verdict":{"type":"string"},"reasons":{"type":"array","items":{"type":"string"}},"source":{"type":"string"},"created_at":{"type":"string"},"rule_results":{"type":"array","items":{"type":"object","additionalProperties":{}}},"fields":{"type":"object","additionalProperties":{"type":"object","properties":{"value":{"type":["string","null"]},"confidence":{"type":"number"}},"required":["value","confidence"]}}},"required":["id","verdict","reasons","source","created_at","rule_results","fields"]},"download_url":{"type":["string","null"],"description":"5 minutes. The redacted copy when something sensitive was found, the original when the scan found nothing; null until the scan has run, or when it failed"},"download_expires_at":{"type":["string","null"]}},"required":["id","contact_id","item_id","file_name","mime_type","file_size_bytes","source","status","filing_status","redaction_status","created_at","superseded_at","review","download_url","download_expires_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":"feature_not_enabled; 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"}}}},"429":{"description":"Rate limited","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"webhooks":{}}