# Update forms

URL: https://docs.hanzo.ai/docs/openapi/form/update-form

> Changes the parts of a form the body names and keeps the rest, then answers it as stored.

`PATCH /v1/form/forms/{id}`

> [Form →](https://docs.hanzo.ai/docs/openapi/form) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                           |
| ------------- | ----------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/form/forms/{id}` |
| **Method**    | `PATCH`                                   |
| **Operation** | `update_form`                             |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`    |

Changes the parts of a form the body names and keeps the rest, then answers it
as stored. The whole form is checked as it will be, exactly as a replace is.
An org admin only.

## Request

58 fields, body `application/json` (required).

| Field                             | In   | Type             | Required | Description                                                                                                                                                                 |
| --------------------------------- | ---- | ---------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                              | path | string           | yes      | ID is the form's id or its slug, from the path.                                                                                                                             |
| `fields`                          | body | form.Field\[]    | —        |                                                                                                                                                                             |
| `fields[].choices`                | body | form.Choice\[]   | —        | Choices are what a multiple\_choice or dropdown field offers, in order.                                                                                                     |
| `fields[].choices[].id`           | body | string           | —        | ID is the choice's id, assigned when empty.                                                                                                                                 |
| `fields[].choices[].label`        | body | string           | —        | Label is the choice as shown.                                                                                                                                               |
| `fields[].choices[].ref`          | body | string           | —        | Ref is how an answer names the choice; unique in the field, defaults to the id.                                                                                             |
| `fields[].description`            | body | string           | —        | Description is the line under the question.                                                                                                                                 |
| `fields[].id`                     | body | string           | —        | ID is the field's id: assigned when a write leaves it empty, and kept across edits by sending it back.                                                                      |
| `fields[].labels`                 | body | form.Labels      | —        |                                                                                                                                                                             |
| `fields[].labels.center`          | body | string           | —        |                                                                                                                                                                             |
| `fields[].labels.left`            | body | string           | —        |                                                                                                                                                                             |
| `fields[].labels.right`           | body | string           | —        |                                                                                                                                                                             |
| `fields[].multiple`               | body | boolean          | —        | Multiple is whether a multiple\_choice field takes several choices.                                                                                                         |
| `fields[].ref`                    | body | string           | —        | Ref is the field's stable name, how an answer and a sink name it: lowercase letters, digits, dash and underscore, at most 64, unique in the form.                           |
| `fields[].required`               | body | boolean          | —        | Required is whether a completed response must answer it.                                                                                                                    |
| `fields[].start`                  | body | integer (int64)  | —        | Start is where an opinion\_scale begins: 0 (the default) or 1.                                                                                                              |
| `fields[].steps`                  | body | integer (int64)  | —        | Steps is how many points a rating (3 to 10, default 5) or an opinion\_scale (5 to 11, default 11) has.                                                                      |
| `fields[].title`                  | body | string           | —        | Title is the question as asked.                                                                                                                                             |
| `fields[].type`                   | body | string           | —        | Type is one of short\_text, long\_text, email, phone, url, number, rating, opinion\_scale, yes\_no, multiple\_choice, dropdown, date and statement.                         |
| `fields[].validations`            | body | form.Validations | —        |                                                                                                                                                                             |
| `fields[].validations.max_length` | body | integer (int64)  | —        | MaxLength is the most characters a text answer holds, at most the platform's bound for the type.                                                                            |
| `fields[].validations.max_value`  | body | number (double)  | —        | MaxValue is the most a number answer may be.                                                                                                                                |
| `fields[].validations.min_value`  | body | number (double)  | —        | MinValue is the least a number answer may be.                                                                                                                               |
| `hidden`                          | body | string\[]        | —        |                                                                                                                                                                             |
| `id`                              | body | string           | —        | ID is the form's id or its slug, from the path.                                                                                                                             |
| `kind`                            | body | string           | —        |                                                                                                                                                                             |
| `settings`                        | body | form.Options     | —        |                                                                                                                                                                             |
| `settings.identity`               | body | string           | —        | Identity is who a response is from when nobody is signed in.                                                                                                                |
| `settings.language`               | body | string           | —        | Language is the form's language, a tag like en or pt-BR.                                                                                                                    |
| `settings.mode`                   | body | string           | —        | Mode is one (a question at a time, the default) or all (every question at once).                                                                                            |
| `settings.progress`               | body | boolean          | —        | Progress is whether the renderer shows a progress bar.                                                                                                                      |
| `settings.visibility`             | body | string           | —        | Visibility is public (answerable at its public address by anyone) or private (not served there).                                                                            |
| `sinks`                           | body | form.Sinks       | —        |                                                                                                                                                                             |
| `sinks.crm`                       | body | form.CRM         | —        |                                                                                                                                                                             |
| `sinks.crm.company`               | body | string           | —        | Company is the ref of the field whose answer is the person's company.                                                                                                       |
| `sinks.crm.email`                 | body | string           | —        | Email is the ref of the field whose answer is the person's address.                                                                                                         |
| `sinks.crm.list`                  | body | string           | —        | List is the CRM list the person joins, by name (a subscribe form's mailing list).                                                                                           |
| `sinks.crm.name`                  | body | string           | —        | Name is the ref of the field whose answer is the person's name.                                                                                                             |
| `sinks.events`                    | body | boolean          | —        | Events states form\_viewed, form\_started and form\_submitted on the deployment's event stream: the form's ids and the refs of the fields answered, never an answer's text. |
| `sinks.forward`                   | body | form.Forward     | —        |                                                                                                                                                                             |
| `sinks.forward.email`             | body | string           | —        | Email is the address.                                                                                                                                                       |
| `sinks.forward.name`              | body | string           | —        | Name is who it is, for the greeting.                                                                                                                                        |
| `sinks.welcome`                   | body | form.Welcome     | —        |                                                                                                                                                                             |
| `sinks.welcome.body`              | body | string           | —        | Body is the mail's text: plain text, a blank line a new paragraph.                                                                                                          |
| `sinks.welcome.subject`           | body | string           | —        | Subject is the mail's subject.                                                                                                                                              |
| `tags`                            | body | string\[]        | —        |                                                                                                                                                                             |
| `thanks`                          | body | form.Screen      | —        |                                                                                                                                                                             |
| `thanks.button`                   | body | string           | —        | Button is the button's label.                                                                                                                                               |
| `thanks.description`              | body | string           | —        | Description is the text under it.                                                                                                                                           |
| `thanks.redirect`                 | body | string           | —        | Redirect is where a thank-you screen sends the respondent instead of showing itself: an https address.                                                                      |
| `thanks.title`                    | body | string           | —        | Title is the screen's heading.                                                                                                                                              |
| `theme`                           | body | string           | —        |                                                                                                                                                                             |
| `title`                           | body | string           | —        |                                                                                                                                                                             |
| `welcome`                         | body | form.Screen      | —        |                                                                                                                                                                             |
| `welcome.button`                  | body | string           | —        | Button is the button's label.                                                                                                                                               |
| `welcome.description`             | body | string           | —        | Description is the text under it.                                                                                                                                           |
| `welcome.redirect`                | body | string           | —        | Redirect is where a thank-you screen sends the respondent instead of showing itself: an https address.                                                                      |
| `welcome.title`                   | body | string           | —        | Title is the screen's heading.                                                                                                                                              |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     | form.Form       | ok      |
| `default` | problem-details | refused |

`200` body — 61 fields.

| Field                             | In   | Type             | Always | Description                                                                                                                                                                 |
| --------------------------------- | ---- | ---------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `created`                         | body | string           | —      | Created is when the form was made, RFC 3339.                                                                                                                                |
| `fields`                          | body | form.Field\[]    | —      | Fields are the questions, in the order they are asked.                                                                                                                      |
| `fields[].choices`                | body | form.Choice\[]   | —      | Choices are what a multiple\_choice or dropdown field offers, in order.                                                                                                     |
| `fields[].choices[].id`           | body | string           | —      | ID is the choice's id, assigned when empty.                                                                                                                                 |
| `fields[].choices[].label`        | body | string           | —      | Label is the choice as shown.                                                                                                                                               |
| `fields[].choices[].ref`          | body | string           | —      | Ref is how an answer names the choice; unique in the field, defaults to the id.                                                                                             |
| `fields[].description`            | body | string           | —      | Description is the line under the question.                                                                                                                                 |
| `fields[].id`                     | body | string           | —      | ID is the field's id: assigned when a write leaves it empty, and kept across edits by sending it back.                                                                      |
| `fields[].labels`                 | body | form.Labels      | —      |                                                                                                                                                                             |
| `fields[].labels.center`          | body | string           | —      |                                                                                                                                                                             |
| `fields[].labels.left`            | body | string           | —      |                                                                                                                                                                             |
| `fields[].labels.right`           | body | string           | —      |                                                                                                                                                                             |
| `fields[].multiple`               | body | boolean          | —      | Multiple is whether a multiple\_choice field takes several choices.                                                                                                         |
| `fields[].ref`                    | body | string           | —      | Ref is the field's stable name, how an answer and a sink name it: lowercase letters, digits, dash and underscore, at most 64, unique in the form.                           |
| `fields[].required`               | body | boolean          | —      | Required is whether a completed response must answer it.                                                                                                                    |
| `fields[].start`                  | body | integer (int64)  | —      | Start is where an opinion\_scale begins: 0 (the default) or 1.                                                                                                              |
| `fields[].steps`                  | body | integer (int64)  | —      | Steps is how many points a rating (3 to 10, default 5) or an opinion\_scale (5 to 11, default 11) has.                                                                      |
| `fields[].title`                  | body | string           | —      | Title is the question as asked.                                                                                                                                             |
| `fields[].type`                   | body | string           | —      | Type is one of short\_text, long\_text, email, phone, url, number, rating, opinion\_scale, yes\_no, multiple\_choice, dropdown, date and statement.                         |
| `fields[].validations`            | body | form.Validations | —      |                                                                                                                                                                             |
| `fields[].validations.max_length` | body | integer (int64)  | —      | MaxLength is the most characters a text answer holds, at most the platform's bound for the type.                                                                            |
| `fields[].validations.max_value`  | body | number (double)  | —      | MaxValue is the most a number answer may be.                                                                                                                                |
| `fields[].validations.min_value`  | body | number (double)  | —      | MinValue is the least a number answer may be.                                                                                                                               |
| `hidden`                          | body | string\[]        | —      | Hidden names the values a page passes in when it embeds the form (a video id, a plan): lowercase letters, digits and underscores, at most 32 each.                          |
| `id`                              | body | string           | —      | ID is the form's id: 15 lowercase hex characters, derived from the slug when the form has one, so a slug names one form for good.                                           |
| `kind`                            | body | string           | —      | Kind is form (every submission is a response, the default) or subscribe (a mailing list: an email field is required and one address is one response).                       |
| `public_id`                       | body | string           | —      | PublicID is the address the form is answered at: "\<org>.\<slug or id>", as GET /v1/form/public/{id} and POST /v1/form/public/{id}/responses take it.                       |
| `settings`                        | body | form.Options     | —      |                                                                                                                                                                             |
| `settings.identity`               | body | string           | —      | Identity is who a response is from when nobody is signed in.                                                                                                                |
| `settings.language`               | body | string           | —      | Language is the form's language, a tag like en or pt-BR.                                                                                                                    |
| `settings.mode`                   | body | string           | —      | Mode is one (a question at a time, the default) or all (every question at once).                                                                                            |
| `settings.progress`               | body | boolean          | —      | Progress is whether the renderer shows a progress bar.                                                                                                                      |
| `settings.visibility`             | body | string           | —      | Visibility is public (answerable at its public address by anyone) or private (not served there).                                                                            |
| `sinks`                           | body | form.Sinks       | —      |                                                                                                                                                                             |
| `sinks.crm`                       | body | form.CRM         | —      |                                                                                                                                                                             |
| `sinks.crm.company`               | body | string           | —      | Company is the ref of the field whose answer is the person's company.                                                                                                       |
| `sinks.crm.email`                 | body | string           | —      | Email is the ref of the field whose answer is the person's address.                                                                                                         |
| `sinks.crm.list`                  | body | string           | —      | List is the CRM list the person joins, by name (a subscribe form's mailing list).                                                                                           |
| `sinks.crm.name`                  | body | string           | —      | Name is the ref of the field whose answer is the person's name.                                                                                                             |
| `sinks.events`                    | body | boolean          | —      | Events states form\_viewed, form\_started and form\_submitted on the deployment's event stream: the form's ids and the refs of the fields answered, never an answer's text. |
| `sinks.forward`                   | body | form.Forward     | —      |                                                                                                                                                                             |
| `sinks.forward.email`             | body | string           | —      | Email is the address.                                                                                                                                                       |
| `sinks.forward.name`              | body | string           | —      | Name is who it is, for the greeting.                                                                                                                                        |
| `sinks.welcome`                   | body | form.Welcome     | —      |                                                                                                                                                                             |
| `sinks.welcome.body`              | body | string           | —      | Body is the mail's text: plain text, a blank line a new paragraph.                                                                                                          |
| `sinks.welcome.subject`           | body | string           | —      | Subject is the mail's subject.                                                                                                                                              |
| `slug`                            | body | string           | —      | Slug is the form's own name within its org: lowercase letters, digits and dashes, at most 64.                                                                               |
| `tags`                            | body | string\[]        | —      | Tags label the form for its org: at most 20, each at most 64 characters.                                                                                                    |
| `thanks`                          | body | form.Screen      | —      |                                                                                                                                                                             |
| `thanks.button`                   | body | string           | —      | Button is the button's label.                                                                                                                                               |
| `thanks.description`              | body | string           | —      | Description is the text under it.                                                                                                                                           |
| `thanks.redirect`                 | body | string           | —      | Redirect is where a thank-you screen sends the respondent instead of showing itself: an https address.                                                                      |
| `thanks.title`                    | body | string           | —      | Title is the screen's heading.                                                                                                                                              |
| `theme`                           | body | string           | —      | Theme is the id of the theme the form is drawn in.                                                                                                                          |
| `title`                           | body | string           | —      | Title is the form's name, as a respondent and the CRM timeline read it.                                                                                                     |
| `updated`                         | body | string           | —      | Updated is when it last changed, RFC 3339.                                                                                                                                  |
| `welcome`                         | body | form.Screen      | —      |                                                                                                                                                                             |
| `welcome.button`                  | body | string           | —      | Button is the button's label.                                                                                                                                               |
| `welcome.description`             | body | string           | —      | Description is the text under it.                                                                                                                                           |
| `welcome.redirect`                | body | string           | —      | Redirect is where a thank-you screen sends the respondent instead of showing itself: an https address.                                                                      |
| `welcome.title`                   | body | string           | —      | Title is the screen's heading.                                                                                                                                              |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo form forms update <id>
```

**SDK**

**.ts**

```ts
import { Configuration, FormApi } from 'hanzoai';

const api = new FormApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.updateForm({ id: 'id', fields: [{"choices":[{"id":null,"label":null,"ref":null}],"description":"<description>","id":"<id>","labels":{"center":"<center>","left":"<left>","right":"<right>"}}], hidden: ["<hidden>"] });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import FormApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = FormApi(client).update_form(id='id', fields=[{"choices":[{"id":null,"label":null,"ref":null}],"description":"<description>","id":"<id>","labels":{"center":"<center>","left":"<left>","right":"<right>"}}], hidden=["<hidden>"])
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.FormAPI.UpdateForm(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, form_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = form_api::update_form(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.FormApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new FormApi(client).updateForm();
```

The method above is the one at the current release of the document. `hanzoai@8.5.914` (npm) and `hanzoai@8.5.914` (PyPI) were generated from an earlier release, where this operation carried a different id, so it spells the method differently — regenerating the clients is what makes the two agree. [SDKs →](https://docs.hanzo.ai/docs/sdks)

**HTTP**

```bash
curl -X PATCH https://api.hanzo.ai/v1/form/forms/<id> \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "fields": [
         {
           "choices": [
             {
               "id": null,
               "label": null,
               "ref": null
             }
           ],
           "description": "<description>",
           "id": "<id>",
           "labels": {
             "center": "<center>",
             "left": "<left>",
             "right": "<right>"
           }
         }
       ],
       "hidden": [
         "<hidden>"
       ]
     }'
```

**MCP**

Tool `form`, op `update_form` — POST the JSON-RPC envelope to `https://api.hanzo.ai/v1/mcp`.

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "form",
         "arguments": {
           "op": "update_form",
           "input": {
             "id": "<id>",
             "fields": [
               {
                 "choices": [
                   {
                     "id": null,
                     "label": null,
                     "ref": null
                   }
                 ],
                 "description": "<description>",
                 "id": "<id>",
                 "labels": {
                   "center": "<center>",
                   "left": "<left>",
                   "right": "<right>"
                 }
               }
             ],
             "hidden": [
               "<hidden>"
             ]
           }
         }
       }
     }'
```

---

[Form API](https://docs.hanzo.ai/docs/openapi/form) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
