{
  "openapi": "3.0.3",
  "info": {
    "title": "TelDev /v1",
    "version": "1.0.0",
    "description": "TelDev is an AI Voice Call Platform. AI voice calls in the browser. 10 live minutes, then Personal $20/175. Telnyx end to end. Twilio is a REST alias only. Trial is not a SKU. Not a carrier."
  },
  "servers": [
    {
      "url": "https://teldev.bot",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "numbers"
    },
    {
      "name": "calls"
    },
    {
      "name": "messages"
    },
    {
      "name": "sessions"
    },
    {
      "name": "devices"
    },
    {
      "name": "events"
    },
    {
      "name": "usage"
    },
    {
      "name": "plans"
    },
    {
      "name": "trial"
    },
    {
      "name": "webrtc"
    }
  ],
  "paths": {
    "/v1/numbers": {
      "post": {
        "tags": [
          "numbers"
        ],
        "summary": "Provision a number",
        "operationId": "createNumber",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required for nl_live_ POST. Same key + same body replays; different body is 409."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "area_code": {
                    "type": "string"
                  },
                  "campaign": {
                    "type": "string"
                  },
                  "quantity": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Number object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Number"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Error 504",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/calls": {
      "post": {
        "tags": [
          "calls"
        ],
        "summary": "Create or control a call",
        "operationId": "postCall",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "trialToken": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required for nl_live_ POST. Same key + same body replays; different body is 409."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": {
                    "type": "string",
                    "enum": [
                      "create",
                      "answer",
                      "hangup",
                      "mute",
                      "unmute",
                      "hold",
                      "unhold"
                    ],
                    "default": "create"
                  },
                  "call": {
                    "type": "string",
                    "description": "call_… id for non-create actions"
                  },
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "description": "E.164, \"device\", \"dev_…\", or { \"device\": \"dev_…\" }",
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "object",
                        "properties": {
                          "device": {
                            "type": "string"
                          }
                        }
                      }
                    ]
                  },
                  "agent": {
                    "type": "string"
                  },
                  "campaign": {
                    "type": "string"
                  },
                  "at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "ISO-8601. Stored as given (no rounding). Fires to a Device on this Account. Timezone default America/Denver. Past or unparseable is 4xx."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Call"
                }
              }
            }
          },
          "201": {
            "description": "Created call",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Call"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Error 402",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Error 504",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/calls/{id}": {
      "get": {
        "tags": [
          "calls"
        ],
        "summary": "Fetch a call",
        "operationId": "getCall",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "call_…"
          }
        ],
        "responses": {
          "200": {
            "description": "Call object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Call"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "tags": [
          "messages"
        ],
        "summary": "Send a message",
        "operationId": "createMessage",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Required for nl_live_ POST. Same key + same body replays; different body is 409."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "from",
                  "to",
                  "body"
                ],
                "properties": {
                  "from": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "body": {
                    "type": "string"
                  },
                  "agent": {
                    "type": "string"
                  },
                  "campaign": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Message object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error 409",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "504": {
            "description": "Error 504",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages/{id}": {
      "get": {
        "tags": [
          "messages"
        ],
        "summary": "Fetch a message",
        "operationId": "getMessage",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "msg_…"
          }
        ],
        "responses": {
          "200": {
            "description": "Message object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Message"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions/{id}": {
      "get": {
        "tags": [
          "sessions"
        ],
        "summary": "Fetch a session",
        "operationId": "getSession",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ses_…"
          }
        ],
        "responses": {
          "200": {
            "description": "Session object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Session"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/sessions/{id}/events": {
      "get": {
        "tags": [
          "sessions"
        ],
        "summary": "SSE stub of session events (not audio)",
        "operationId": "getSessionEvents",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "trialToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "ses_…"
          }
        ],
        "responses": {
          "200": {
            "description": "text/event-stream of Event objects",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error 404",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/devices": {
      "post": {
        "tags": [
          "devices"
        ],
        "summary": "Register a browser Device",
        "operationId": "createDevice",
        "responses": {
          "201": {
            "description": "Device object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Device"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "devices"
        ],
        "summary": "Fetch the reachable Device for this token",
        "operationId": "getDevice",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Device object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Device"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/devices/{id}/push": {
      "post": {
        "tags": [
          "devices"
        ],
        "summary": "Save this Device's Web Push subscription",
        "operationId": "saveDevicePush",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "dev_…"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "subscription"
                ],
                "properties": {
                  "subscription": {
                    "type": "object",
                    "description": "A browser PushSubscription (endpoint + p256dh/auth keys)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Device object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Device"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error 403",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/push/key": {
      "get": {
        "tags": [
          "webrtc"
        ],
        "summary": "VAPID public key for Web Push subscription",
        "operationId": "getPushKey",
        "responses": {
          "200": {
            "description": "Public VAPID key; configured:false when push env is unset",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "configured": {
                      "type": "boolean"
                    },
                    "key": {
                      "type": "string",
                      "nullable": true
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/events": {
      "get": {
        "tags": [
          "events"
        ],
        "summary": "List events after an id",
        "operationId": "listEvents",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "evt_… cursor"
          }
        ],
        "responses": {
          "200": {
            "description": "Event list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventList"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "usage"
        ],
        "summary": "Account usage totals",
        "operationId": "getUsage",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Usage object",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Usage"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/plans": {
      "get": {
        "tags": [
          "plans"
        ],
        "summary": "Locked monthly SKUs",
        "operationId": "getPlans",
        "responses": {
          "200": {
            "description": "Personal / Build / Ship / Scale only. checkout is null. Trial is not a SKU.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/subscribe": {
      "post": {
        "tags": [
          "plans"
        ],
        "summary": "Mock-attach a paid plan to a trial identity",
        "operationId": "subscribePlan",
        "security": [
          {
            "trialToken": []
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "plan"
                ],
                "properties": {
                  "plan": {
                    "type": "string",
                    "enum": [
                      "personal",
                      "build",
                      "ship",
                      "scale"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Trial view after attach",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrialView"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/trial/otp": {
      "post": {
        "tags": [
          "trial"
        ],
        "summary": "Send SMS OTP for a verified E.164",
        "operationId": "requestTrialOtp",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "phone"
                ],
                "properties": {
                  "phone": {
                    "type": "string",
                    "description": "E.164"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OTP challenge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrialOtp"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/trial/verify": {
      "post": {
        "tags": [
          "trial"
        ],
        "summary": "Verify OTP and issue a trl_ token",
        "operationId": "verifyTrialOtp",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "phone",
                  "code"
                ],
                "properties": {
                  "phone": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Trial view plus token. Minutes stay server-side.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrialVerify"
                }
              }
            }
          },
          "400": {
            "description": "Error 400",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/trial": {
      "get": {
        "tags": [
          "trial"
        ],
        "summary": "Remaining seconds and plan for a trl_ identity",
        "operationId": "getTrial",
        "security": [
          {
            "trialToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Trial view",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrialView"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v1/webrtc/token": {
      "post": {
        "tags": [
          "webrtc"
        ],
        "summary": "Mint a Telnyx WebRTC client token",
        "operationId": "mintWebRtcToken",
        "security": [
          {
            "bearerAuth": []
          },
          {
            "trialToken": []
          }
        ],
        "responses": {
          "200": {
            "description": "Client token; mock: true on test / no API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebRtcToken"
                }
              }
            }
          },
          "401": {
            "description": "Error 401",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Error 422",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "nl_test_… or nl_live_…. Live POSTs require Idempotency-Key."
      },
      "trialToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "trl_… trial identity. Trial is not a SKU."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "idempotency_key_required",
                  "invalid_request",
                  "unauthorized",
                  "trial_exhausted",
                  "plan_exhausted",
                  "included_exhausted",
                  "trial_forbidden",
                  "not_found",
                  "idempotency_conflict",
                  "campaign_not_approved",
                  "device_only_plan",
                  "number_not_owned",
                  "agent_not_found",
                  "no_route",
                  "carrier_timeout",
                  "internal_error"
                ]
              },
              "message": {
                "type": "string"
              },
              "details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "Number": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "number"
          },
          "e164": {
            "type": "string"
          },
          "status": {
            "const": "active"
          },
          "campaign": {
            "type": "string",
            "nullable": true
          },
          "account": {
            "type": "string"
          },
          "carrier": {
            "type": "string",
            "description": "telnyx"
          },
          "carrier_ref": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Call": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "call"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "ringing",
              "in_progress",
              "completed",
              "failed",
              "busy",
              "no_answer"
            ]
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "agent": {
            "type": "string",
            "nullable": true
          },
          "session": {
            "type": "string"
          },
          "stream_url": {
            "type": "string",
            "nullable": true
          },
          "campaign": {
            "type": "string",
            "nullable": true
          },
          "account": {
            "type": "string"
          },
          "carrier": {
            "type": "string"
          },
          "carrier_ref": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "muted": {
            "type": "boolean"
          },
          "on_hold": {
            "type": "boolean"
          },
          "identity": {
            "type": "string",
            "nullable": true
          },
          "started_at": {
            "type": "string",
            "nullable": true
          },
          "ended_at": {
            "type": "string",
            "nullable": true
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "fired_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "Message": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "message"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "sending",
              "sent",
              "delivered",
              "failed",
              "undelivered"
            ]
          },
          "from": {
            "type": "string"
          },
          "to": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "agent": {
            "type": "string",
            "nullable": true
          },
          "session": {
            "type": "string"
          },
          "stream_url": {
            "type": "string",
            "nullable": true
          },
          "campaign": {
            "type": "string",
            "nullable": true
          },
          "account": {
            "type": "string"
          },
          "carrier": {
            "type": "string"
          },
          "carrier_ref": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Session": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "session"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "streaming",
              "ended"
            ]
          },
          "call": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "agent": {
            "type": "string",
            "nullable": true
          },
          "stream_url": {
            "type": "string",
            "nullable": true
          },
          "account": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "connected_seconds": {
            "type": "integer"
          },
          "end_reason": {
            "type": "string",
            "nullable": true,
            "enum": [
              "trial_exhausted",
              "plan_exhausted",
              null
            ]
          }
        }
      },
      "Event": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "event"
          },
          "type": {
            "type": "string"
          },
          "data": {
            "type": "object",
            "additionalProperties": true
          },
          "account": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "EventList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Event"
            }
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "object": {
            "const": "usage"
          },
          "billed": {
            "type": "number"
          },
          "carrier": {
            "type": "number"
          },
          "currency": {
            "const": "usd"
          },
          "invoice": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "Plan": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "enum": [
              "personal",
              "build",
              "ship",
              "scale"
            ]
          },
          "object": {
            "const": "plan"
          },
          "name": {
            "type": "string"
          },
          "amount": {
            "type": "number"
          },
          "currency": {
            "const": "usd"
          },
          "interval": {
            "const": "month"
          },
          "kind": {
            "const": "control_plane"
          },
          "included_minutes": {
            "type": "integer",
            "nullable": true
          },
          "overage": {
            "type": "string",
            "nullable": true
          },
          "default_sell": {
            "type": "boolean"
          }
        }
      },
      "PlanList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Plan"
            }
          },
          "usage": {
            "const": "telnyx_list_plus_spread"
          },
          "checkout": {
            "type": "string",
            "nullable": true
          },
          "billing": {
            "type": "object",
            "additionalProperties": true
          },
          "ship_example": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "TrialView": {
        "type": "object",
        "properties": {
          "object": {
            "const": "trial"
          },
          "phone": {
            "type": "string"
          },
          "remaining_seconds": {
            "type": "integer"
          },
          "plan": {
            "type": "string",
            "nullable": true,
            "enum": [
              "personal",
              "build",
              "ship",
              "scale",
              null
            ]
          },
          "trial_exhausted": {
            "type": "boolean"
          },
          "included_exhausted": {
            "type": "boolean"
          },
          "calls_allowed": {
            "type": "boolean"
          },
          "ip_warning": {
            "type": "boolean"
          },
          "included_minutes": {
            "type": "integer",
            "nullable": true
          }
        }
      },
      "TrialOtp": {
        "type": "object",
        "properties": {
          "object": {
            "const": "trial_otp"
          },
          "phone": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer"
          },
          "mock": {
            "type": "boolean"
          },
          "code": {
            "type": "string",
            "description": "Present only when mock (no Telnyx key)"
          }
        }
      },
      "TrialVerify": {
        "allOf": [
          {
            "$ref": "#/components/schemas/TrialView"
          },
          {
            "type": "object",
            "properties": {
              "token": {
                "type": "string"
              }
            }
          }
        ]
      },
      "Device": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "device"
          },
          "session": {
            "type": "string"
          },
          "stream_url": {
            "type": "string",
            "nullable": true
          },
          "handle": {
            "type": "string",
            "nullable": true,
            "description": "Websocket handle"
          },
          "account": {
            "type": "string"
          },
          "last_seen": {
            "type": "string",
            "format": "date-time"
          },
          "reachable": {
            "type": "boolean"
          },
          "token": {
            "type": "string"
          },
          "incoming": {
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebRtcToken": {
        "type": "object",
        "properties": {
          "object": {
            "const": "webrtc_token"
          },
          "token": {
            "type": "string"
          },
          "mock": {
            "type": "boolean"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}