{
  "openapi": "3.1.0",
  "info": {
    "title": "VoiSar Call API",
    "version": "2026-09-05",
    "description": "Integration-scoped calls, canonical results, transcript, analysis, MP3 and cancellation. Use Bearer headers; legacy GET creation is deprecated."
  },
  "servers": [
    {
      "url": "https://api.voisar.ru"
    }
  ],
  "paths": {
    "/v1/call/{integration_id}": {
      "post": {
        "tags": [
          "v1-public"
        ],
        "summary": "Make Call Post",
        "operationId": "make_call_post_v1_call__integration_id__post",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Persist one key per business operation and reuse unchanged on retry. A conflicting body returns 409.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[A-Za-z0-9._:-]+$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PublicCallRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      },
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "Make Call Get",
        "operationId": "make_call_get_v1_call__integration_id__get",
        "deprecated": true,
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 32,
              "title": "Phone"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicCallResponse"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/call/{integration_id}/{call_id}": {
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "Get Call Status",
        "operationId": "get_call_status_v1_call__integration_id___call_id__get",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Canonical result; poll terminal, analysis_status and recording.status independently",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallResult"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/call/{integration_id}/status/{call_id}": {
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "Get Call Status",
        "operationId": "get_call_status_v1_call__integration_id__status__call_id__get",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Canonical result; poll terminal, analysis_status and recording.status independently",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallResult"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/call/{integration_id}/{call_id}/transcript": {
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "Get Transcript",
        "operationId": "get_transcript_v1_call__integration_id___call_id__transcript_get",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Processing state and available data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "call_id",
                    "status",
                    "text",
                    "dialog"
                  ],
                  "properties": {
                    "call_id": {
                      "type": "string"
                    },
                    "status": {
                      "enum": [
                        "available",
                        "pending",
                        "unavailable"
                      ]
                    },
                    "text": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "dialog": {
                      "type": [
                        "array",
                        "object",
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/call/{integration_id}/{call_id}/analysis": {
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "Get Analysis",
        "operationId": "get_analysis_v1_call__integration_id___call_id__analysis_get",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Processing state and available data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "call_id",
                    "status",
                    "analysis",
                    "structured_data"
                  ],
                  "properties": {
                    "call_id": {
                      "type": "string"
                    },
                    "status": {
                      "enum": [
                        "ready",
                        "pending",
                        "failed",
                        "unavailable"
                      ]
                    },
                    "analysis": {
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "structured_data": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/call/{integration_id}/{call_id}/audio": {
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "Get Audio",
        "operationId": "get_audio_v1_call__integration_id___call_id__audio_get",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Id"
            }
          },
          {
            "name": "Range",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "bytes=0-1023"
          }
        ],
        "responses": {
          "200": {
            "description": "Validated MP3 recording",
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          },
          "206": {
            "description": "Validated MP3 recording",
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/call/{integration_id}/{call_id}/cancel": {
      "post": {
        "tags": [
          "v1-public"
        ],
        "summary": "Cancel Call",
        "operationId": "cancel_call_v1_call__integration_id___call_id__cancel_post",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Call Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    },
    "/v1/calls/{integration_id}": {
      "get": {
        "tags": [
          "v1-public"
        ],
        "summary": "List Calls",
        "description": "Stable cursor pagination for reconciliation; each row links to full results.",
        "operationId": "list_calls_v1_calls__integration_id__get",
        "parameters": [
          {
            "name": "integration_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Integration Id"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 50,
              "minimum": 1,
              "default": 20,
              "title": "Limit"
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 36
                },
                {
                  "type": "null"
                }
              ],
              "title": "Before"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Compact owned calls, newest first. Follow next_cursor as before until null.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "items",
                    "next_cursor"
                  ],
                  "properties": {
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "call_id": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "terminal": {
                            "type": "boolean"
                          },
                          "result": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "direction": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "created_at": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "completed_at": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "duration": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "transcript_status": {
                            "type": "string"
                          },
                          "analysis_status": {
                            "type": "string"
                          },
                          "recording": {
                            "type": "object",
                            "properties": {
                              "status": {
                                "enum": [
                                  "available",
                                  "pending",
                                  "unavailable"
                                ]
                              },
                              "url": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "content_type": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            }
                          },
                          "links": {
                            "type": "object",
                            "additionalProperties": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          },
          "401": {
            "description": "Invalid integration credentials"
          },
          "403": {
            "description": "Inactive integration or account"
          },
          "404": {
            "description": "Owned call or recording not found"
          },
          "409": {
            "description": "Conflicting request or dispatch pending"
          },
          "413": {
            "description": "Payload too large"
          },
          "429": {
            "description": "Rate or capacity limit; see Retry-After"
          },
          "503": {
            "description": "Temporary failure or dispatch_unknown; retain call_id and idempotency key"
          }
        },
        "security": [
          {
            "IntegrationBearer": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "IntegrationBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key for the selected integration, issued once in the dashboard"
      }
    },
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "PublicCallRequest": {
        "properties": {
          "phone": {
            "type": "string",
            "maxLength": 32,
            "minLength": 7,
            "title": "Phone"
          },
          "variables": {
            "anyOf": [
              {
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Variables"
          },
          "callback_url": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 500
              },
              {
                "type": "null"
              }
            ],
            "title": "Callback Url"
          }
        },
        "type": "object",
        "required": [
          "phone"
        ],
        "title": "PublicCallRequest"
      },
      "PublicCallResponse": {
        "properties": {
          "call_id": {
            "type": "string",
            "title": "Call Id"
          },
          "status": {
            "type": "string",
            "title": "Status"
          },
          "message": {
            "type": "string",
            "title": "Message"
          }
        },
        "type": "object",
        "required": [
          "call_id",
          "status",
          "message"
        ],
        "title": "PublicCallResponse"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "CallResult": {
        "type": "object",
        "required": [
          "call_id",
          "integration_id",
          "status",
          "direction",
          "phone",
          "transcript_status",
          "analysis_status",
          "result",
          "created_at",
          "started_at",
          "completed_at",
          "transcript",
          "duration",
          "wait_time",
          "talk_time",
          "terminal",
          "variables",
          "structured_data",
          "ai_analysis",
          "recording",
          "links",
          "webhook"
        ],
        "properties": {
          "call_id": {
            "type": "string"
          },
          "integration_id": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "direction": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "transcript_status": {
            "type": "string"
          },
          "analysis_status": {
            "type": "string"
          },
          "result": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "transcript": {
            "type": [
              "string",
              "null"
            ]
          },
          "duration": {
            "type": "integer",
            "minimum": 0
          },
          "wait_time": {
            "type": "integer",
            "minimum": 0
          },
          "talk_time": {
            "type": "integer",
            "minimum": 0
          },
          "terminal": {
            "type": "boolean"
          },
          "variables": {
            "type": "object"
          },
          "structured_data": {
            "type": "object"
          },
          "ai_analysis": {
            "type": [
              "object",
              "null"
            ]
          },
          "recording": {
            "type": "object",
            "properties": {
              "status": {
                "enum": [
                  "available",
                  "pending",
                  "unavailable"
                ]
              },
              "url": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "content_type": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "webhook": {
            "type": "object",
            "properties": {
              "delivered": {
                "type": "boolean"
              }
            }
          }
        }
      }
    }
  }
}
