# Forms

> Create and change form data sources and their questions, and build a form with an assistant.

A [form](https://pulso.run/docs/concepts/data-sources.md#form) is a data source people answer on a page, each answer an event for the monitors on it. The API writes its questions and texts, as the form editor does, and checks them the same way. Creating and changing a form needs `data_sources:write` and an admin; reading one, `data_sources:list`.

## Create a form

```bash
curl -X POST https://pulso.run/api/v1/forms \
  -H "Authorization: Bearer ak_..." -H "Content-Type: application/json" \
  -d '{"name": "Refund requests", "locale": "en", "fields": [
        {"key": "order_number", "label": "Order number", "type": "text", "required": true, "pattern": "[A-Z]{2}-[0-9]+"},
        {"key": "reason", "label": "Reason", "type": "select", "options": ["Duplicate charge", "Fraud", "Other"], "display": "radio"},
        {"key": "details", "label": "What happened?", "type": "textarea", "show_if": {"key": "reason", "op": "is", "value": "Other"}}
      ]}'
```

Answers `201` with `{ "form": … }`, as [Read a form](https://pulso.run/docs/api/forms.md#read-a-form) returns it, `url` being the link to share.

| Field | |
|---|---|
| `name` | Required. The data source's name, and the form's heading unless `title` is set. |
| `title`, `description` | The heading, and the text under it. |
| `submit_label`, `success_message` | The button, and what people see once they answer. Each has a default in the form's language. |
| `locale` | `en` or `es`: the language of the page's own texts and its emails. Write the questions in it too. |
| `fields` | Required. The questions, in order; up to 100. |

Each question is an object with a `type` and, but for a `section`, a `key` and a `label`:

| Setting | |
|---|---|
| `type` | `text`, `textarea`, `number`, `email`, `phone`, `url`, `date`, `select`, `checkboxes`, `boolean`, `rating`, `hidden`, or `section`: a heading between questions. |
| `key` | Names the answer: lowercase letters, digits and `_`, starting with a letter. Monitors read it as `{{signal.key}}`. |
| `label` | The question, or the section's heading. |
| `required`, `help`, `placeholder` | Whether it must be answered, the text under it, and the hint inside it. |
| `options`, `display` | For `select` and `checkboxes`: the choices. A `select` shows them as a `dropdown` (the default) or as `radio` buttons. |
| `min`, `max` | For `number`. |
| `min_length`, `max_length`, `pattern`, `pattern_message` | For `text` and `textarea` the length; for `text` a regular expression the whole answer must match, and the message when it doesn't. |
| `scale` | For `rating`: `stars` (1 to 5, the default) or `nps` (0 to 10). |
| `new_page` | For `section`: starts a new page. |
| `show_if` | Shows it only when a question above matches: `{ "key", "op", "value" }`, `op` being `is`, `is_not`, `filled` or `empty`. |
| `hidden` | A `hidden` question isn't shown: the [link fills it in](https://pulso.run/docs/concepts/data-sources.md#fill-answers-in-from-the-link). |

If a question isn't valid, nothing is saved and it answers `422`: a setting that is unknown, of the wrong type or not for the question's type by its place (`fields[1].options`), and what the editor would point at under `fields`, as `"reason: a choice needs at least one option"`.

To act on the answers, [create a monitor](https://pulso.run/docs/api/monitors.md#create-a-monitor) with the form as `data_source_id` and the key that tells answers apart as `row_identifiers`.

## Read a form

```bash
curl https://pulso.run/api/v1/forms/01M7ZJ3DXSQ8YS1EHDA656QNDK \
  -H "Authorization: Bearer ak_..."
```

```json
{
  "form": {
    "id": "01M7ZJ3DXSQ8YS1EHDA656QNDK",
    "name": "Refund requests",
    "title": null, "description": null, "submit_label": null, "success_message": null, "locale": "en",
    "fields": [{ "key": "order_number", "label": "Order number", "type": "text", "required": true, "options": [] }, …],
    "access": "anyone",
    "closed": false,
    "url": "https://pulso.run/forms/01M7ZJ3DXSQ8YS1EHDA656QNDK/…",
    "monitors": [{ "id": "01M7ZK…", "name": "Refunds to review", "active": true, "reads": ["amount", "order_number"] }],
    "updated_at": "2026-11-20T09:14:02Z"
  }
}
```

`monitors`, with `monitors:read`, are those on the form, with the questions each reads. `url` is the public link, the only gate to a form open to anyone, so it comes only to admins through a key or connection with `data_sources:write`. Who may answer, and closing the form, are set in the app.

## Change a form

`PATCH /api/v1/forms/:id` takes the fields of [Create a form](https://pulso.run/docs/api/forms.md#create-a-form); only those sent change, and `null` clears `title`, `description`, `submit_label` or `success_message`. `fields` replaces the questions: send them all, as read. Answers already given keep theirs.

Monitors read answers by key, so renaming or removing a key one reads (see `monitors`) leaves it without that value. The change is in the data source's audit log, as one made in the editor.

## With an assistant

> **You:** Make a form for customers to ask for a refund: order number, reason, and details when the reason is "Other". Then open a signal for each one.
>
> **Assistant:** *calls `create_form`*
> I created **Refund requests**: <https://pulso.run/forms/…>
>
> *calls `list_categories`, `create_monitor` and `replace_monitor_playbook`*
> And **Refunds to review**, on that form, raising a signal per order number with a task to refund it. It's inactive. Activate it?

`update_form` changes a live form, so it is marked destructive and your client can ask you first.
