Batch request examples

Some examples of how you can send batches of entities, events, instruments, and devices in one request.

Batch Create Entities

Entity-level options are ignored. Instead, send options as its own second-level field (inside the entities object). These options are applied globally.

The following snippet shows a valid request body to batch send two entities:

{
  "entities": [
    {
      "user_data": {
        "first_name": "John",
        "last_name": "Smith"
      },
      "general_data": {
        "entity_id": "user-100",
        "entity_type": "user"
      }
    },
    {
      "business_data": {
        "business_name": "Acme Inc"
      },
      "general_data": {
        "entity_id": "business-100",
        "entity_type": "business"
      }
    }
  ],
  "options": {
    "upsert_on_conflict": true,
    "resolve_geoip": false,
    "merge_custom_data": true,
    "list_merge_strategy": "union"
  }
}

Batch Create Events

Entity-level options are ignored. Instead, send options as its own
second-level field (inside the entities object). These options are applied
globally.

The following snippet shows a valid request body to batch send two entities:

{
  "events": [
    {
      "general_data": {
        "event_id": "event100",
        "event_type": "transaction",
        "event_time": 1623346868
      },
      "transaction_data": {
        "amount": 15000,
        "sender_entity_id": "user100",
        "sender_entity_type": "user",
        "sender_source": "internal"
      }
    },
    {
      "general_data": {
        "event_id": "event200",
        "event_type": "action",
        "event_time": 1623346861
      },
      "action_data": {
        "entity_type": "business",
        "entity_id": "business-200"
      }
    }
  ],
  "options": {
    "monitor": true,
    "linked_entity": "both",
    "merge_custom_data": false,
    "list_merge_strategy": "union"
  }
}

Batch Create Instruments

When you create a batch of instruments, you MAY use all the objects
available when creating a single instrument. There are only two differences:

  • Each instrument batch object is sent in the instruments array.
  • The options object should be outside of the instruments array. This overrides all options contained in a single instrument objects.

Here's a minimal example of a batch request to create two instruments:

{
  "options": {
    "merge_custom_data": false,
    "list_merge_strategy": "union"
  },
  "instruments": [
    {
      "instrument_id": "ins-101",
      "instrument_type": "credit_card"
    },
    {
      "instrument_id": "ins-102",
      "instrument_type": "ach"
    }
  ]
}

Batch Create Devices

When you create a batch of devices, you MAY use all the objects available when creating a single device. There are only two differences:

  • Each device batch object is sent in the devices array.
  • The options object should be outside of the devices array. This overrides all options contained in a single device objects.

Here's an example of a batch request:

{
  "devices": [
    {
        "device_id": "dev-100",
        "device_type": "PC"
    },
    {
        "device_id": "dev-200",
        "device_type": "Mobile"
    }
  ],
  "options": {
    "upsert_on_conflict": true,
    "list_merge_strategy": "union"
    }
}

Did this page help you?