Skip to content
POST /batch-request

Request Body

argsRecord<string, any>

Optional arguments available for placeholder replacement in resource definitions.

Example: {"my_placeholder":123}
integrated_account_idstring · uuid

The ID of the integrated account in whose context these resource calls are made.

resourcesobject[]

A list of resource definitions that can be either a request or a transform.

depends_onstring

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.

Example: crm/contacts
idstring

The ID of the resource to sync. This is optional and can be used to sync a single resource. It also supports placeholders.

Example: Static value like `4a4de828-f4db-4c9e-adfd-434e0864c3c7` or placeholder like `{{args.user_id}}`.
loop_onstring

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.

Example: {"{ args.user_ids }":null}
methodstring

The method to call on the resource.

Example: list
persistboolean

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.

queryRecord<string, any>

The query parameters to pass to the resource method. It supports placeholders for values.

Example: { "page": 1, "per_page": 100, "user_id": "{{args.user_id}}" }
resourcestring

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.

Example: For fetching Contacts from CRM Unified API, `crm/contacts`. For fetching Contacts from a Proxy API, `contacts`.

Response Body

errorsRecord<string, any>

A map of resource names to encountered errors (if any).

resultRecord<string, any>

A map of resource names to fetched records.

curl -X POST 'https://api.truto.one/batch-request' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "integrated_account_id": "your_integrated_account_id",
  "args": {
    "my_placeholder": 123
  },
  "resources": []
}'
const body = {
  "integrated_account_id": "your_integrated_account_id",
  "args": {
    "my_placeholder": 123
  },
  "resources": []
};

const response = await fetch('https://api.truto.one/batch-request', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

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

url = "https://api.truto.one/batch-request"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}
payload = {
    "integrated_account_id": "your_integrated_account_id",
    "args": {
        "my_placeholder": 123
    },
    "resources": []
}

response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())
import Truto from '@truto/truto-ts-sdk';

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

const body = {
  "integrated_account_id": "your_integrated_account_id",
  "args": {
    "my_placeholder": 123
  },
  "resources": []
};

const result = await truto.batchRequest.create(body);

console.log(result);
import asyncio
from truto_python_sdk import TrutoApi

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

async def main():
    body = {
        "integrated_account_id": "your_integrated_account_id",
        "args": {
            "my_placeholder": 123
        },
        "resources": []
    }

    result = await truto_api.batch_requests.create(body)
    print(result)

asyncio.run(main())