# Update a device

Changes the token or the notification settings. A new token that another device entry still has moves to this one; the other entry is removed.

`PATCH https://api.switchfile.io/v1/account/devices/{id}`

Needs an API key: `Authorization: Bearer YOUR_API_KEY`. See [Authentication](https://switchfile.io/docs/authentication).

## Example

cURL:

```bash
curl -X PATCH "https://api.switchfile.io/v1/account/devices/b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b" \
  -H "Authorization: Bearer $SWITCHFILE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "show_file_names": true
  }'
```

Node.js:

```js
const res = await fetch("https://api.switchfile.io/v1/account/devices/b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.SWITCHFILE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    show_file_names: true
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());
```

PHP:

```php
<?php
$ch = curl_init('https://api.switchfile.io/v1/account/devices/b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_POSTFIELDS => json_encode([
        'show_file_names' => true,
    ]),
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('SWITCHFILE_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if ($status >= 400) {
    throw new RuntimeException("HTTP $status: $response");
}
print_r(json_decode($response, true));
```

Python:

```python
import os
import requests

res = requests.patch(
    "https://api.switchfile.io/v1/account/devices/b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b",
    headers={"Authorization": f"Bearer {os.environ['SWITCHFILE_API_KEY']}"},
    json={
        "show_file_names": True,
    },
)
res.raise_for_status()
print(res.json())
```

## Parameters

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string (uuid) | yes | ID of the device |

## Request body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `locale` | string | no | Language of the texts, for example de or en-US (matches ^[a-zA-Z]{2}([-_][a-zA-Z0-9]{2,8})?$) |
| `notify_failed` | boolean | no |  |
| `notify_finished` | boolean | no |  |
| `show_file_names` | boolean | no |  |
| `start_token` | string \| null | no | APNs token as hex (matches ^[0-9a-fA-F]{32,200}$) |
| `token` | string | no | APNs token as hex (matches ^[0-9a-fA-F]{32,200}$) |

## Responses

### 200: OK

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `created_at` | string | yes | ISO 8601 timestamp |
| `environment` | string | yes | (one of "production", "sandbox") |
| `id` | string (uuid) | yes |  |
| `live_activity_start` | boolean | yes | A push-to-start token is registered |
| `locale` | string | yes |  |
| `notify_failed` | boolean | yes |  |
| `notify_finished` | boolean | yes |  |
| `show_file_names` | boolean | yes |  |
| `updated_at` | string | yes | ISO 8601 timestamp |

Example (application/json):

```json
{
  "id": "b3e1f2a4-5c6d-4e7f-8a9b-0c1d2e3f4a5b",
  "environment": "production",
  "locale": "de",
  "notify_finished": true,
  "notify_failed": true,
  "show_file_names": true,
  "live_activity_start": false,
  "created_at": "2026-11-06T18:00:00+00:00",
  "updated_at": "2026-11-06T18:00:00+00:00"
}
```

### 401: The API key is missing or not valid (`UNAUTHENTICATED`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-unauthenticated",
  "title": "Unauthenticated",
  "status": 401,
  "code": "UNAUTHENTICATED",
  "detail": "Missing or invalid API key."
}
```

### 403: Not available with a service key or a connected app (`NOT_AVAILABLE`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-not-available",
  "title": "Not available",
  "status": 403,
  "code": "NOT_AVAILABLE",
  "detail": "This endpoint is only available with your own API key or the switchfile app."
}
```

### 404: Does not exist for this account (`NOT_FOUND`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-not-found",
  "title": "Not found",
  "status": 404,
  "code": "NOT_FOUND",
  "detail": "Device not found."
}
```

### 422: Invalid data. errors names the fields (`INVALID_DATA`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-invalid-data",
  "title": "Invalid data",
  "status": 422,
  "code": "INVALID_DATA",
  "detail": "The request contains invalid data.",
  "errors": {
    "to": [
      "Expected string"
    ]
  }
}
```

### 429: Too many requests or a daily quota is used up. See Retry-After (`RATE_LIMIT_EXCEEDED`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded",
  "title": "Rate limit exceeded",
  "status": 429,
  "code": "RATE_LIMIT_EXCEEDED",
  "detail": "Too many requests. Try again in 12 seconds."
}
```

Error bodies and codes are explained in [Errors](https://switchfile.io/docs/errors).
