{
  "openapi": "3.1.0",
  "x-lifecycle": "live",
  "info": {
    "title": "Vocaleo API",
    "version": "1",
    "summary": "Give a personal AI assistant the ability to make one phone call and read one result.",
    "description": "Give a personal AI assistant the ability to make phone calls. You send a phone number and a task; Vocaleo makes the call and returns structured facts.",
    "contact": {
      "email": "support@vocaleo.co"
    }
  },
  "servers": [
    {
      "url": "https://api.vocaleo.co",
      "description": "Production."
    }
  ],
  "tags": [
    {
      "name": "accounts",
      "description": "Create an account and read its balance."
    },
    {
      "name": "calls",
      "description": "Place one call and read its result."
    }
  ],
  "paths": {
    "/v1/accounts": {
      "post": {
        "tags": [
          "accounts"
        ],
        "summary": "Create an account.",
        "description": "No authentication. Returns the API key once — store it, it is never shown again — and a payment link for adding credit. Limited to 10 per IP per day.",
        "operationId": "createAccount",
        "security": [],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 120
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountCreated"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "tags": [
          "accounts"
        ],
        "summary": "Read the balance and payment link.",
        "operationId": "getAccount",
        "responses": {
          "200": {
            "description": "The account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/calls": {
      "post": {
        "tags": [
          "calls"
        ],
        "summary": "Start one call.",
        "description": "Admits the call only when the balance covers max_charge_cents_per_call, holds that amount, and dispatches. Send an optional Idempotency-Key header to make retries safe; the same key with a different body returns 409.",
        "operationId": "createCall",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            },
            "description": "Unique per account. Exact replay returns the original call."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCall"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Call accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallAccepted"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient credit. Body carries needed_cents and payment_url.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "422": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          },
          "503": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/v1/calls/{call_id}": {
      "get": {
        "tags": [
          "calls"
        ],
        "summary": "Read status and, when done, the result.",
        "description": "Only the account that placed the call may read it. wait_seconds holds the request open, polling internally, until the call is terminal or the wait runs out.",
        "operationId": "getCall",
        "parameters": [
          {
            "name": "call_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "wait_seconds",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 60,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The call.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallDetail"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "The API key from POST /v1/accounts, sent as a bearer token."
      }
    },
    "responses": {
      "Error": {
        "description": "Error envelope.",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "CallStatus": {
        "type": "string",
        "enum": [
          "queued",
          "in_progress",
          "completed",
          "error"
        ]
      },
      "CallOutcome": {
        "type": "string",
        "enum": [
          "achieved",
          "partial",
          "not_achieved",
          "unclear"
        ]
      },
      "FailureCode": {
        "type": "string",
        "enum": [
          "no_answer",
          "busy",
          "error"
        ]
      },
      "AccountCreated": {
        "type": "object",
        "required": [
          "account_id",
          "api_key",
          "balance_cents",
          "price_cents_per_minute",
          "max_charge_cents_per_call"
        ],
        "properties": {
          "account_id": {
            "type": "string"
          },
          "api_key": {
            "type": "string",
            "description": "Bearer token, prefix vok_. Shown once.",
            "examples": [
              "vok_0123abcd..."
            ]
          },
          "balance_cents": {
            "type": "integer",
            "examples": [
              0
            ]
          },
          "payment_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "price_cents_per_minute": {
            "type": "integer"
          },
          "max_charge_cents_per_call": {
            "type": "integer"
          }
        }
      },
      "AccountDetail": {
        "type": "object",
        "required": [
          "account_id",
          "balance_cents",
          "price_cents_per_minute",
          "max_charge_cents_per_call"
        ],
        "properties": {
          "account_id": {
            "type": "string"
          },
          "balance_cents": {
            "type": "integer"
          },
          "payment_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "price_cents_per_minute": {
            "type": "integer"
          },
          "max_charge_cents_per_call": {
            "type": "integer"
          }
        }
      },
      "CreateCall": {
        "type": "object",
        "required": [
          "to_phone_number",
          "task"
        ],
        "properties": {
          "to_phone_number": {
            "type": "string",
            "pattern": "^\\+[1-9]\\d{1,14}$",
            "description": "E.164. US and Canada only.",
            "examples": [
              "+14155550123"
            ]
          },
          "task": {
            "type": "string",
            "minLength": 1,
            "maxLength": 10000,
            "examples": [
              "Call Lume and book a table for 2 tomorrow at 7pm under Alex Rivera. Accept 6:30-8:00 as fallback."
            ]
          },
          "on_behalf_of": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120,
            "examples": [
              "Alex Rivera"
            ]
          }
        }
      },
      "CallAccepted": {
        "type": "object",
        "properties": {
          "call_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/CallStatus"
          },
          "held_cents": {
            "type": "integer"
          }
        }
      },
      "TranscriptTurn": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "assistant",
              "user"
            ]
          },
          "content": {
            "type": "string"
          }
        }
      },
      "CallDetail": {
        "type": "object",
        "description": "outcome, summary, transcript, and charged_cents are null until the call is terminal.",
        "properties": {
          "call_id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/CallStatus"
          },
          "to_phone_number": {
            "type": "string"
          },
          "task": {
            "type": "string"
          },
          "on_behalf_of": {
            "type": [
              "string",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "ended_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "outcome": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/CallOutcome"
              },
              {
                "type": "null"
              }
            ]
          },
          "summary": {
            "type": [
              "string",
              "null"
            ]
          },
          "transcript": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "$ref": "#/components/schemas/TranscriptTurn"
            }
          },
          "failure": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "$ref": "#/components/schemas/FailureCode"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "held_cents": {
            "type": "integer"
          },
          "charged_cents": {
            "type": [
              "integer",
              "null"
            ]
          },
          "balance_cents": {
            "type": "integer"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "unauthorized",
                  "not_found",
                  "invalid_request",
                  "task_rejected",
                  "insufficient_credit",
                  "rate_limited",
                  "conflict",
                  "temporarily_unavailable",
                  "executor_error"
                ]
              },
              "message": {
                "type": "string"
              }
            }
          },
          "needed_cents": {
            "type": "integer",
            "description": "On 402 insufficient_credit."
          },
          "payment_url": {
            "type": "string",
            "description": "On 402 insufficient_credit."
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ]
}