# Get sync job run

> Source: https://truto.one/docs/api-reference/admin/sync-job-runs/get/

`GET /sync-job-run/{id}`

Resource: **Sync job runs**

## Path parameters

- **`id`** _(string, required)_
  The ID of the sync job run to get.

## Response body

- **`id`** _(string)_
  The ID of the sync job run.
- **`args`** _(object)_
  The arguments passed to the sync job run.
- **`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.
- **`sync_job_id`** _(string)_
  The ID of the sync job that this sync job run belongs to.
- **`integrated_account_id`** _(string)_
  The ID of the integrated account that this sync job run belongs to.
- **`status`** _(string)_
  The status of the sync job run. `created` - waiting to run, `running` - running, `completed` - completed successfully, `failed` - failed, `stopped` - stopped by the user.
  Allowed: `created`, `running`, `completed`, `failed`, `stopped`
- **`daemon_id`** _(string)_
  The daemon_id attribute of a daemon that is running this sync job.
- **`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.
- **`error_handling`** _(string)_
  Specifies the error handling strategy used for the sync job run. `fail_fast` - stop the sync job run as soon as an error is encountered, `ignore` - continue running the sync job run even if an error is encountered. In case of `ignore`, you'll receive `sync_job_run:record_error` events for each error encountered. In case of `batch`, you'll receive `sync_job_run:record_error` events with multiple errors batched into the errors array, this is only supported when the `version` used for Sync Job Run is 2.
  Allowed: `fail_fast`, `ignore`, `batch`
- **`ignore_previous_run`** _(boolean)_
  Specifies if the sync job run was started ignoring the previous run date.
- **`version`** _(integer)_
  The runtime version of the sync job run. The version 1 is the default version and the version 2 is the new version which supports batch error handling and other enhancements.
- **`resource_stats`** _(object)_
  The statistics of the resources synced in the sync job run. This will have information around how many records were fetched and persisted by the sync job run -- grouped by the resource and method. The data is updated every 10 seconds while the sync job run is running.
- **`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.
- **`started_at`** _(string)_
  The date and time when the sync job run was started.
- **`finished_at`** _(string)_
  The date and time when the sync job run was finished.
- **`sync_job`** _(object)_
  - **`id`** _(string)_
    The ID of the sync job.
  - **`integration_name`** _(string)_
    The name of the integration that this sync job interacts with.
  - **`args_schema`** _(object, required)_
    JSON schema defining the structure of the arguments that can be passed to the sync job. Same shape as `JsonSchemaObject` (top-level `{ type: "object", properties }`).
    - **`type`** _(string)_
      Allowed: `object`
    - **`$ref`** _(string)_
    - **`properties`** _(object)_
      Map of property name → `JsonSchemaObjectProperties`.
    - **`description`** _(string)_
    - **`required`** _(boolean)_
    - **`default`** _(unknown)_
    - **`additionalProperties`** _(boolean)_
  - **`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.
  - **`environment_id`** _(string)_
    The ID of the environment that this sync job belongs to.
  - **`created_at`** _(string)_
    The date and time when the sync job was created.
  - **`updated_at`** _(string)_
    The date and time when the sync job was last updated.

## Code examples

### curl

```bash
curl -X GET 'https://api.truto.one/sync-job-run/{id}' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json'
```

### JavaScript

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

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

### Python

```python
import requests

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

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

### Truto TS SDK

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

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

const result = await truto.syncJobRun.get('<id>');

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():
    result = await truto_api.sync_job_runs.get("<id>")
    print(result)

asyncio.run(main())
```
