OS1 Services
...
Entity
How to use Entities?

How To: Create & Update Entities In Batch

13min

For information about prerequisites, see How to use Entities?. Batch endpoints are provided to create and update Entities in batches. The Batch endpoints support two methods to supply the Entity data:

  • JSON
  • CSV file upload

Create Entities in Batch via JSON

To create Entities in batch, call the Create Batch Request endpoint and specify the entityTypePluralName in the path parameter.

Learn more about the necessary attributes listed for creating Entities in Batch using the JSON.

The following examples show a request body for creating a Batch Entities request:

JSON


Create Entities in Batch via CSV Upload

To create Entities in batch through CSV, call the File Upload Create Request endpoint and specify entityTypePluralName in the path parameter. Upload the CSV file with all the details as shown in the sample CSV.

Updating Entities In Batch Via JSON

To update Entities in batch, call the Update Batch Request endpoint and specify entityTypePluralName in the path parameter. The following examples show a request body for updating a Batch Entity request:

JSON


Update Enities in Batch with Conditional Updates

Conditional updates can also be applied to batch updates, where multiple entity instances are updated in a single request. Each entry in the batch can have its own conditionExpression.

JS


Payload

JS


Understand the Batch Payload

  • URL: Replace {{baseUrl}} and :entityType with the appropriate details for your batch update endpoint.
  • payload: This array contains multiple entity instances to be updated.
    • Each object within the array represents an individual update:
      • entityInstanceId: The unique identifier for the entity instance being updated.
      • properties: The attributes to be updated for that instance.
      • conditionExpression: A condition specific to that instance that must evaluate to true for the update to proceed.

Batch Update with Multiple Conditions

Request Headers

Headers

Description

Example Value

Required

X-COREOS-REQUEST-ID

Unique request identifier for tracking purposes

32876292-bde0-438d-ac75-6fe4eb78c073

Yes

X-COREOS-TID

Tenant identifier for the organization

delhivery

Yes

X-COREOS-USERINFO

Information about the user making the request

{} (Empty JSON in this example)

Yes

X-COREOS-APPID

Identifier for the application making the request

b0ecb6e12f5e4fd38f9f04125f8db1ea

Yes

Content-Type

The media type of the resource being sent

application/json

Yes

Accept

The media type expected in the response

application/json

Yes

Request Parameters

Parameter

Description

Example Value

Type

Required

payload

Array of objects containing entity details to be updated

Array of entity instance objects (shown in payload below)

JSON Array

Yes

entityInstanceId

Unique identifier for the entity instance being updated

testfives:a5fb93b0-e1b8-5acf-9cb8-351cee15bcd2

String

Yes

owner

Owner identifier for the entity instance

3RTrlmIFfo50wNDBv2mDlAHKUGz3SQ5v

String

Yes

properties

Properties of the entity instance

{"manufacturer": "hyundai"}

JSON Object

Yes

name

Name of the entity instance

"USB", "Direct", "Garden"

String

Yes

category

Category of the entity instance

"four-wheeler"

String

Yes

subCategory

Subcategory of the entity instance

"car"

String

Yes

conditionExpression

Condition that must be true for the update to occur

properties.manufacturer == 'honda', etc.

String

Yes

callback.url

URL to send callback notifications upon completion

https://many-baby-86.webhook.cool

URL String

No

Payload

JSON


In this example, the last object in the json with "conditionExpression": "properties.manufacturer == '\''toyota'\''" fails to meet the condition and fails to update.

Updating Entities In Batch Via CSV Upload

To update Entities in batch through CSV, call the File Upload to Update Entities Request endpoint and specify entityTypePluralName in the path parameter. Upload the CSV file with all the details as shown in the sample CSV.

Update Entities in Batch via CSV with conditional expression

Now, when converting the above JSON payload to a CSV file and making the following request, the same behavior occurs with the last record failing to update as a condition not met.

CSV file data 

entityInstanceId

properties

conditionExpression

testfives:a5fb93b0-e1b8-5acf-9cb8-351cee15bcd2

{"manufacturer": "honda"}

properties.manufacturer == 'hyundai'

testfives:a5fb93b0-e1b8-5acf-9cb8-351cee15bcd2

{"manufacturer": "hyundai"}

properties.manufacturer == 'honda'

testfives:a5fb93b0-e1b8-5acf-9cb8-351cee15bcd2

{"manufacturer": "hyundai"}

properties.manufacturer == 'toyota'

Upload Request

Curl


Retrieve Entity Batch Status

To retrieve the information about Entities in Batch processing, call the Get the Status of Batch Request endpoint and pass the entityTypePluralName, BatchId in the path parameter. This process is common to both JSON and CSV-based APIs.