# Build a form

Creates a form, and always as a DRAFT — `post_forms_id_publish` is what opens the public door afterwards. Body: `name`, an optional `slug` (lowercase letters, numbers and hyphens; the words drafts and submissions are refused because the public router already means something by them), `fields`, `sections`, `settings`, and `targetDefinitionKey` naming the record page answers should land on.

Access class: `workspace`.

## Endpoint

`POST /v1/forms`

## Request body

Content type: `application/json`.

```json
{
  "body": {
    "description": "string",
    "fields": [
      {
        "column": "string",
        "documentType": "string",
        "id": "",
        "kind": "string",
        "label": "string",
        "placeholder": "string",
        "required": true
      }
    ],
    "name": "string",
    "sections": [
      {
        "fieldIds": [
          "string"
        ],
        "title": "string"
      }
    ],
    "settings": "string",
    "slug": "string",
    "targetDefinitionKey": "string"
  },
  "params": {},
  "query": {}
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "createdAt": "string",
    "createdBy": "string",
    "description": "string",
    "fields": [
      {
        "column": "string",
        "documentType": "string",
        "entityType": "string",
        "id": "",
        "kind": "string",
        "label": "string",
        "options": "string",
        "placeholder": "string",
        "required": "string"
      }
    ],
    "id": "",
    "name": "string",
    "publishedAt": "string",
    "sections": [
      {
        "fieldIds": "string",
        "title": "string"
      }
    ],
    "settings": {
      "analytics": true,
      "automations": [
        "string"
      ],
      "branding": "string",
      "pacing": "string",
      "postSubmit": "string",
      "saveDrafts": true,
      "signature": "string",
      "theme": "string"
    },
    "slug": "string",
    "sourceUrl": "string",
    "stats": {
      "submissions": 1,
      "views": 1
    },
    "status": "string",
    "targetDefinitionKey": "string",
    "updatedAt": "string"
  }
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
