Fluent Commerce Logo
Docs
Sign In
Essential knowledge

Author:

Fluent Commerce

Changed on:

10 Dec 2024

Overview

A batch contains a series of records that will have the same operation applied to it. All Batches are run asynchronously so to confirm success or failure the client must request a status update for submitted batches via the GET API at a later stage. Most Batches are limited to 5,000 records.

To create a Batch, the user must first create a Job. A Job is required to store a series of batches. For more information please refer to the Job API.

Key points

  • Batch Properties
  • Category Batch
  • Inventory Batch
  • Location Batch
  • Response on Failures


Batch Properties

Below are the properties available in the Batch object which can be updated and retrieved through the APIs in this document.

1. id

Type: DateTime

Description: Unique id associated with the created batch.


2. jobId

Type: String

Description: The unique identifier associated to the Job. 

`{ "jobId" : "223" }`


3. batchId

Type: String

Description: The unique batch id.


4. start

Type: String

Description: Offset of result


5. count

Type: String

Description: The count of batches shown


6. total

Type: String

Description: Total no of batches


7. action

Type: String

Description: The type of operation that will be applied to all records in the batch. 

`{ "action": "UPSERT" }`

Possible values are:

  • UPSERT: Insert or update records. If the record already exists then update existing record.
  • CREATE: Create new records.
BATCHRECORDSTATUS
  • entityId: FluentRetail ID of category entity. This field is only available when category is created successfull.
  • entityRef: External reference of category entity.
  • responseCode:
    • 200 OK: successful
    • 404: not found (Dependent record)
    • 500: Internal server
    • 301: Unauthorised
  • message: Descriptive message related to the response code.
8. entityType

Type: String

Description: Entity type. Possible values are 'INVENTORY', 'LOCATION'.

`{ "entityType" : "INVENTORY" }`

9. entities

Type: Array

Description: An array of InventoryPost records

1{ "retailerId" : "197" }
2
3{ "inventoryId" : "56470" }
4
5 { "skuRef" : "29SPM0020X96-1-8" }
6
7 { "locationRef" : "158" }
8
9 { "qty" : "10" }
10
11 { "correctedQty" : "2" }
12
13{ "reservedQty" : "2" }
14
15retailerId (string) : The retailer identifier assigned by Fluent Commerce.
16inventoryId (string) : The unique identifier assigned by Fluent Commerce.
17skuRef (string) : The unique reference or code provided by the retailer.
18locationRef (string) : The location (i.e. store) number.
19qty (integer) : The stock on hand.
20correctedQty (integer) : Correction quantity based on stock updates.
21reservedQty (integer) : Quantity reserved due to unfulfilled orders

Language: java

Name: Example: An array of InventoryPost records

Description:

[Warning: empty required content area]
1{ "locationRef" : "DX001" }
2
3{ "alternateId" : "36137249241" }
4
5{ "status" : "ACTIVE" }
6
7{ "name" : "ABC Store" }
8
9{ "email" : "abcstore@mystore.com.au" }
10
11{ "supportPhone" : "0272432243" }
12
13{ "type" : "STORE" }
14
15{ "timeZone" : "+10" }
16
17{ "pickAndPackTimeLimit" : 2 }
18
19{ "ClickAndCollectNetworks" : [”ABC_CC”] }
20
21{ "useInventoryForHomeDelivery" : [”ABC_HD”]}
22
23{ "useInventoryForClickCollect" : [”ABC_CC”]}
24
25{ "StorageAreas" : [”locker_1","locker_2”]}
26
27{ "address" : {
28                  "LocationRef":"DX001",
29                  "companyName":"ABC Pvt Ltd", 
30                  "name":"ABC Store", 
31                  "city":"Sydney", 
32                  "country":"Australia", 
33                  "postcode":"2100",
34                  "state":"NSW", 
35                  "street":"48, Kippax St.",
36                  "longiltude":"33.8688", 
37                  "latitude":"150.72893"
38                   }}
39
40{ "openingHours" : "{
41
42                    "allHours": true, 
43                    "friEndMin": 0, 
44                    "friStartMin": 0, 
45                    "monEndMin": 0, 
46                    "monStartMin": 0, 
47                    "satEndMin": 0, 
48                    "satStartMin": 0, 
49                    "sunEndMin": 0, 
50                    "sunStartMin": 0, 
51                    "thuEndMin": 0, 
52                    "thuStartMin": 0, 
53                    "tueEndMin": 0, 
54                    "tueStartMin": 0, 
55                    "wedEndMin": 0, 
56                    "wedStartMin": 0 
57                    }} 
58{ "agentNetworks" : [”network1”] }  
59{ "attributes" : [
60
61                    {
62                    "name" : "Supplier address",
63                    "type" : "address",
64                    "value" : {"Address 1" : "46, Kipax Street",
65                    "Suburb" : "Surry Hills"
66                    "Post code" : "2010",
67                    "State" : "NSW"
68                    }
69                    },
70                    {
71                    "name" : "ECP",
72                    "type" : "string",
73                    "value" : "XCD123"
74                    }                  
75                    ] 
76}
77
78
79locationRef (String) Compulsory - The location reference from the retailer.
80alternateId (String) Optional - External ID for location.
81status (String) Compulsory - Status of the location. Allowed values are ACTIVE | INACTIVE.
82name (String) Compulsory - The name of the location.
83email (String) Compulsory - The object of customer information.
84supportPhone (String) Compulsory - The support phone number.
85type (String) Compulsory - Type of the location STORE | WAREHOUSE.
86timeZone (String) Compulsory - Time Zone associated with this location.
87pickAndPackTimeLimit (Int) Optional - Default is 3 HRS for store location. N/A For WAREHOUSE.
88clickAndCollectNetworks (Array[String]) Optional - The list of Click & Collect Network for which this Location can act as a collection point
89useInventoryForHomeDelivery (Array[String]) Optional - The list of HD Networks for which this Location can do fulfilment.
90useInventoryForClickCollect (Array[String]) Optional - The list of CC Networks for which this Location can do fulfilment.
91storageAreas [Array] Optional - List of storage Areas associated with the location.
92address Address Compulsory - The address of the location.
93
94LocationRef (String) Compulsory - The location reference from the retailer.
95companyName (String) Compulsory - Company Name.
96name (String) Optional - The name of the location.
97city (String) Optional - City name.
98country (String) Optional - Country name.
99postcode (String) Optional - Post code of the location.
100state (String) Optional - State name.
101street (String) Optional - Street name.
102latitude (String) Compulsory - Latitude.
103longitude (String) Compulsory - Longitude.
104openingHours OpeningHours Compulsory - The opening hours associated with this location.
105
106mon_start_min (integer) Compulsory - Start Time.
107mon_end_min (integer) Compulsory - End Time.
108tue_start_min (integer) Compulsory - Start Time.
109tue_end_min (integer) Compulsory - End Time.
110wed_start_min (integer) Compulsory - Start Time.
111wed_end_min (integer) Compulsory - End Time.
112thur_start_min (integer) Compulsory - Start Time.
113thur_end_min (integer) Compulsory - End Time.
114fri_start_min (integer) Compulsory - Start Time.
115fri_end_min (integer) Compulsory - End Time.
116sat_start_min (integer) Compulsory - Start Time.
117sat_end_min (integer) Compulsory - End Time.
118sun_start_min (integer) Compulsory - Start Times.
119sun_end_min (integer) Compulsory - End Time.
120allHours (boolean) Optional Indicates whether the store is 24x7
121agentNetworks [Array] Optional List of agent networks this location associated with (String array which represent agent network ids).
122
123attributes [Array] Optional - The array of attributes
124name (String) N attribute name
125type (String) N attribute type
126value (object) N Value

Language: java

Name: Example: An array of LocationPost records

Description:

[Warning: empty required content area]
10. status

Type: String

Description: The Status of the batch

1{ "status" : “RUNNING” }
2
3Possible values are: - PENDING - Batch has been entered but is not currently running. - RUNNING - Batch is being processed - COMPLETE - Batch has been processed ( with or without errors )

Language: java

Name: Status

Description:

[Warning: empty required content area]


Category Batch

Category Batch Properties
1. categoryRef
  • Type: String
  • Description: External Category reference to be referenced as the parent category.
Create a Batch

This endpoint can be used to create a new batch

POST: 

`/api/v4.1/job/{jobid}/batch`

Request object and example

1batchRequest {
2
3action (string, compulsory) = UPSERT,
4entityType (string, compulsory) = CATEGORY,
5entities (array, compulsory),
6
7    CategoryPost {
8        categoryRef (string, compulsory),
9        name (string, compulsory),
10        parentCategoryRef (string, optional),
11    }
12
13}

Language: java

Name: Request object

Description:

[Warning: empty required content area]
1{
2  "action": "UPSERT",
3  "entityType": "CATEGORY",
4  "entities": [
5    {
6      "categoryRef": "CGR-0001",
7      "name": "Category 001",
8      "parentCategoryRef": "CGR-000"
9    },
10    {
11      "categoryRef": "CGR-0002",
12      "name": "Category 002"
13    }
14  ]
15}

Language: json

Name: Example request

Description:

[Warning: empty required content area]

Response object and example

1SuccessMessageResponse {
2
3id (object, optional),
4message (string, optional),
5status (string, optional)
6}

Language: java

Name: Response object

Description:

[Warning: empty required content area]
1{
2 "id":"427323"
3}

Language: json

Name: Example response

Description:

[Warning: empty required content area]
View Details of a Batch Job

This endpoint can be used to view the status of a batch job

GET: 

`/api/v4.1/job/{jobid}/batch/{batchId}`

Request example

1/api/v4.1/job/223/batch/299

Language: java

Name: Request sample

Description:

[Warning: empty required content area]

Response object and example

1batchResponse {
2
3    batchId (string),
4    entityType (string) = 'CATEGORY', 
5    status (string) = 'PENDING', 'RUNNING', 'COMPLETE',
6    start (integer),
7    count (integer),
8    total (integer),
9    results (array[batchRecordStatus]):[
10    {
11    entityId (string),
12    entityRef (string),
13    responseCode (string) = '200', '404', '500', '401'
14    message (string)
15    }
16    ]
17    }

Language: java

Name: Response object

Description:

[Warning: empty required content area]
1{
2  "batchId": "1",
3  "entityType": "CATEGORY",
4  "status": "PENDING|RUNNING|COMPLETE",
5  "start": 1,
6  "count": 100,
7  "total": 5000,
8  "results": [
9      {
10            "responseCode": 404,
11            "entityRef": "CGR-0001",
12            "message": "Parent category \"CGR-000\" does not exist"
13      },
14      {
15            "responseCode": 200,
16            "entityId": "2",
17            "entityRef": "CGR-0002",
18            "message": "Category update successfully"
19      }
20  ],
21  "createdOn": "2017-09-20T10:00.000Z"
22}

Language: json

Name: Response Example

Description:

[Warning: empty required content area]


Inventory Batch

Create an Inventory Batch

This endpoint can be used to create a new inventory batch.

POST: 

`/api/v4.1/job/{jobid}/batch`

Request object and example

1// Request for INVENTORY
2
3batchRequest {
4
5    action (string, compulsory) = UPSERT,
6
7    entityType (string, compulsory) = INVENTORY,
8
9    entities (array, compulsory)
10}
11
12    InventoryPost {
13    retailerId (string, compulsory),
14    skuRef (string, compulsory),
15    locationRef (string, compulsory),
16    qty (integer, compulsory)
17    correctedQty (integer, optional)
18    }

Language: java

Name: Request object

Description:

[Warning: empty required content area]
1{
2    "action": "UPSERT",
3    "entityType": "INVENTORY",
4    "entities": [
5{
6    "locationRef": "158",
7    "qty": 10,
8    "correctedQty": 11,
9    "reservedQty" : 12,
10    "skuRef": "29SPM0020X96-1-8",
11    "retailerId": 197
12    }
13    ]
14}

Language: json

Name: Example request

Description:

[Warning: empty required content area]

Response object and example

1SuccessMessageResponse {
2
3id (object, optional),
4message (string, optional),
5status (string, optional)
6}

Language: java

Name: Response object

Description:

[Warning: empty required content area]
1{
2 "id":"427323"
3}

Language: json

Name: Example response

Description:

[Warning: empty required content area]
View an Inventory Batch

With Global Inventory enabled (INVENTORY_BATCH_ENHANCEMENT_ENABLED = TRUE), the status of inventory processing can be verified by retrieving the corresponding events for the job and batch entities. For each inventory batch that is submitted, a "CREATE" event is generated. When the inventory processing is complete and the inventory workflow has been executed, a corresponding "BATCH_COMPLETE" event is generated.

When Global Inventory is not enabled, follow the guides below.

Retrieve details of the Batch.

GET: 

`/api/v4.1/job/{jobid}/batch/{batchId}`

Request example

1/api/v4.1/job/223/batch/299

Language: java

Name: Request sample

Description:

[Warning: empty required content area]

Response object and example

1batchResponse {
2
3    batchId (string),
4    entityType (string) = 'INVENTORY', 
5    status (string) = 'PENDING', 'RUNNING', 'COMPLETE',
6    start (integer),
7    count (integer),
8    total (integer),
9    results (array[batchRecordStatus]):[
10    {
11    entityId (string),
12    entityRef (string),
13    responseCode (string) = '200', '404', '500', '401'
14    message (string)
15    }
16    ]
17    }

Language: java

Name: Response object

Description:

[Warning: empty required content area]
1{
2"batchId": "300",
3"entityType": "INVENTORY",
4"status": "COMPLETE",
5"start": 1,
6"count": 10,
7"total": 1,
8"results": [
9{
10"entityId": "1013187",
11"entityRef": null,
12"responseCode": 200,
13"message": "Inventory Created."
14}
15]
16}

Language: json

Name: Response Example

Description:

[Warning: empty required content area]


Location Batch

1// Request for LOCATION
2
3batchRequest {
4
5    action (string, compulsory) = UPSERT,
6
7    entityType (string, compulsory) = LOCATION,
8
9    entities (array, compulsory),
10}
11
12
13entities {
14    address (AddressDTO, optional),
15    agentNetworks (Array[string], optional),
16    alternateId (string, optional),
17    attributes (Array[Attribute], optional),
18    clickAndCollectNetworks (Array[string], optional),
19    directions (string, optional),
20    email (string, optional),
21    locationRef (string, optional),
22    name (string, optional),
23    openingHours (AgentOpening,optional),
24    pickAndPackTimeLimit (integer, optional),
25    status (string, optional) = ['ACTIVE','INACTIVE']stringEnum:"ACTIVE", "INACTIVE",
26    storageAreas (Array[string], optional),
27    supportPhone (string, optional),
28    timeZone (string, optional),
29    type (string, optional),
30    useInventoryForClickAndCollect(Array[string], optional),
31    useInventoryForHomeDelivery(Array[string], optional)}
32}
33
34
35AddressDTO {
36
37city (string, optional),
38companyName (string, optional),
39country (string, optional),
40latitude (number, optional),
41locationRef (string, optional),
42longitude (number, optional),
43name (string, optional),
44postcode (string, optional),
45state (string, optional),
46street (string, optional)
47
48}
49
50 Attribute {
51name (string, optional),
52type (string, optional),
53value (object, optional)
54
55}
56
57agentNetworks (Array[string], optional), alternateId (string, optional), attributes (Array[Attribute], optional),
58
59
60AgentOpening {
61allHours (boolean, optional),
62friEndMin (integer, optional),
63friStartMin (integer, optional),
64monEndMin (integer, optional),
65monStartMin (integer, optional),
66satEndMin (integer, optional),
67satStartMin (integer, optional),
68sunEndMin (integer, optional),
69sunStartMin (integer, optional),
70thuEndMin (integer, optional),
71thuStartMin (integer, optional),
72tueEndMin (integer, optional),
73tueStartMin (integer, optional),
74wedEndMin (integer, optional),
75wedStartMin (integer, optional)
76
77}
78

Language: java

Name: Location Request Example

Description:

[Warning: empty required content area]


Response on Failures

NAME

TYPE

DESCRIPTION

error

Array

Array of errors

message

String

Additional information on the code Unauthorized | Bad Request | Forbidden | Not Found | Status 500 Error

code

String

Status Code for the above messages 401 | 400 | 403 | 404 | 500



Fluent Commerce

Fluent Commerce