{
  "openapi": "3.1.0",
  "info": {
    "title": "FormBuilder API",
    "version": "1.0.0",
    "description": "FormBuilder (formbuilder.com) public REST API. Create an account and API key with POST /api/v1/signup (no browser needed), then create and publish forms, list responses and register response webhooks. All authenticated endpoints use `Authorization: Bearer fbpat_...`. Free plan: 5 forms, no card required. Human-readable docs: https://formbuilder.com/developers. MCP server (Streamable HTTP) for AI agents: POST https://api.formbuilder.com/mcp",
    "termsOfService": "https://formbuilder.com/terms",
    "contact": {
      "name": "FormBuilder support",
      "url": "https://formbuilder.com/contact",
      "email": "support@formbuilder.com"
    },
    "x-logo": {
      "url": "https://formbuilder.com/logo.png",
      "altText": "FormBuilder"
    }
  },
  "servers": [
    {
      "url": "https://api.formbuilder.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Onboarding",
      "description": "Account + API key creation for agents and scripts"
    },
    {
      "name": "Forms"
    },
    {
      "name": "Responses"
    },
    {
      "name": "Hooks",
      "description": "Outbound webhooks fired when a response is submitted"
    }
  ],
  "paths": {
    "/api/v1/signup": {
      "post": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Create an account and API key in one call",
        "description": "Creates a free FormBuilder account for the given email and returns an API key with forms:read, forms:write, responses:read and hooks:manage scopes. The email owner receives a claim link to take over the account. Rate limit: 3 per hour per IP. Returns 409 if the email already has an account.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "agent": {
                    "type": "string",
                    "maxLength": 80,
                    "description": "Name of the agent/tool creating the account, e.g. \"claude-code\" or \"chatgpt\". Used for attribution only."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "api_key": {
                      "type": "string",
                      "description": "Store this \u2014 it is only returned once."
                    },
                    "abilities": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "verify_required": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "next": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          },
          "429": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/me": {
      "get": {
        "tags": [
          "Onboarding"
        ],
        "summary": "Validate the API key and return the account",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "plan": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/forms": {
      "get": {
        "tags": [
          "Forms"
        ],
        "summary": "List forms",
        "parameters": [
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Form"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Forms"
        ],
        "summary": "Create a form (optionally publish it)",
        "description": "Requires the forms:write scope. Set publish=true to publish immediately; the form goes through FormBuilder's safety review and may be held (see publish_blocked_reasons). Free plan allows 5 forms.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "title",
                  "fields"
                ],
                "properties": {
                  "title": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "submit_button_text": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "publish": {
                    "type": "boolean",
                    "default": false
                  },
                  "fields": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "$ref": "#/components/schemas/FieldInput"
                    }
                  }
                },
                "example": {
                  "title": "Contact us",
                  "publish": true,
                  "fields": [
                    {
                      "label": "Name",
                      "type": "text",
                      "required": true
                    },
                    {
                      "label": "Email",
                      "type": "email",
                      "required": true
                    },
                    {
                      "label": "How can we help?",
                      "type": "textarea"
                    },
                    {
                      "label": "Topic",
                      "type": "select",
                      "options": [
                        "Sales",
                        "Support",
                        "Other"
                      ]
                    }
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    },
                    "slug": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "draft",
                        "published"
                      ]
                    },
                    "public_url": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "Live form URL when published"
                    },
                    "edit_url": {
                      "type": "string"
                    },
                    "publish_blocked_reasons": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "type": "string"
                      }
                    },
                    "fields": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Error"
          },
          "402": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/forms/{formId}/fields": {
      "get": {
        "tags": [
          "Forms"
        ],
        "summary": "Field schema for a form",
        "parameters": [
          {
            "$ref": "#/components/parameters/formId"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/forms/{formId}/responses": {
      "get": {
        "tags": [
          "Responses"
        ],
        "summary": "List responses for a form (newest first)",
        "description": "Requires responses:read. Responses held by the free-plan cap are returned with locked=true and without field data.",
        "parameters": [
          {
            "$ref": "#/components/parameters/formId"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/hooks": {
      "post": {
        "tags": [
          "Hooks"
        ],
        "summary": "Register a webhook for new responses",
        "description": "Requires hooks:manage and responses:read. FormBuilder POSTs event response.created to target_url for eligible new responses. Omit form_id for all owned forms. Delivery rechecks current token authorization and response eligibility. Keep callback URLs private; receivers should authenticate by retrieving the current response and deduplicate by response ID.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "target_url"
                ],
                "properties": {
                  "target_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "form_id": {
                    "type": "string"
                  },
                  "event": {
                    "type": "string",
                    "enum": [
                      "response.created"
                    ],
                    "default": "response.created"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created"
          },
          "400": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "tags": [
          "Hooks"
        ],
        "summary": "List the current API token\u2019s hooks",
        "description": "Requires hooks:manage and responses:read. Returns only hooks created by this token, including their private callback URLs. Does not reveal another token\u2019s hooks, even for the same owner. Use exact target_url and form_id matching to reconcile an uncertain subscription.",
        "parameters": [
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "event": {
                            "type": "string"
                          },
                          "form_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "target_url": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/hooks/{hookId}": {
      "delete": {
        "tags": [
          "Hooks"
        ],
        "summary": "Delete a webhook",
        "parameters": [
          {
            "name": "hookId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted"
          }
        }
      }
    },
    "/api/v1/forms/{formId}/responses/{responseId}": {
      "get": {
        "tags": [
          "Responses"
        ],
        "summary": "Retrieve one authorized response",
        "description": "Requires responses:read on a current active-owner API token. Foreign or deleted responses return 404; locked, incomplete or unpaid responses return 403. File answers contain authenticated API-relative download paths. Storage URLs are never exposed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/formId"
          },
          {
            "$ref": "#/components/parameters/responseId"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "form": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        }
                      }
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "data": {
                          "type": "object"
                        },
                        "submitted_at": {
                          "type": "string"
                        },
                        "read_at": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "is_test": {
                          "type": "boolean"
                        },
                        "country_code": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "metadata": {
                          "type": [
                            "object",
                            "null"
                          ]
                        },
                        "created_at": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/forms/{formId}/responses/{responseId}/files": {
      "get": {
        "tags": [
          "Responses"
        ],
        "summary": "List committed private attachments",
        "description": "Requires responses:read on a current active-owner API token. Foreign or deleted responses return 404; locked, incomplete or unpaid responses return 403. File answers contain authenticated API-relative download paths. Storage URLs are never exposed.",
        "parameters": [
          {
            "$ref": "#/components/parameters/formId"
          },
          {
            "$ref": "#/components/parameters/responseId"
          },
          {
            "$ref": "#/components/parameters/page"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "form": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "title": {
                          "type": "string"
                        }
                      }
                    },
                    "response_id": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "form_id": {
                            "type": "string"
                          },
                          "response_id": {
                            "type": "string"
                          },
                          "field_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "file_name": {
                            "type": "string"
                          },
                          "file_type": {
                            "type": "string"
                          },
                          "file_size": {
                            "type": "integer"
                          },
                          "created_at": {
                            "type": "string"
                          },
                          "download_path": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "pagination": {
                      "type": "object",
                      "properties": {
                        "page": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/api/v1/forms/{formId}/responses/{responseId}/files/{fileId}/download": {
      "get": {
        "tags": [
          "Responses"
        ],
        "summary": "Download original attachment bytes",
        "description": "Requires responses:read on a current active-owner API token. Foreign or deleted responses return 404; locked, incomplete or unpaid responses return 403. File answers contain authenticated API-relative download paths. Storage URLs are never exposed. Rechecks authorization and committed file identity after storage access. Returns private no-store, attachment Content-Disposition, octet-stream and sandbox CSP. Never redirects.",
        "parameters": [
          {
            "$ref": "#/components/parameters/formId"
          },
          {
            "$ref": "#/components/parameters/responseId"
          },
          {
            "$ref": "#/components/parameters/fileId"
          }
        ],
        "responses": {
          "200": {
            "description": "Original attachment bytes",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Error"
          },
          "403": {
            "$ref": "#/components/responses/Error"
          },
          "404": {
            "$ref": "#/components/responses/Error"
          },
          "409": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Personal access token (fbpat_...). Create one at https://formbuilder.com/developers or via POST /api/v1/signup."
      }
    },
    "parameters": {
      "formId": {
        "name": "formId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "page": {
        "name": "page",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "default": 1
        }
      },
      "limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 50
        }
      },
      "responseId": {
        "name": "responseId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      },
      "fileId": {
        "name": "fileId",
        "in": "path",
        "required": true,
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Form": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "slug": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "is_public": {
            "type": "boolean"
          },
          "response_count": {
            "type": "integer"
          },
          "view_count": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FieldInput": {
        "type": "object",
        "required": [
          "label"
        ],
        "properties": {
          "label": {
            "type": "string",
            "maxLength": 500
          },
          "type": {
            "type": "string",
            "default": "text",
            "enum": [
              "text",
              "email",
              "textarea",
              "select",
              "radio",
              "checkbox",
              "number",
              "date",
              "phone",
              "url",
              "file",
              "rating",
              "signature",
              "nps",
              "matrix",
              "ranking",
              "score",
              "calculation",
              "payment"
            ]
          },
          "required": {
            "type": "boolean",
            "default": false
          },
          "placeholder": {
            "type": "string"
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "For select / radio / checkbox / multiselect"
          },
          "page": {
            "type": "integer",
            "default": 1
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "page": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "total": {
            "type": "integer"
          }
        }
      }
    }
  }
}
