# Forms

> The store's forms (D705): read, made and changed with forms:write; their responses read with the right to read customers.

| Operation | Method and path | Scope |
|---|---|---|
| [List forms](https://docs.kaizenaflow.com/reference/admin-api/forms#forms-list) | `GET /forms` | [`forms:read`](https://docs.kaizenaflow.com/reference/scopes#forms-read) |
| [Get a form](https://docs.kaizenaflow.com/reference/admin-api/forms#forms-get) | `GET /forms/{id}` | [`forms:read`](https://docs.kaizenaflow.com/reference/scopes#forms-read) |
| [List a form's responses](https://docs.kaizenaflow.com/reference/admin-api/forms#forms-responses) | `GET /forms/{id}/responses` | [`forms:read`](https://docs.kaizenaflow.com/reference/scopes#forms-read) |
| [Make a form](https://docs.kaizenaflow.com/reference/admin-api/forms#forms-create) | `POST /forms` | [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write) |
| [Change a form](https://docs.kaizenaflow.com/reference/admin-api/forms#forms-update) | `PATCH /forms/{id}` | [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write) |

## List forms {#forms-list}

`GET https://kaizenaflow.com/api/admin/v1/forms`

The store's forms (D705), archived last, newest change first, with their responses counted.

- **Operation:** `forms.list`
- **Scope:** [`forms:read`](https://docs.kaizenaflow.com/reference/scopes#forms-read), or [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write), which reads too
- **Answers:** `200`, the answer under `data`.

### Answer {#forms-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].name` | string | The owner's name for it; never shown on the site. |
| `data[].kind` | one of `message`, `signup` | A message form, or a newsletter sign-up. |
| `data[].status` | one of `active`, `archived` | archived: it shows nothing on the site and takes no responses. |
| `data[].questions` | integer | How many questions it asks (a sign-up's own email and name not counted). |
| `data[].responses` | integer |   |
| `data[].unread` | integer | Responses not yet opened in the admin. |
| `data[].last_response_at` | string (date-time) or null |   |
| `data[].updated_at` | string (date-time) |   |

### Errors {#forms-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#forms-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/forms' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/forms", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/forms",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Get a form {#forms-get}

`GET https://kaizenaflow.com/api/admin/v1/forms/{id}`

One form with its draft: what it asks, its words in every language, who it emails and how long it keeps responses.

- **Operation:** `forms.get`
- **Scope:** [`forms:read`](https://docs.kaizenaflow.com/reference/scopes#forms-read), or [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write), which reads too
- **Answers:** `200`, the answer under `data`.

### Path parameters {#forms-get-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#forms-get-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.name` | string | The owner's name for it; never shown on the site. |
| `data.kind` | one of `message`, `signup` | A message form, or a newsletter sign-up. |
| `data.status` | one of `active`, `archived` | archived: it shows nothing on the site and takes no responses. |
| `data.questions` | integer | How many questions it asks (a sign-up's own email and name not counted). |
| `data.responses` | integer |   |
| `data.unread` | integer | Responses not yet opened in the admin. |
| `data.last_response_at` | string (date-time) or null |   |
| `data.updated_at` | string (date-time) |   |
| `data.made_from` | string or null | `starter:{key}` or `template:{id}`: what it was made from. Never a link that changes it. |
| `data.draft` | map of string to any | The form as the editor keeps it (kind, name, questions with their words per language, words, delivery, signup, keepMonths): what `PATCH` takes back whole. |

### Errors {#forms-get-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#forms-get-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## List a form's responses {#forms-responses}

`GET https://kaizenaflow.com/api/admin/v1/forms/{id}/responses`

What visitors sent with the form, newest first, as the Responses tab shows them. A response is a person's data: it needs the right to read customers, and goes after the form's own months.

- **Operation:** `forms.responses`
- **Scope:** [`forms:read`](https://docs.kaizenaflow.com/reference/scopes#forms-read), or [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write), which reads too
- **Answers:** `200`, a page: the rows under `data`, and `next` for the page after.
- **Pages:** at most 100 rows, 50 when `limit` is left out; give an answer's `next` as `?after=` for the page after.

### Path parameters {#forms-responses-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Query parameters {#forms-responses-query}

| Name | Type | Required | Description |
|---|---|---|---|
| `limit` | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
| `after` | string, at most 200 characters | no | The `next` cursor of the page before; the first page when left out. |

### Answer {#forms-responses-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].answers` | list of objects | What the visitor answered, labelled in the owner's language, in the form's order. |
| `data[].answers[].label` | string |   |
| `data[].answers[].value` | string |   |
| `data[].contact_email` | string or null | The first email address answered, lower case. |
| `data[].path` | string | The page it was sent from. |
| `data[].locale` | string |   |
| `data[].state` | one of `new`, `read`, `archived` |   |
| `data[].delivery` | one of `sent`, `logged`, `failed`, `inbox` | How it reached the store: emailed (sent, or only logged without email settings), the email failed, or the support inbox. |
| `data[].created_at` | string (date-time) |   |
| `next` | string or null | The cursor of the next page, given as `?after=`; null on the last page. |

### Errors {#forms-responses-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#forms-responses-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/responses' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/responses", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/responses",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Make a form {#forms-create}

`POST https://kaizenaflow.com/api/admin/v1/forms`

Makes a form from a template, or whole from a draft. It shows on the site only once a page's Form component places it.

- **Operation:** `forms.create`
- **Scope:** [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write)
- **Answers:** `201`, made: the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Body {#forms-create-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `template_id` | string (uuid) | no | A form template the store may use (its own, its owner's other stores', Kaizena Flow's or the marketplace's): the form is made from it in the store's languages, sending to the store's contact address. |
| `draft` | map of string to any | no | The form whole, as `GET` answers its `draft`; the editor's own checks run on it. |

### Answer {#forms-create-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.name` | string | The owner's name for it; never shown on the site. |
| `data.kind` | one of `message`, `signup` | A message form, or a newsletter sign-up. |
| `data.status` | one of `active`, `archived` | archived: it shows nothing on the site and takes no responses. |
| `data.questions` | integer | How many questions it asks (a sign-up's own email and name not counted). |
| `data.responses` | integer |   |
| `data.unread` | integer | Responses not yet opened in the admin. |
| `data.last_response_at` | string (date-time) or null |   |
| `data.updated_at` | string (date-time) |   |
| `data.made_from` | string or null | `starter:{key}` or `template:{id}`: what it was made from. Never a link that changes it. |
| `data.draft` | map of string to any | The form as the editor keeps it (kind, name, questions with their words per language, words, delivery, signup, keepMonths): what `PATCH` takes back whole. |

### Errors {#forms-create-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#forms-create-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/forms' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"template_id":"41872e6b-c6f6-44b6-9980-f2f41db16bc9"}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/forms", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "template_id": "41872e6b-c6f6-44b6-9980-f2f41db16bc9"
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/forms",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "template_id": "41872e6b-c6f6-44b6-9980-f2f41db16bc9",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Change a form {#forms-update}

`PATCH https://kaizenaflow.com/api/admin/v1/forms/{id}`

Saves the form's draft whole: a page that places it shows the change at once.

- **Operation:** `forms.update`
- **Scope:** [`forms:write`](https://docs.kaizenaflow.com/reference/scopes#forms-write)
- **Answers:** `200`, the answer under `data`.

### Path parameters {#forms-update-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#forms-update-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `draft` | map of string to any | yes | The form whole, as `GET` answers its `draft` (read it first); its kind never changes. The editor's own checks run on it. |

### Answer {#forms-update-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.name` | string | The owner's name for it; never shown on the site. |
| `data.kind` | one of `message`, `signup` | A message form, or a newsletter sign-up. |
| `data.status` | one of `active`, `archived` | archived: it shows nothing on the site and takes no responses. |
| `data.questions` | integer | How many questions it asks (a sign-up's own email and name not counted). |
| `data.responses` | integer |   |
| `data.unread` | integer | Responses not yet opened in the admin. |
| `data.last_response_at` | string (date-time) or null |   |
| `data.updated_at` | string (date-time) |   |
| `data.made_from` | string or null | `starter:{key}` or `template:{id}`: what it was made from. Never a link that changes it. |
| `data.draft` | map of string to any | The form as the editor keeps it (kind, name, questions with their words per language, words, delivery, signup, keepMonths): what `PATCH` takes back whole. |

### Errors {#forms-update-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#forms-update-example}

**curl**

```shell
curl -X PATCH 'https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"draft":{"example":"example"}}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "draft": {
      "example": "example"
    }
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/forms/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    method="PATCH",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "draft": {
            "example": "example",
        },
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/forms · made from the API contract 1.57
