{
  "openapi": "3.1.0",
  "info": {
    "title": "CallForMe API",
    "version": "1.0.0",
    "description": "Let your agent call businesses for you. $1 per answered call (includes the first 5 minutes), then 25¢ a minute. No charge if nobody answers. Prepaid: add $10.00 to start; it auto-reloads when you drop under $2.00 (you can turn that off)."
  },
  "servers": [
    {
      "url": "https://callforme.tel"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "cfm_... key. Optional: without it, POST /v1/calls returns 402 with a setup link."
      }
    }
  },
  "security": [
    {
      "bearer": []
    },
    {}
  ],
  "paths": {
    "/v1/calls": {
      "post": {
        "operationId": "placeCall",
        "summary": "Place a call (201 calling, 402 needs_setup with setup_url, 400 invalid, 403 blocked)",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "phone",
                  "goal"
                ],
                "properties": {
                  "phone": {
                    "type": "string"
                  },
                  "goal": {
                    "type": "string"
                  },
                  "business_name": {
                    "type": "string"
                  },
                  "details": {
                    "type": "string"
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "on_behalf_of": {
                    "type": "string"
                  },
                  "callback_number": {
                    "type": "string"
                  },
                  "constraints": {
                    "type": "string"
                  },
                  "voicemail_message": {
                    "type": "string"
                  },
                  "transfer_to": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  },
                  "setup_code": {
                    "type": "string",
                    "description": "From a 402 needs_setup response, after the user completed the link"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Calling"
          },
          "402": {
            "description": "Needs setup: show setup_url to the user"
          }
        }
      },
      "get": {
        "operationId": "listCalls",
        "summary": "Recent calls",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/calls/plan": {
      "post": {
        "operationId": "planCall",
        "summary": "Preview a call, no account needed",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "phone",
                  "goal"
                ],
                "properties": {
                  "phone": {
                    "type": "string"
                  },
                  "goal": {
                    "type": "string"
                  },
                  "business_name": {
                    "type": "string"
                  },
                  "details": {
                    "type": "string"
                  },
                  "questions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "on_behalf_of": {
                    "type": "string"
                  },
                  "callback_number": {
                    "type": "string"
                  },
                  "constraints": {
                    "type": "string"
                  },
                  "voicemail_message": {
                    "type": "string"
                  },
                  "transfer_to": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  },
                  "setup_code": {
                    "type": "string",
                    "description": "From a 402 needs_setup response, after the user completed the link"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Plan"
          }
        }
      }
    },
    "/v1/calls/{id}": {
      "get": {
        "operationId": "getCall",
        "summary": "Status, transcript, pending_question, outcome. ?wait=45 long-polls.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "wait",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Call"
          }
        }
      }
    },
    "/v1/calls/{id}/answer": {
      "post": {
        "operationId": "answerQuestion",
        "summary": "Answer the business's pending question",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "answer": {
                    "type": "string"
                  }
                },
                "required": [
                  "answer"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Delivered"
          }
        }
      }
    },
    "/v1/calls/{id}/hangup": {
      "post": {
        "operationId": "hangUp",
        "summary": "End a call",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/businesses": {
      "get": {
        "operationId": "findBusiness",
        "summary": "Find businesses (phone, hours, open now)",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "near",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Results"
          }
        }
      }
    },
    "/v1/account": {
      "get": {
        "operationId": "account",
        "summary": "Balance",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/v1/pricing": {
      "get": {
        "operationId": "pricing",
        "summary": "Pricing",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}