# Update Form (PUT)

Replace a form's fields, design and settings. Every field is applied, so send the whole form, not a patch.

## Endpoint

```
PUT https://api.pocketalert.app/v1/forms/{tid}
```

## Authentication

> **Info: Required**
>
> Include one of these headers in your request:
> - `Token: <your-api-key>` — Get it from [API Keys](https://pocketalert.app/account/apikeys)
> - `Authorization: Bearer <jwt-token>` — From [Login](https://info.pocketalert.app/api/user/login.md)

## Request

### Path Parameters

| Parameter | Type | Required | Description |
|-----------|------|:--------:|-------------|
| `tid` | string | ✅ | Form identifier |

### Body Parameters

Same as [Create Form](https://info.pocketalert.app/api/forms/create.md#body-parameters). Anything you leave out is reset to its default: omitting `allowed_origins` clears the list, omitting `application_tid` detaches the application.

> **Warning: Send the current state**
>
> The editor loads the form, changes what it needs and sends the result back. A client that sends only the changed keys will silently wipe the rest.

### Example Request

**cURL**

```bash
curl -X PUT "https://api.pocketalert.app/v1/forms/vml19aihrga216gt8apc5e3m9" \
  -H "Token: your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Contact form",
    "is_active": false,
    "max_responses": 100,
    "allowed_origins": ["example.com", "*.shop.example.com"],
    "fields": [
      { "id": "name", "type": "text", "label": "Name", "required": true },
      { "id": "email", "type": "email", "label": "Email", "required": true }
    ],
    "settings": { "title": "Get in touch" }
  }'
```

**JavaScript**

```javascript
const tid = 'vml19aihrga216gt8apc5e3m9';

// Load the form, change one thing, send it all back.
const [form] = await fetch('https://api.pocketalert.app/v1/forms', {
  headers: { 'Token': 'your-api-key' }
}).then((r) => r.json()).then((forms) => forms.filter((f) => f.tid === tid));

await fetch(`https://api.pocketalert.app/v1/forms/${tid}`, {
  method: 'PUT',
  headers: {
    'Token': 'your-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ ...form, is_active: false })
});
```

**Python**

```python
import requests

tid = 'vml19aihrga216gt8apc5e3m9'
headers = {'Token': 'your-api-key'}

forms = requests.get('https://api.pocketalert.app/v1/forms', headers=headers).json()
form = next(f for f in forms if f['tid'] == tid)

requests.put(
    f'https://api.pocketalert.app/v1/forms/{tid}',
    headers=headers,
    json={**form, 'is_active': False}
)
```

## Response

### Success Response

> **Tip: 200 OK**
>
> The updated form, in the same shape as [Create Form](https://info.pocketalert.app/api/forms/create.md#response).

### Error Responses

| Status | Description |
|:------:|-------------|
| `400` | Validation error — the `error` field says what is wrong |
| `401` | Unauthorized — Invalid or missing token |
| `404` | Form not found, or it belongs to another account |
| `500` | Failed to update form |
