# Update sync job run state

> Source: https://truto.one/docs/api-reference/admin/sync-job-run-state/update/

`PATCH /sync-job-run-state/{id}`

Resource: **Sync Job Run State**

## Path parameters

- **`id`** _(string, required)_
  The ID of the state to update.

## Query parameters

- **`state_key`** _(string, required)_
  The state_key attribute found in a sync job run and defined in the sync job. Used as a namespace for the states.

## Request body

- **`value`** _(string)_
  The new state value to store.

## Response body

- **`key`** _(string)_
  The key identifier for this state.
- **`value`** _(string)_
  The updated state value stored.
- **`created_at`** _(string)_
  Timestamp when the state was created.
- **`updated_at`** _(string)_
  Timestamp when the state was last updated.
- **`sync_job_run_id`** _(string)_
  The ID of the sync job run this state is associated with (optional).

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/sync-job-run-state/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "value": "eyJpZCI6IjY3ODkwIiwidGltZXN0YW1wIjoiMjAyMy0wMi0wMVQwMDowMDowMFoifQ=="
}'
```

### JavaScript

```javascript
const body = {
  "value": "eyJpZCI6IjY3ODkwIiwidGltZXN0YW1wIjoiMjAyMy0wMi0wMVQwMDowMDowMFoifQ=="
};

const response = await fetch('https://api.truto.one/sync-job-run-state/{id}', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/sync-job-run-state/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "value": "eyJpZCI6IjY3ODkwIiwidGltZXN0YW1wIjoiMjAyMy0wMi0wMVQwMDowMDowMFoifQ=="
}

response = requests.patch(url, headers=headers, params=params, json=payload)
print(response.json())
```
