{
  "openapi": "3.1.0",
  "info": {
    "title": "Startup25 Call Lab API",
    "version": "1.0.0",
    "description": "Paid AI business-call rehearsals. Use existing Call Lab credits. Only call yourself or a recipient who requested the call."
  },
  "servers": [
    {
      "url": "https://www.startup25.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Seven-day token created at /lab/agent. Password changes revoke tokens."
      }
    }
  },
  "paths": {
    "/api/v1/account": {
      "get": {
        "operationId": "getCredits",
        "responses": {
          "200": {
            "description": "Remaining credits",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calls": {
      "post": {
        "operationId": "placeRehearsalCall",
        "description": "Costs one credit. Use same idempotency key for retries.",
        "parameters": [
          {
            "in": "header",
            "name": "Idempotency-Key",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{8,100}$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "phone",
                  "first_name",
                  "salon_name",
                  "offer_text",
                  "consent"
                ],
                "properties": {
                  "phone": {
                    "type": "string",
                    "description": "Real US/Canada phone number"
                  },
                  "first_name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 40
                  },
                  "salon_name": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 80
                  },
                  "offer_text": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 300
                  },
                  "consent": {
                    "type": "boolean",
                    "const": true
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 600
                  },
                  "voice": {
                    "type": "string",
                    "enum": [
                      "marin",
                      "cedar"
                    ]
                  },
                  "timezone": {
                    "type": "string",
                    "default": "America/New_York"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "Accepted; returns id",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "413": {
            "description": "Body too large",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "Validation, credit or calling restriction",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/calls/{id}": {
      "get": {
        "operationId": "getCall",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Call status and transcript. Poll every five seconds until phase=ended.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  }
}
