{"openapi":"3.0.3","info":{"title":"InfiVoice REST API","description":"Welcome to the InfiVoice REST API documentation. This API enables you to programmatically automate AI-powered voice communications at scale.\n","version":"1.0.0"},"servers":[{"url":"/api/v1","description":"API v1"}],"tags":[{"name":"Introduction","description":"\nInfiVoice provides a powerful REST API for automating AI-powered voice calls. Whether you're building customer outreach, appointment reminders, lead qualification, or interactive voice applications, our API gives you full control.\n\n<br /><br />\n\n---\n\n<br />\n\n\n<br />\n\n\nNavigate to your InfiVoice dashboard → API Keys page (left sidebar, /app/api-keys) to create an API key. Keep this key secure—it provides full access to your account.\n\n<br />\n\n\nTest your connection with a simple health check:\n\n```bash\ncurl -X GET \"https://infivoice.com/api/v1/health\"\n```\n\n<br />\n\n\nInclude your API key in every request using one of these methods:\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_API_KEY\" ...\n\ncurl -H \"X-API-Key: YOUR_API_KEY\" ...\n```\n\n<br /><br />\n\n---\n\n<br />\n\n\n<br />\n\n| Concept | Description |\n|---------|-------------|\n| **Agents** | AI voice agents that handle conversations. Two types: Flow (visual conversation builder) and Incoming (for inbound calls). |\n| **Campaigns** | Bulk calling operations targeting multiple contacts with the same agent. |\n| **Calls** | Individual voice call records with transcripts, recordings, and analytics. |\n| **Contacts** | Your CRM leads with phone numbers, custom fields, and AI-enriched data. |\n| **Credits** | Billing units where 1 credit = 1 minute of call time. |\n| **Webhooks** | Real-time event notifications delivered to your endpoints. |\n\n<br /><br />\n\n---\n\n<br />\n\n\nInfiVoice supports three telephony engines for different use cases:\n\n<br />\n\n| Engine | AI Provider | Best For |\n|--------|-------------|----------|\n| `elevenlabs` | ElevenLabs Conversational AI | High-quality voices, 29 languages |\n| `plivo` | OpenAI Realtime API | India and APAC regions |\n| `twilio-openai` | OpenAI Realtime API | Global coverage, reliable routing |\n\n<br /><br />\n\n---\n\n<br />\n\n\nAll API endpoints (except `/health`) require authentication. Include your API key in every request:\n\n<br />\n\n- **Authorization Header**: `Authorization: Bearer YOUR_API_KEY`\n- **X-API-Key Header**: `X-API-Key: YOUR_API_KEY`\n\n<br />\n\nAPI keys have scoped permissions. Ensure your key has the required scopes for the endpoints you're accessing.\n\n<br /><br />\n\n---\n\n<br />\n\n\nRequests are rate-limited based on your subscription plan:\n\n<br />\n\n| Plan | Limit |\n|------|-------|\n| Free | 60 requests/minute |\n| Pro | 300 requests/minute |\n| Enterprise | 1000 requests/minute |\n\n<br />\n\n**Rate limit headers in responses:**\n\n- `X-RateLimit-Limit` — Maximum requests per window\n- `X-RateLimit-Remaining` — Remaining requests\n- `X-RateLimit-Reset` — Unix timestamp when window resets\n\n<br /><br />\n\n---\n\n<br />\n\n\n<br />\n\n\n```json\n{\n  \"success\": true,\n  \"data\": { ... },\n  \"meta\": {\n    \"requestId\": \"uuid\",\n    \"timestamp\": \"2024-01-01T00:00:00.000Z\"\n  }\n}\n```\n\n<br />\n\n\n```json\n{\n  \"success\": false,\n  \"error\": {\n    \"code\": \"ERROR_CODE\",\n    \"message\": \"Human readable message\",\n    \"details\": { ... }\n  },\n  \"meta\": { ... }\n}\n```\n\n<br /><br />\n\n---\n\n<br />\n\n\n<br />\n\n| Code | HTTP Status | Description |\n|------|-------------|-------------|\n| `VALIDATION_ERROR` | 400 | Invalid request parameters |\n| `UNAUTHORIZED` | 401 | Missing or invalid API key |\n| `FORBIDDEN` | 403 | Insufficient permissions |\n| `NOT_FOUND` | 404 | Resource not found |\n| `INSUFFICIENT_CREDITS` | 402 | Not enough credits |\n| `RATE_LIMIT_EXCEEDED` | 429 | Too many requests |\n\n<br />\n"},{"name":"Calls","description":"\nThe Calls API allows you to trigger outbound calls, monitor active calls, and retrieve call history with transcripts and recordings.\n\n**Common Use Cases:**\n- Trigger individual calls to leads\n- Check call status and duration\n- Retrieve transcripts and AI summaries\n- Hang up active calls\n\n**Credit Usage:** Each call consumes credits based on duration (1 credit = 1 minute).\n"},{"name":"Campaigns","description":"\nCampaigns enable you to call multiple contacts automatically using a single AI agent. Perfect for outreach, reminders, and surveys.\n\n**Campaign Lifecycle:**\n1. Create a campaign (status: `draft`)\n2. Add contacts to the campaign\n3. Start the campaign (status: `running`)\n4. Monitor progress or pause if needed\n5. Campaign completes when all contacts are called\n\n**Features:**\n- Schedule campaigns for specific times\n- Set calling windows (e.g., 9 AM - 6 PM)\n- Configure retry attempts for unanswered calls\n- Limit concurrent calls\n"},{"name":"Agents","description":"\nAgents are your AI-powered conversational assistants. They handle voice interactions using advanced conversation flows.\n\n**Agent Types:**\n\n| Type | Description |\n|------|-------------|\n| `flow` | Visual conversation builder with decision trees and LLM-powered responses |\n| `incoming` | Handles inbound calls on purchased phone numbers |\n\n**Note:** Agents must be active (`isActive: true`) before they can be used in calls or campaigns.\n"},{"name":"Contacts","description":"\nManage your leads and contacts with full CRUD operations. Contacts can be enriched with AI-generated summaries and sentiment analysis after calls.\n\n**Features:**\n- Store custom fields for personalization\n- Tag contacts for segmentation\n- Track lead stages through your funnel\n- Bulk import up to 10,000 contacts at once\n\n**AI Enrichment:** After a call, contacts are automatically updated with:\n- Conversation summary\n- Sentiment analysis\n- Lead score adjustments\n"},{"name":"Credits","description":"\nMonitor your credit balance and usage history. Credits are consumed during calls at a rate of 1 credit per minute.\n\n**Understanding Credits:**\n- Credits are deducted in real-time during calls\n- Partial minutes are rounded up\n- Campaigns pause automatically when credits run low\n- View historical usage for budgeting\n"},{"name":"Analytics","description":"\nAccess aggregated statistics and insights about your calling activity. Use this data to optimize campaigns and measure ROI.\n\n**Available Metrics:**\n- Total calls and minutes\n- Answer rates and outcomes\n- Average call duration\n- Campaign performance comparisons\n- Daily/weekly/monthly trends\n"},{"name":"Webhooks","description":"\nWebhooks deliver real-time notifications to your server when events occur. Use them to sync data, trigger workflows, or build integrations.\n\n**Supported Events:**\n- `call.started` — Call initiated\n- `call.completed` — Call ended\n- `call.failed` — Call failed\n- `campaign.started` — Campaign began execution\n- `campaign.completed` — Campaign finished\n- `campaign.paused` — Campaign paused\n\n**Security:** All webhook payloads include an HMAC-SHA256 signature in the `X-Webhook-Signature` header for verification.\n"}],"security":[{"ApiKeyAuth":[]},{"BearerAuth":[]}],"paths":{"/health":{"get":{"summary":"Health Check","description":"Verify the API is operational. This endpoint does not require authentication and is useful for monitoring and uptime checks.\n\n**Use Case:** Add this endpoint to your monitoring tools to detect API outages.\n","operationId":"healthCheck","tags":["Introduction"],"security":[],"responses":{"200":{"description":"API is healthy and ready to accept requests","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthResponse"}}}}}}},"/calls":{"get":{"summary":"List Calls","description":"Retrieve a paginated list of all calls made from your account. Results include calls from all telephony engines (ElevenLabs, Plivo, Twilio-OpenAI).\n\n**Tip:** Use the `page` and `pageSize` parameters to navigate through large result sets efficiently.\n\n**Required Scope:** `calls:read`\n","operationId":"listCalls","tags":["Calls"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"}],"responses":{"200":{"description":"List of calls with pagination metadata","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallListResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"403":{"$ref":"#/components/responses/Forbidden"}}},"post":{"summary":"Trigger Call","description":"Initiate an outbound call using a specified AI agent. The call will be placed immediately unless scheduled for a future time.\n\n<br />\n\n**Prerequisites:**\n- An active AI agent (flow or incoming type)\n- Sufficient credits in your account\n- An active phone number (or provide `fromNumber`)\n\n<br />\n\n**Telephony Engines:**\n- `elevenlabs` — Best voice quality, 29 languages\n- `plivo` — India/APAC optimized\n- `twilio-openai` — Global coverage\n\n<br />\n\n**Required Scope:** `calls:write`\n","operationId":"triggerCall","tags":["Calls"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriggerCallRequest"},"examples":{"basic":{"summary":"Basic call","value":{"agentId":"550e8400-e29b-41d4-a716-446655440000","toNumber":"+14155551234"}},"withEngine":{"summary":"Specify engine","value":{"agentId":"550e8400-e29b-41d4-a716-446655440000","toNumber":"+14155551234","engine":"twilio-openai","fromNumber":"+14155559999"}}}}}},"responses":{"201":{"description":"Call initiated successfully. Returns call ID and initial status.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TriggerCallResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/calls/{id}":{"get":{"summary":"Get Call Details","description":"Retrieve detailed information about a specific call including:\n- Call status and duration\n- Full conversation transcript\n- AI-generated summary\n- Sentiment analysis\n- Recording URL (if available)\n\n<br />\n\n**Tip:** Poll this endpoint to track call progress. Status will transition from `queued` → `ringing` → `in-progress` → `completed`.\n\n<br />\n\n**Required Scope:** `calls:read`\n","operationId":"getCall","tags":["Calls"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Complete call details with transcript and analytics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallDetailResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/calls/{id}/hangup":{"post":{"summary":"Hangup Call","description":"Terminate an active call immediately. Use this to end calls that are in progress.\n\n**Note:** This only works for calls with status `in-progress` or `ringing`. Completed or failed calls cannot be hung up.\n\n**Required Scope:** `calls:write`\n","operationId":"hangupCall","tags":["Calls"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Hangup request accepted. Call will terminate shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HangupResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/campaigns":{"get":{"summary":"List Campaigns","description":"Retrieve all campaigns with their current status and progress metrics.\n\n<br />\n\n**Campaign Statuses:**\n- `draft` — Created but not started\n- `scheduled` — Waiting for scheduled start time\n- `running` — Actively making calls\n- `paused` — Temporarily stopped\n- `completed` — All contacts processed\n- `cancelled` — Permanently stopped\n\n<br />\n\n**Required Scope:** `campaigns:read`\n","operationId":"listCampaigns","tags":["Campaigns"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"}],"responses":{"200":{"description":"List of campaigns with progress metrics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CampaignListResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"summary":"Create Campaign","description":"Create a new bulk calling campaign with optional contacts CSV upload. The campaign starts in `draft` status and won't execute until you start it.\n\n<br />\n\n**Simplified Workflow:**\n1. Create campaign with contacts CSV → 2. Start campaign\n\n<br />\n\n**Request Format:**\nThis endpoint accepts `multipart/form-data` to allow simultaneous campaign creation and contact import.\n\n<br />\n\n**Campaign Data Options:**\n- Send as JSON string in `data` field, OR\n- Send as individual form fields (name, agentId, etc.)\n\n<br />\n\n**CSV Upload (Optional):**\nInclude a `contacts` field with your CSV file. Recognized columns:\n- `phone` or `phone_number` — Required\n- `firstName`, `lastName`, `name`, `email`\n- Any other columns become custom fields\n\n<br />\n\n**Configuration Options:**\n- **Calling Windows:** Restrict calls to business hours\n- **Concurrent Calls:** Control call volume (1-100)\n- **Retry Logic:** Automatically retry unanswered calls\n- **Scheduling:** Start immediately or at a future time\n\n<br />\n\n**Required Scope:** `campaigns:write`\n","operationId":"createCampaign","tags":["Campaigns"],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["name","agentId"],"properties":{"data":{"type":"string","description":"Campaign data as JSON string (alternative to individual fields)","example":"{\"name\": \"Q1 Outreach\", \"agentId\": \"550e8400-e29b-41d4-a716-446655440000\"}"},"name":{"type":"string","description":"Campaign name (use either this or data field)","example":"Q1 Lead Outreach"},"agentId":{"type":"string","format":"uuid","description":"Agent to use for calls"},"phoneNumberId":{"type":"string","format":"uuid","description":"Phone number to call from"},"engine":{"type":"string","enum":["elevenlabs","plivo","twilio-openai"],"description":"Telephony engine"},"scheduledStartTime":{"type":"string","format":"date-time","description":"When to start the campaign"},"timezone":{"type":"string","example":"America/New_York"},"callWindowStart":{"type":"string","pattern":"^\\d{2}:\\d{2}$","example":"09:00"},"callWindowEnd":{"type":"string","pattern":"^\\d{2}:\\d{2}$","example":"18:00"},"maxConcurrentCalls":{"type":"integer","minimum":1,"maximum":100,"example":10},"contacts":{"type":"string","format":"binary","description":"Optional CSV file with contacts"}}}},"application/json":{"schema":{"$ref":"#/components/schemas/CreateCampaignRequest"},"examples":{"basic":{"summary":"Basic campaign (JSON)","value":{"name":"Q1 Lead Outreach","agentId":"550e8400-e29b-41d4-a716-446655440000"}},"scheduled":{"summary":"Scheduled campaign","value":{"name":"Appointment Reminders","agentId":"550e8400-e29b-41d4-a716-446655440000","scheduledStartTime":"2024-01-15T09:00:00Z","timezone":"America/New_York","callWindowStart":"09:00","callWindowEnd":"18:00","maxConcurrentCalls":10}}}}}},"responses":{"201":{"description":"Campaign created with optional contact import results","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/CampaignResponse"},{"type":"object","properties":{"data":{"type":"object","properties":{"contacts":{"type":"object","description":"Present only if CSV was uploaded","properties":{"fileName":{"type":"string"},"totalRows":{"type":"integer"},"contactsAdded":{"type":"integer"},"contactsSkipped":{"type":"integer"},"invalidRows":{"type":"integer"}}}}}}}]},"example":{"success":true,"data":{"id":"550e8400-e29b-41d4-a716-446655440000","name":"Q1 Lead Outreach","status":"draft","agentId":"550e8400-e29b-41d4-a716-446655440001","contacts":{"fileName":"leads.csv","totalRows":150,"contactsAdded":145,"contactsSkipped":3,"invalidRows":2}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/campaigns/{id}":{"get":{"summary":"Get Campaign Details","description":"Retrieve detailed information about a campaign including:\n- Current status and progress\n- Contact counts (total, called, remaining)\n- Schedule and timing information\n- Configuration settings\n\n<br />\n\n**Required Scope:** `campaigns:read`\n","operationId":"getCampaign","tags":["Campaigns"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Campaign details with progress metrics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CampaignResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/campaigns/{id}/contacts":{"post":{"summary":"Add Campaign Contacts","description":"Add contacts to a campaign's call list. You can add up to 10,000 contacts per request.\n\n<br />\n\n**Important:** Contacts can only be added when the campaign status is `draft` or `paused`. Running campaigns will reject new contacts.\n\n<br />\n\n**Contact Fields:**\n- `phoneNumber` (required) — Phone number in E.164 format\n- `firstName`, `lastName`, `email` — Optional contact info\n- `customFields` — Key-value pairs for personalization in agent scripts\n\n<br />\n\n**Tip:** Use `customFields` to pass data like appointment times or account numbers that your agent can reference during the call.\n\n<br />\n\n**Required Scope:** `campaigns:write`\n","operationId":"addCampaignContacts","tags":["Campaigns"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddCampaignContactsRequest"},"examples":{"simple":{"summary":"Basic contacts","value":{"contacts":[{"phoneNumber":"+14155551234","firstName":"John","lastName":"Doe"},{"phoneNumber":"+14155555678","firstName":"Jane","lastName":"Smith"}]}},"withCustomFields":{"summary":"Contacts with custom fields","value":{"contacts":[{"phoneNumber":"+14155551234","firstName":"John","customFields":{"appointmentTime":"2:00 PM","doctorName":"Dr. Smith"}}]}}}}}},"responses":{"201":{"description":"Contacts added with success/skip counts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddContactsResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/campaigns/{id}/contacts-upload":{"post":{"summary":"Upload CSV Contacts","description":"Upload a CSV file to add contacts to a campaign. This is the recommended method for bulk contact imports.\n\n<br />\n\n**CSV Format:**\nThe CSV must include a header row. Recognized columns:\n- `phone` or `phone_number` — Required, contact phone number\n- `firstName` or `first_name` — First name\n- `lastName` or `last_name` — Last name  \n- `name` — Full name (splits into first/last automatically)\n- `email` — Email address\n- Any other columns become custom fields\n\n<br />\n\n**ElevenLabs Format Support:**\nColumns prefixed with `dynamic_data.` are automatically converted to custom fields.\n\n<br />\n\n**Example CSV:**\n```\nphone,firstName,lastName,appointmentTime\n+14155551234,John,Doe,2:00 PM\n+14155555678,Jane,Smith,3:30 PM\n```\n\n<br />\n\n**Limits:**\n- Maximum file size: 10MB\n- Maximum contacts: 10,000 per upload\n\n<br />\n\n**Required Scope:** `campaigns:write`\n","operationId":"uploadCampaignContacts","tags":["Campaigns"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"CSV file containing contacts"}}}}}},"responses":{"201":{"description":"CSV processed successfully","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"campaignId":{"type":"string","format":"uuid"},"fileName":{"type":"string","example":"contacts.csv"},"totalRows":{"type":"integer","description":"Total rows parsed from CSV","example":150},"contactsAdded":{"type":"integer","description":"New contacts added","example":145},"contactsSkipped":{"type":"integer","description":"Duplicate contacts skipped","example":3},"invalidRows":{"type":"integer","description":"Rows with invalid phone numbers","example":2}}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/campaigns/{id}/start":{"post":{"summary":"Start Campaign","description":"Begin executing a campaign. The system will start placing calls to contacts according to your configuration.\n\n<br />\n\n**Prerequisites:**\n- Campaign must have at least one contact\n- Sufficient credits for estimated calls\n- Associated agent must be active\n\n<br />\n\n**Behavior:**\n- Calls are placed respecting `maxConcurrentCalls` limit\n- Calling windows are honored (no calls outside configured hours)\n- Failed calls are retried based on `retryAttempts` setting\n\n<br />\n\n**Required Scope:** `campaigns:write`\n","operationId":"startCampaign","tags":["Campaigns"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Campaign started successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CampaignActionResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/campaigns/{id}/pause":{"post":{"summary":"Pause Campaign","description":"Temporarily pause a running campaign. Active calls will complete, but no new calls will be initiated.\n\n<br />\n\n**Resume:** Use the Start Campaign endpoint to resume a paused campaign.\n\n<br />\n\n**Use Cases:**\n- Credit running low\n- Need to add more contacts\n- Business hours ended\n\n<br />\n\n**Required Scope:** `campaigns:write`\n","operationId":"pauseCampaign","tags":["Campaigns"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Campaign paused. Active calls will complete.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CampaignActionResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/agents":{"get":{"summary":"List Agents","description":"Retrieve all AI agents in your account. Each agent represents a configured voice assistant with its own personality, language, and behavior.\n\n<br />\n\n**Agent Status:**\n- `isActive: true` — Agent is ready for calls\n- `isActive: false` — Agent is disabled\n\n<br />\n\n**Required Scope:** `agents:read`\n","operationId":"listAgents","tags":["Agents"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"}],"responses":{"200":{"description":"List of agents with basic information","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentListResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/agents/{id}":{"get":{"summary":"Get Agent Details","description":"Retrieve complete configuration for an agent including:\n- System prompt and first message\n- Voice and LLM settings\n- Transfer configuration\n- Language and personality settings\n\n<br />\n\n**Use Case:** Inspect agent settings before using in campaigns or calls.\n\n<br />\n\n**Required Scope:** `agents:read`\n","operationId":"getAgent","tags":["Agents"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Complete agent configuration","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentDetailResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/agents/{id}/flow":{"get":{"summary":"Export Agent Flow","description":"Export the visual conversation flow for a Flow-type agent. Returns the complete flow structure including nodes, edges, and variables.\n\n<br />\n\n**Use Cases:**\n- Backup agent configurations\n- Clone flows to other agents\n- Version control flow designs\n- Share flows between accounts\n\n<br />\n\n**Note:** Only works for agents with `type: flow`. Incoming agents don't have exportable flows.\n\n<br />\n\n**Required Scope:** `agents:read`\n","operationId":"exportAgentFlow","tags":["Agents"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Complete flow definition with nodes and edges","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlowExportResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Import Agent Flow","description":"Replace an agent's conversation flow with an imported definition. Use this to restore backups or deploy flows from templates.\n\n<br />\n\n**Warning:** This replaces the existing flow entirely. Export the current flow first if you want to preserve it.\n\n<br />\n\n**Flow Structure:**\n- `nodes` — Array of flow nodes (message, question, condition, etc.)\n- `edges` — Connections between nodes\n- `variables` — Flow variables for data collection\n\n<br />\n\n**Required Scope:** `agents:write`\n","operationId":"importAgentFlow","tags":["Agents"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlowImportRequest"}}}},"responses":{"200":{"description":"Flow imported and agent updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/FlowImportResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/contacts":{"get":{"summary":"List Contacts","description":"Retrieve all contacts from your CRM. Contacts are enriched with AI-generated data after calls.\n\n<br />\n\n**Contact Data Includes:**\n- Basic info (name, phone, email, company)\n- Custom fields for personalization\n- Tags for segmentation\n- Lead stage and score\n- AI summary and sentiment (post-call)\n\n<br />\n\n**Required Scope:** `contacts:read`\n","operationId":"listContacts","tags":["Contacts"],"parameters":[{"$ref":"#/components/parameters/PageParam"},{"$ref":"#/components/parameters/PageSizeParam"}],"responses":{"200":{"description":"List of contacts with enriched data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactListResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"summary":"Create Contact","description":"Add a new contact to your CRM. The phone number is required; all other fields are optional.\n\n<br />\n\n**Best Practices:**\n- Use E.164 format for phone numbers (+1234567890)\n- Add custom fields that your agents can reference\n- Use tags for easy filtering and segmentation\n\n<br />\n\n**Required Scope:** `contacts:write`\n","operationId":"createContact","tags":["Contacts"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateContactRequest"},"examples":{"basic":{"summary":"Basic contact","value":{"phone":"+14155551234","firstName":"John","lastName":"Doe","email":"john@example.com"}},"withCustomFields":{"summary":"Contact with custom fields","value":{"phone":"+14155551234","firstName":"John","company":"Acme Corp","tags":["lead","enterprise"],"customFields":{"accountId":"ACC-12345","preferredTime":"morning"}}}}}}},"responses":{"201":{"description":"Contact created successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"409":{"$ref":"#/components/responses/Conflict"}}}},"/contacts/{id}":{"get":{"summary":"Get Contact Details","description":"Retrieve complete information about a contact including call history and AI enrichment.\n\n<br />\n\n**AI Enrichment (after calls):**\n- `aiSummary` — AI-generated summary of conversations\n- `sentiment` — Detected sentiment (positive, neutral, negative)\n- `leadScore` — Automatically calculated lead score\n\n<br />\n\n**Required Scope:** `contacts:read`\n","operationId":"getContact","tags":["Contacts"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Complete contact details with AI enrichment","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update Contact","description":"Update contact information. Only include fields you want to change.\n\n<br />\n\n**Tip:** Update the `stage` field to move contacts through your sales funnel.\n\n<br />\n\n**Required Scope:** `contacts:write`\n","operationId":"updateContact","tags":["Contacts"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateContactRequest"}}}},"responses":{"200":{"description":"Contact updated successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ContactResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"summary":"Delete Contact","description":"Permanently delete a contact and all associated data.\n\n<br />\n\n**Warning:** This action cannot be undone. Call history remains but will no longer be linked to this contact.\n\n<br />\n\n**Required Scope:** `contacts:write`\n","operationId":"deleteContact","tags":["Contacts"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Contact permanently deleted","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/contacts/bulk-import":{"post":{"summary":"Bulk Import Contacts","description":"Import up to 10,000 contacts in a single request. Ideal for syncing from external CRMs or uploading lists.\n\n<br />\n\n**Behavior:**\n- Duplicate phone numbers are skipped\n- Invalid records are counted in `failed` response field\n- Import is atomic — all succeed or detailed errors returned\n\n<br />\n\n**Performance Tip:** For very large imports, batch into multiple requests of 5,000 contacts each.\n\n<br />\n\n**Required Scope:** `contacts:write`\n","operationId":"bulkImportContacts","tags":["Contacts"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkImportRequest"}}}},"responses":{"201":{"description":"Import completed with success/failure counts","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BulkImportResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/credits/balance":{"get":{"summary":"Get Credit Balance","description":"Check your current credit balance. Use this to verify you have sufficient credits before starting campaigns.\n\n<br />\n\n**Credit System:**\n- 1 credit = 1 minute of call time\n- Partial minutes are rounded up\n- Balance updates in real-time during calls\n\n<br />\n\n**Required Scope:** `credits:read`\n","operationId":"getCreditBalance","tags":["Credits"],"responses":{"200":{"description":"Current credit balance","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBalanceResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/credits/usage":{"get":{"summary":"Get Credit Usage","description":"Retrieve credit usage history for budgeting and analysis. Shows daily usage breakdown.\n\n<br />\n\n**Use Cases:**\n- Track spending over time\n- Identify high-usage periods\n- Plan credit purchases\n- Generate billing reports\n\n<br />\n\n**Required Scope:** `credits:read`\n","operationId":"getCreditUsage","tags":["Credits"],"parameters":[{"name":"days","in":"query","description":"Number of days to include in the report (default 30, max 90)","schema":{"type":"integer","default":30,"minimum":1,"maximum":90}}],"responses":{"200":{"description":"Daily credit usage breakdown","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditUsageResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/analytics/calls":{"get":{"summary":"Get Call Analytics","description":"Retrieve aggregated call statistics. Useful for dashboards and performance monitoring.\n\n<br />\n\n**Metrics Included:**\n- Total calls and minutes\n- Answer rate and average duration\n- Outcome distribution (completed, failed, no-answer)\n- Daily trends\n\n<br />\n\n**Required Scope:** `analytics:read`\n","operationId":"getCallAnalytics","tags":["Analytics"],"parameters":[{"name":"days","in":"query","description":"Number of days to analyze (default 30, max 90)","schema":{"type":"integer","default":30,"minimum":1,"maximum":90}}],"responses":{"200":{"description":"Call analytics","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallAnalyticsResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/analytics/campaigns":{"get":{"summary":"Get Campaign Analytics","description":"Retrieve performance analytics for all campaigns. Compare effectiveness across different campaigns.\n\n<br />\n\n**Metrics Per Campaign:**\n- Total contacts and calls made\n- Answer rate and completion rate\n- Average call duration\n- Cost (credits used)\n\n<br />\n\n**Required Scope:** `analytics:read`\n","operationId":"getCampaignAnalytics","tags":["Analytics"],"responses":{"200":{"description":"Performance metrics for all campaigns","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CampaignAnalyticsResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/analytics/summary":{"get":{"summary":"Get Analytics Summary","description":"Get a high-level summary of all activity. Perfect for executive dashboards and quick status checks.\n\n<br />\n\n**Summary Includes:**\n- Total calls, campaigns, and contacts\n- Credit usage and balance\n- Success rates and key metrics\n- Comparison to previous period\n\n<br />\n\n**Required Scope:** `analytics:read`\n","operationId":"getAnalyticsSummary","tags":["Analytics"],"parameters":[{"name":"days","in":"query","description":"Time period to summarize (default 30 days)","schema":{"type":"integer","default":30}}],"responses":{"200":{"description":"High-level analytics summary","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AnalyticsSummaryResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/webhooks":{"get":{"summary":"List Webhooks","description":"Retrieve all webhook subscriptions. Each webhook listens for specific events and delivers payloads to your endpoint.\n\n<br />\n\n**Webhook Status:**\n- `active` — Receiving events\n- `inactive` — Paused, not receiving events\n- `failed` — Too many delivery failures\n\n<br />\n\n**Required Scope:** `webhooks:read`\n","operationId":"listWebhooks","tags":["Webhooks"],"responses":{"200":{"description":"List of webhook subscriptions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookListResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}},"post":{"summary":"Create Webhook","description":"Subscribe to events with a new webhook. Your endpoint will receive HTTP POST requests when events occur.\n\n<br />\n\n**Setup Requirements:**\n- HTTPS endpoint (HTTP not allowed for security)\n- Endpoint must respond with 2xx within 30 seconds\n- Failed deliveries are retried with exponential backoff\n\n<br />\n\n**Signature Verification:**\nEach payload includes an `X-Webhook-Signature` header with an HMAC-SHA256 signature. Verify this to ensure authenticity.\n\n<br />\n\n**Required Scope:** `webhooks:write`\n","operationId":"createWebhook","tags":["Webhooks"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateWebhookRequest"},"examples":{"callEvents":{"summary":"Subscribe to call events","value":{"url":"https://your-server.com/webhooks/infivoice","events":["call.started","call.completed","call.failed"]}},"allEvents":{"summary":"Subscribe to all events","value":{"url":"https://your-server.com/webhooks/infivoice","events":["call.started","call.completed","call.failed","campaign.started","campaign.completed"]}}}}}},"responses":{"201":{"description":"Webhook created with signing secret","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/webhooks/events":{"get":{"summary":"List Supported Events","description":"Get a list of all event types you can subscribe to. Use these event names when creating webhooks.\n\n<br />\n\n**Event Categories:**\n- `call.*` — Call lifecycle events\n- `campaign.*` — Campaign lifecycle events\n- `contact.*` — Contact changes\n- `subscription.*` — Billing events\n\n<br />\n\n**Required Scope:** `webhooks:read`\n","operationId":"listWebhookEvents","tags":["Webhooks"],"responses":{"200":{"description":"List of available event types","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookEventsResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"}}}},"/webhooks/{id}":{"put":{"summary":"Update Webhook","description":"Modify a webhook's configuration. You can change the URL, events, or active status.\n\n<br />\n\n**Tip:** Set `active: false` to temporarily pause a webhook without deleting it.\n\n<br />\n\n**Required Scope:** `webhooks:write`\n","operationId":"updateWebhook","tags":["Webhooks"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateWebhookRequest"}}}},"responses":{"200":{"description":"Webhook configuration updated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"delete":{"summary":"Delete Webhook","description":"Permanently delete a webhook subscription. No further events will be delivered to this endpoint.\n\n**Required Scope:** `webhooks:write`\n","operationId":"deleteWebhook","tags":["Webhooks"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Webhook deleted successfully","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/webhooks/{id}/test":{"post":{"summary":"Test Webhook","description":"Send a test payload to verify your webhook endpoint is configured correctly. The test payload mimics a real event.\n\n<br />\n\n**Test Process:**\n1. InfiVoice sends a test payload to your URL\n2. Your server should return 2xx status\n3. Response includes success/failure and timing info\n\n<br />\n\n**Troubleshooting:**\n- Ensure your endpoint is publicly accessible\n- Check that you respond within 30 seconds\n- Verify SSL certificate is valid\n\n<br />\n\n**Required Scope:** `webhooks:write`\n","operationId":"testWebhook","tags":["Webhooks"],"parameters":[{"$ref":"#/components/parameters/IdParam"}],"responses":{"200":{"description":"Test results with timing and response info","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WebhookTestResponse"}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-API-Key","description":"API key for authentication"},"BearerAuth":{"type":"http","scheme":"bearer","description":"Bearer token (API key)"}},"parameters":{"IdParam":{"name":"id","in":"path","required":true,"description":"Resource UUID","schema":{"type":"string","format":"uuid"}},"PageParam":{"name":"page","in":"query","description":"Page number (1-indexed)","schema":{"type":"integer","default":1,"minimum":1}},"PageSizeParam":{"name":"pageSize","in":"query","description":"Items per page (max 100)","schema":{"type":"integer","default":20,"minimum":1,"maximum":100}}},"responses":{"BadRequest":{"description":"Invalid request parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Unauthorized":{"description":"Authentication required or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Forbidden":{"description":"Insufficient permissions","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"NotFound":{"description":"Resource not found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"Conflict":{"description":"Resource conflict","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}},"InsufficientCredits":{"description":"Insufficient credits","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}},"schemas":{"Meta":{"type":"object","properties":{"requestId":{"type":"string","format":"uuid"},"timestamp":{"type":"string","format":"date-time"}}},"PaginationMeta":{"allOf":[{"$ref":"#/components/schemas/Meta"},{"type":"object","properties":{"pagination":{"type":"object","properties":{"page":{"type":"integer"},"pageSize":{"type":"integer"},"totalItems":{"type":"integer"},"totalPages":{"type":"integer"},"hasNext":{"type":"boolean"},"hasPrev":{"type":"boolean"}}}}}]},"ErrorResponse":{"type":"object","properties":{"success":{"type":"boolean","example":false},"error":{"type":"object","properties":{"code":{"type":"string","example":"VALIDATION_ERROR"},"message":{"type":"string","example":"Invalid request parameters"},"details":{"type":"object"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"HealthResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"status":{"type":"string","example":"healthy"},"version":{"type":"string","example":"v1"},"timestamp":{"type":"string","format":"date-time"}}}}},"DeleteResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"deleted":{"type":"boolean","example":true}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"TriggerCallRequest":{"type":"object","required":["agentId","toNumber"],"properties":{"agentId":{"type":"string","format":"uuid","description":"ID of the agent to use for the call"},"toNumber":{"type":"string","description":"Phone number to call (E.164 format recommended)","example":"+14155551234"},"fromNumber":{"type":"string","description":"Caller ID phone number (optional, uses default if not provided)"},"engine":{"type":"string","enum":["elevenlabs","plivo","twilio-openai"],"description":"Telephony engine to use"},"metadata":{"type":"object","additionalProperties":{"type":"string"},"description":"Custom metadata to attach to the call"},"scheduledAt":{"type":"string","format":"date-time","description":"Schedule call for a future time"}}},"TriggerCallResponse":{"type":"object","properties":{"success":{"type":"boolean","example":true},"data":{"type":"object","properties":{"callId":{"type":"string","format":"uuid"},"status":{"type":"string","example":"queued"},"agentId":{"type":"string","format":"uuid"},"toNumber":{"type":"string"},"fromNumber":{"type":"string"},"engine":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"Call":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"engine":{"type":"string","enum":["elevenlabs","plivo","twilio-openai"]},"agentId":{"type":"string","format":"uuid"},"toNumber":{"type":"string"},"fromNumber":{"type":"string"},"status":{"type":"string","enum":["queued","ringing","in-progress","completed","failed","no-answer","busy"]},"duration":{"type":"integer","description":"Duration in seconds"},"creditsUsed":{"type":"number"},"transcript":{"type":"string"},"aiSummary":{"type":"string"},"recordingUrl":{"type":"string"},"sentiment":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"endedAt":{"type":"string","format":"date-time"}}},"CallListResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Call"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}}},"CallDetailResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Call"},"meta":{"$ref":"#/components/schemas/Meta"}}},"HangupResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"callId":{"type":"string"},"status":{"type":"string","example":"hangup_requested"},"message":{"type":"string"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CreateCampaignRequest":{"type":"object","required":["name","agentId"],"properties":{"name":{"type":"string","maxLength":255},"agentId":{"type":"string","format":"uuid"},"phoneNumberId":{"type":"string","format":"uuid"},"engine":{"type":"string","enum":["elevenlabs","plivo","twilio-openai"]},"scheduledStartTime":{"type":"string","format":"date-time"},"timezone":{"type":"string","example":"America/New_York"},"callWindowStart":{"type":"string","pattern":"^\\d{2}:\\d{2}$","example":"09:00"},"callWindowEnd":{"type":"string","pattern":"^\\d{2}:\\d{2}$","example":"18:00"},"maxConcurrentCalls":{"type":"integer","minimum":1,"maximum":100,"default":5},"retryAttempts":{"type":"integer","minimum":0,"maximum":5,"default":2},"retryDelayMinutes":{"type":"integer","minimum":1,"maximum":1440,"default":30}}},"Campaign":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"status":{"type":"string","enum":["draft","scheduled","running","paused","completed","cancelled"]},"agentId":{"type":"string","format":"uuid"},"phoneNumberId":{"type":"string","format":"uuid"},"totalContacts":{"type":"integer"},"calledContacts":{"type":"integer"},"scheduledStartTime":{"type":"string","format":"date-time"},"startedAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"},"createdAt":{"type":"string","format":"date-time"}}},"CampaignResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Campaign"},"meta":{"$ref":"#/components/schemas/Meta"}}},"CampaignListResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Campaign"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}}},"AddCampaignContactsRequest":{"type":"object","required":["contacts"],"properties":{"contacts":{"type":"array","minItems":1,"maxItems":10000,"items":{"type":"object","required":["phoneNumber"],"properties":{"phoneNumber":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"customFields":{"type":"object","additionalProperties":{"type":"string"}}}}}}},"AddContactsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"campaignId":{"type":"string"},"contactsAdded":{"type":"integer"},"contactsSkipped":{"type":"integer"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CampaignActionResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"campaignId":{"type":"string"},"status":{"type":"string"},"message":{"type":"string"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"Agent":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string"},"type":{"type":"string","enum":["flow","incoming"]},"telephonyProvider":{"type":"string"},"language":{"type":"string"},"isActive":{"type":"boolean"},"transferEnabled":{"type":"boolean"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"AgentDetail":{"allOf":[{"$ref":"#/components/schemas/Agent"},{"type":"object","properties":{"systemPrompt":{"type":"string"},"firstMessage":{"type":"string"},"llmModel":{"type":"string"},"temperature":{"type":"number"},"voiceId":{"type":"string"},"openaiVoice":{"type":"string"},"transferPhoneNumber":{"type":"string"},"maxDurationSeconds":{"type":"integer"}}}]},"AgentListResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Agent"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}}},"AgentDetailResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/AgentDetail"},"meta":{"$ref":"#/components/schemas/Meta"}}},"FlowExportResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"version":{"type":"string"},"agentId":{"type":"string"},"agentName":{"type":"string"},"exportedAt":{"type":"string","format":"date-time"},"flow":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"nodes":{"type":"array","items":{"type":"object"}},"edges":{"type":"array","items":{"type":"object"}},"variables":{"type":"object"}}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"FlowImportRequest":{"type":"object","required":["flow"],"properties":{"flow":{"type":"object","required":["nodes","edges"],"properties":{"name":{"type":"string"},"nodes":{"type":"array","items":{"type":"object"}},"edges":{"type":"array","items":{"type":"object"}},"variables":{"type":"object"}}}}},"FlowImportResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"agentId":{"type":"string"},"message":{"type":"string"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CreateContactRequest":{"type":"object","required":["phone"],"properties":{"phone":{"type":"string","minLength":10},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"company":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"customFields":{"type":"object","additionalProperties":true}}},"UpdateContactRequest":{"type":"object","properties":{"phone":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string","format":"email"},"company":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"customFields":{"type":"object"},"stage":{"type":"string"}}},"Contact":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"phone":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"},"email":{"type":"string"},"company":{"type":"string"},"tags":{"type":"array","items":{"type":"string"}},"customFields":{"type":"object"},"stage":{"type":"string"},"leadScore":{"type":"integer"},"aiSummary":{"type":"string"},"sentiment":{"type":"string"},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"}}},"ContactResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"$ref":"#/components/schemas/Contact"},"meta":{"$ref":"#/components/schemas/Meta"}}},"ContactListResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Contact"}},"meta":{"$ref":"#/components/schemas/PaginationMeta"}}},"BulkImportRequest":{"type":"object","required":["contacts"],"properties":{"contacts":{"type":"array","minItems":1,"maxItems":10000,"items":{"$ref":"#/components/schemas/CreateContactRequest"}},"skipDuplicates":{"type":"boolean","default":true}}},"BulkImportResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"imported":{"type":"integer"},"skipped":{"type":"integer"},"errors":{"type":"array","items":{"type":"object","properties":{"row":{"type":"integer"},"phoneNumber":{"type":"string"},"error":{"type":"string"}}}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CreditBalanceResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"available":{"type":"number"},"reserved":{"type":"number"},"total":{"type":"number"},"currency":{"type":"string","example":"credits"}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CreditUsageResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"period":{"type":"object","properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"}}},"usage":{"type":"array","items":{"type":"object","properties":{"date":{"type":"string","format":"date"},"calls":{"type":"integer"},"minutes":{"type":"integer"},"credits":{"type":"number"}}}},"total":{"type":"object","properties":{"calls":{"type":"integer"},"minutes":{"type":"integer"},"credits":{"type":"number"}}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CallAnalyticsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"totalCalls":{"type":"integer"},"completedCalls":{"type":"integer"},"failedCalls":{"type":"integer"},"totalDurationMinutes":{"type":"integer"},"averageDurationSeconds":{"type":"integer"},"creditsUsed":{"type":"number"},"period":{"type":"object","properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"}}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CampaignAnalyticsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"type":"object","properties":{"campaignId":{"type":"string"},"name":{"type":"string"},"status":{"type":"string"},"totalContacts":{"type":"integer"},"completed":{"type":"integer"},"successful":{"type":"integer"},"failed":{"type":"integer"},"pending":{"type":"integer"},"successRate":{"type":"integer"},"startedAt":{"type":"string","format":"date-time"},"completedAt":{"type":"string","format":"date-time"}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"AnalyticsSummaryResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"period":{"type":"object","properties":{"start":{"type":"string","format":"date-time"},"end":{"type":"string","format":"date-time"},"days":{"type":"integer"}}},"calls":{"type":"object","properties":{"total":{"type":"integer"},"completed":{"type":"integer"}}},"campaigns":{"type":"object","properties":{"total":{"type":"integer"},"running":{"type":"integer"},"completed":{"type":"integer"}}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"CreateWebhookRequest":{"type":"object","required":["url","events"],"properties":{"url":{"type":"string","format":"uri","description":"HTTPS endpoint to receive webhook payloads"},"events":{"type":"array","minItems":1,"items":{"type":"string","enum":["call.started","call.completed","call.failed","campaign.started","campaign.completed","campaign.paused","contact.created","contact.updated","credits.low","credits.depleted"]}},"secret":{"type":"string","description":"Custom signing secret (auto-generated if not provided)"},"description":{"type":"string"}}},"UpdateWebhookRequest":{"type":"object","properties":{"url":{"type":"string","format":"uri"},"events":{"type":"array","items":{"type":"string"}},"isActive":{"type":"boolean"},"description":{"type":"string"}}},"Webhook":{"type":"object","properties":{"id":{"type":"string","format":"uuid"},"url":{"type":"string"},"events":{"type":"array","items":{"type":"string"}},"isActive":{"type":"boolean"},"description":{"type":"string"},"lastDeliveryAt":{"type":"string","format":"date-time"},"lastDeliveryStatus":{"type":"string"},"createdAt":{"type":"string","format":"date-time"}}},"WebhookResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"allOf":[{"$ref":"#/components/schemas/Webhook"},{"type":"object","properties":{"secret":{"type":"string","description":"Only returned on creation"}}}]},"meta":{"$ref":"#/components/schemas/Meta"}}},"WebhookListResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Webhook"}},"meta":{"$ref":"#/components/schemas/Meta"}}},"WebhookEventsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"events":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"description":{"type":"string"}}}}}},"meta":{"$ref":"#/components/schemas/Meta"}}},"WebhookTestResponse":{"type":"object","properties":{"success":{"type":"boolean"},"data":{"type":"object","properties":{"delivered":{"type":"boolean"},"statusCode":{"type":"integer"},"message":{"type":"string"}}},"meta":{"$ref":"#/components/schemas/Meta"}}}}}}