# Faddy API

Use the Faddy API from your own app, script or AI tool: send responses to a form, read responses, and read, create and edit forms.

- Base URL: `https://console.faddy.app/api/v1`
- Create a key in Faddy → **Profile settings → API & AI → API keys**. It looks like `fdy_` + 40 characters.
- Send it in the `Authorization` header: `Authorization: Bearer fdy_…` (or `X-Faddy-Key: fdy_…` if your tool can't set `Authorization`).
- A key is **yours**: it acts as you, with your role, in every workspace you're a member of. Leave a workspace and the key stops working there. Revoke it any time; it stops at once.
- Keys never delete forms or responses.

## Permissions

Pick them when you create the key.

| Permission | Scope | Allows |
|---|---|---|
| Create responses | `submissions:write` | `POST /forms/{id}/submissions` |
| Read responses | `submissions:read` | `GET /forms/{id}/submissions`, `GET /forms/{id}/summary` |
| Read form fields | `forms:read` | `GET /forms/{id}`, `GET /forms`, `GET /forms/{id}/doc`, `GET /workspaces` |
| Edit forms (for AI assistants) | `forms:write` | Everything `forms:read` allows, plus creating, editing, publishing, unpublishing and duplicating forms |

## Send a response

Each form's **Integrations → Incoming webhook** shows its endpoint, its field keys and a ready-to-run example.

```sh
curl -X POST https://console.faddy.app/api/v1/forms/FORM_ID/submissions \
  -H "Authorization: Bearer fdy_…" \
  -H "Content-Type: application/json" \
  -d '{"answers": {"email": "ada@example.com"}, "idempotency_key": "ticket-123"}'
```

A response sent this way is checked like one typed into the form, shows up in Submissions, and triggers the form's emails, webhooks and integrations. Send the same `idempotency_key` again within 24 hours and nothing is stored twice.

## Read

- `GET /workspaces`: the workspaces your key works in, with your role.
- `GET /forms?q=&status=draft|published&workspace_id=&cursor=&limit=`: your forms, most recently edited first.
- `GET /forms/{id}`: the fields a form takes.
- `GET /forms/{id}/doc`: the full form (draft), its version and editor URL.
- `GET /forms/{id}/submissions?cursor=&limit=&since=&until=`: responses, newest first.
- `GET /forms/{id}/summary`: a summary of the answers.

## Create and edit forms

- `POST /forms {title?, doc?, workspace_id?}`: a new **draft**. Send `workspace_id` when you're in more than one workspace.
- `PUT /forms/{id}/doc {doc, version}`: save the draft. A different current version answers `409 version_conflict` with the latest form.
- `POST /forms/{id}/publish`, `POST /forms/{id}/unpublish`, `POST /forms/{id}/duplicate`.

## Errors

| Status | Meaning |
|---|---|
| 401 | The key is missing, wrong or revoked |
| 403 | The key lacks a permission, or your role doesn't allow it |
| 404 | No such form in your workspaces |
| 422 | The request didn't pass the checks (the answer says which field) |
| 429 | Too many requests: wait `Retry-After` seconds |

Limits: 60 requests a minute per key.

## AI agents

To let Claude, ChatGPT, Codex, Cursor or another agent build forms for you, connect it over MCP instead: see [agent-setup.md](https://console.faddy.app/agent-setup.md), or Profile settings → API & AI in Faddy.
