# Update sync job cron trigger

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

`PATCH /sync-job-cron-trigger/{id}`

Resource: **Sync job cron triggers**

## Path parameters

- **`id`** _(string, required)_
  The ID of the sync job cron trigger to update.

## Request body

- **`daemon_group_key`** _(string)_
  The name of the daemon group that this sync job run should be assigned to. Used while creating a sync job run. Truto find a daemon in the group that is available to run the sync job. You can either specify `daemon_group_key` (Daemon) or `webhook_id` (RapidBridge), but NOT both while creating a Sync Job Run.
- **`webhook_id`** _(string)_
  The ID of the webhook where the sync job records need to be sent. You can either specify `daemon_group_key` (Daemon) or `webhook_id` (RapidBridge), but NOT both while creating a Sync Job Run.
- **`cron_expression`** _(string)_
  The cron expression that defines when the sync job should be run. The timezone used is UTC.

## Response body

- **`id`** _(string)_
  The ID of the sync job cron trigger.
- **`args`** _(object)_
  The arguments passed to the sync job cron trigger.
- **`resources`** _(array<object>)_
  The resources to sync as part of the sync job.
  - **`resource`** _(string)_
    The name of the resource to sync. For Unified APIs, it should be in the format `unified_api_name/resource_name`. For Proxy API, it can just be `resource_name`.
  - **`method`** _(string)_
    The method to call on the resource.
  - **`id`** _(string)_
    The ID of the resource to sync. This is optional and can be used to sync a single resource. It also supports placeholders.
  - **`query`** _(object)_
    The query parameters to pass to the resource method. It supports placeholders for values.
  - **`loop_on`** _(string)_
    When a particular placeholder argument is an array and you want to repeat the request for each element in that array, you can set this parameter. For example, if you accept an argument called `user_ids` which is an array of strings, and you want to fetch each user's details, you can set this parameter to `user_ids` and the request will be repeated for each element in the `user_ids` array.
  - **`depends_on`** _(string)_
    The resource that this resource depends on (parent resource). This is optional and can be used to sync a resource only after another resource has been synced. Each object synced for the parent resource is available as the resources object in placeholders for the child resource, e.g. `{{resources.crm.contacts.id}}` if depends on is `crm/contacts` resource.
  - **`persist`** _(boolean)_
    Whether to persist the resource in the database or not in case of a Daemon sync job run or send as a payload in case of RapidBridge sync job run. The Proxy API resources are by default NOT persisted and this parameter can be set to `true` to persist them. Unified API resources are always persisted.
- **`cron_expression`** _(string)_
  The cron expression defining when the sync job should run.
- **`sync_job_id`** _(string)_
  The ID of the sync job that this sync job cron trigger should run.
- **`integrated_account_id`** _(string)_
  The ID of the integrated account that this sync job cron trigger should run.
- **`daemon_group_key`** _(string)_
  The name of the daemon group that this sync job run should be assigned to. Used while creating a sync job run. Truto find a daemon in the group that is available to run the sync job. You can either specify `daemon_group_key` (Daemon) or `webhook_id` (RapidBridge), but NOT both while creating a Sync Job Run.
- **`webhook_id`** _(string)_
  The ID of the webhook where the sync job records need to be sent. You can either specify `daemon_group_key` (Daemon) or `webhook_id` (RapidBridge), but NOT both while creating a Sync Job Run.
- **`created_at`** _(string)_
  The date and time when the sync job run was created.
- **`updated_at`** _(string)_
  The date and time when the sync job run was last updated.

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/sync-job-cron-trigger/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "daemon_group_key": "default",
  "webhook_id": "4a4de828-f4db-4c9e-adfd-434e0864c3c7",
  "cron_expression": "0 0 * * *"
}'
```

### JavaScript

```javascript
const body = {
  "daemon_group_key": "default",
  "webhook_id": "4a4de828-f4db-4c9e-adfd-434e0864c3c7",
  "cron_expression": "0 0 * * *"
};

const response = await fetch('https://api.truto.one/sync-job-cron-trigger/{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-cron-trigger/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "daemon_group_key": "default",
    "webhook_id": "4a4de828-f4db-4c9e-adfd-434e0864c3c7",
    "cron_expression": "0 0 * * *"
}

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

### Truto TS SDK

```typescript
import Truto from '@truto/truto-ts-sdk';

const truto = new Truto({
  token: '<your_api_token>',
});

const body = {
  "daemon_group_key": "default",
  "webhook_id": "4a4de828-f4db-4c9e-adfd-434e0864c3c7",
  "cron_expression": "0 0 * * *"
};

const result = await truto.syncJobCronTrigger.update('<id>', body);

console.log(result);
```

### Truto Python SDK

```python
import asyncio
from truto_python_sdk import TrutoApi

truto_api = TrutoApi(token="<your_api_token>")

async def main():
    body = {
        "daemon_group_key": "default",
        "webhook_id": "4a4de828-f4db-4c9e-adfd-434e0864c3c7",
        "cron_expression": "0 0 * * *"
    }

    result = await truto_api.sync_job_cron_triggers.update("<id>", body)
    print(result)

asyncio.run(main())
```
