top of page

How it works

  1. Trax’ Store Import API V5 enables its clients to send new stores to Trax or to update already existing stores in the Trax database.

  2. Store data should be added to a file to be sent as part of the corresponding POST request (see below). Supported file formats:

    1. Excel

    2. CSV

    3. JSON.

  3. Store import is an async process, ie. the response contains a job ID which can be used to poll the API to get all available data incl. the status for the given upload.

  4. The Excel/CSV/json should/can contain the following fields (mandatory fields are marked with an asterisk *):

    1. Store Number (json: store_number) - string(100) *
      The client's store unique identifier​

    2. Store Name (json: store_name) - string(100) *
      Name of the store

    3. Display Name (json: store_display_name) - string(100)
      A display (short-version) name of the store for report use (for Trax output solutions)

    4. Store Type (json: store_type_name) - string(100)
      One of the values for the Store Type store attribute that have been implemented from the client to Trax.

    5. Region (json: region_name) - string(45) *
      One of the values for the Region store attribute that have been implemented from the client to Trax.

    6. District (json: district_name) - string(45)
      One of the values for the District store attribute that have been implemented from the client to Trax.

    7. Branch (json: branch_name) - string(45)
      One of the values for the Branch store attribute that have been implemented from the client to Trax.

    8. Retailer (json: retailer_name) - string(100)
      One of the values for the Retailer store attribute that have been implemented from the client to Trax.

    9. State (json: state_name) - string(100)
      One of the values for the State store attribute that have been implemented from the client to Trax.

    10. Street (json: street) - string(200) *
      Address street info e.g. "65 Chulia Street"

    11. Address Line 2 (json: address_line_2) - string(100)
      Additional address information

    12. City (json: city) - string(100) *
      Address City info

    13. Deleted (json: is_deleted) - boolean
      True - delete the store
      False - remove the delete flag (By default false)

    14. Postal Code (json: postal_code) - string(45)
      Address Postal (ZIP) code

    15. Latitude (json: latitude) - Float(10,6)
      GPS latitude coordinate (in degrees) 

    16. Longitude (json: longitude) - Float(10,6)
      GPS longitude coordinate (in degrees) 

    17. Active (json: is_active) - boolean
      Indicates whether the store is active or has been deactivated. Optional values 'true' or 'false'
      (Settings this value to 'false' will remove the store from the Trax Mobile Application. It will still appear in Trax reports) - default value is 'true'

    18. Manager Name (json: manager_name) - string(45)
      Name of the store's manager (or another contact person for the store)

    19. Manager Email (json: manager_email) - string(100)
      Email of the store's manager

    20. Manager Phone (json: manager_phone) - string(45)
      Phone number of the store's manager

    21. Audit Cycle Set (json: audit_cycle_set) - string(100)
      Name of the audit cycle set to be connected to the store

  5. In addition, you can also include additional attribute values as they are available for your project by using the following additional fields:​

    1. Additional Attribute 1 (json: additional_attribute_1) - string(100)
      Additional attribute for the store

    2. Additional Attribute 2 (json: additional_attribute_2) - string(100)
      Additional attribute for the store

    3. Additional Attribute 3 (json: additional_attribute_3) - string(100)
      Additional attribute for the store

    4. ...

  6. Store Update Operation Details:

    1. Operations are done in an "update + insert" style

    2. In order to add a new store

      1. Add an object/row with all the required fields.

      2. The operation will succeed only if all the mandatory fields will be provided

    3. In order to update a store: 

      1. Add an object/row with all the required fields. The operation will succeed only if all the mandatory fields will be provided 

      2. The unique identifier of a store is the 'store_number' field. This field is not editable

      3. Empty or missing field values will be treated as clearing the field values.

    4. In order to delete a store:

      1. Add an object/row with the store_number of the store, which serves as a unique identifier, and in addition to the rest of the mandatory fields

      2. Set the 'is_deleted' value to true 

    5. Note that setting a store to 'is_active: false' does not delete the store​.

  7. Each object/row of the file will be validated. Invalid objects/rows will be added to an error file, while the valid ones are upserted to the database.

Store Import API V5

Examples

Let’s assume we have 3 stores in the Trax database with the following fields:

[
   {
      "store_number":"100",
      "store_name":"Sample Store 100",
      "store_display_name":"Store 100",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer1",
      "street":"Test Street 4",
      "city":"Test City",
      "postal_code":"1111",
      "is_active":"false",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue1",
      "additional_attribute_2":"testValue2"
   },
   {
      "store_number":"200",
      "store_name":"Sample Store 200",
      "store_display_name":"Store 200",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer1",
      "street":"Test Street 12",
      "city":"Test City",
      "postal_code":"1212",
      "is_active":"false",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue3",
      "additional_attribute_2":"testValue4"
   },
   {
      "store_number":"300",
      "store_name":"Sample Store 300",
      "store_display_name":"Store 300",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer1",
      "street":"Test Street 30",
      "city":"Test City",
      "postal_code":"2323",
      "is_active":"false",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue5",
      "additional_attribute_2":"testValue6"
   }
]

Now, we are sending the following store update to Trax via API:

[
   {
      "store_number":"200",
      "store_name":"Sample Store 200",
      "store_display_name":"Store 200",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer2",
      "street":"Test Street 12",
      "city":"Test City",
      "postal_code":"1212",
      "is_active":"false",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue3",
      "additional_attribute_2":"testValue4"
   },
   {
      "store_number":"300",
      "store_name":"Sample Store 300",
      "store_display_name":"Store 300",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer1",
      "street":"Test Street 30",
      "city":"Test City",
      "postal_code":"2323",
      "is_deleted":"true",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue5",
      "additional_attribute_2":"testValue6"
   },
   {
      "store_number":"400",
      "store_name":"Sample Store 400",
      "store_display_name":"Store 400",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer1",
      "street":"Test Street 455",
      "city":"Test City",
      "postal_code":"3434",
      "is_active":"false",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue1",
      "additional_attribute_2":"testValue2"
   },
   {
      "store_number":"500",
      "store_type_name":"testStoreType",
      "region_name":"testRegion",
      "retailer_name":"testRetailer1",
      "street":"Test Street 455",
      "city":"Test City",
      "postal_code":"3434",
      "is_active":"false",
      "manager_name":"Test Manager",
      "manager_email":"test@manager.com",
      "additional_attribute_1":"testValue1",
      "additional_attribute_2":"testValue2"
   }
]

After a successful validation and upsert, the following will happen:

  1. The store with the store number 100 will remain intact.

  2. The store with the store number 200 will be updated by changing the retailer from testRetailer1 to testRetailer2.

  3. The store with the store number 300 will be deleted.

  4. A new store with a store number 400 will be created.

  5. Creating a new store with the store number 500 will be rejected since the store update file does not contain a mandatory field (store_name).

Endpoints

Store updates to Trax

Upload details

Source and error file

POST

Aim: To enable Clients to upload a file containing store data to Trax.

Supported protocol: HTTPS

POST <host>/api/v5/<project_name>/store-import/upload

Ex. https://services.traxretail.com/api/v5/myproject/store-import/upload

Route

Request

Request Headers

Authorization string

Value: 'Auth-Token {project auth token}'

Authentication token provided by Trax

Request Body

file*

Excel/CSV/json file with the store data as described above​​

Import ID

Response

Store updates to Trax

Errors

400 missing file

400 unsupported file format

404 invalid route

500 server error

GET

Upload Details

Aim: To enable Clients to get an update on a file upload by providing the import ID

Route

Supported protocol: HTTPS

GET <host>/api/v5/<project>/store-import/<import_id>

Ex. https://services.traxretail.com/api/v5/myproject/store-import/129387129391823

Request

Data in json format:

fileName

Name of the source file with extension

importedBy

Email of the user who uploaded the file - or in case of API upload, a constant value (api-user)

started

Timestamp of the import start time

status

one of the following values

  • queued - initial status upon sending the request

  • validating - status for the time of the file validation 

  • validated - status after successful validation

  • importing - status for the time of the file's valid data import

  • imported - status after successful validation (terminal state)

  • failed - status for errors (terminal state)

parsed

Number of objects/rows parsed

total

Total number of objects/rows included in the source file

errored

Number of invalid stores (ones with errors)

fileID

ID of the source file

errorID

ID of the error log file

uuid

UUID of the file upload

message

additional information on the upload

Example response

{
         "fileName":"test_store_update.csv",
         "importedBy":"myproject-api-user",
         "started":"2023-11-17T12:19:06.652Z",
         "status":"imported",
         "parsed":11234,
         "total":11232,
         "errored":2,
         "fileId":"65575a3ad48b4b00075c91dc",
         "errorId":"65575a454adfab00077d0e32",
         "uuid":"8e795776-22b2-4f32-843b-9084097d7e74",
         "message":""
      }

400 invalid token

404 invalid route

400 bad request invalid query params

500 server error

Request Headers

Authorization string

Value: 'Auth-Token {project auth token}'

Authentication token provided by Trax

Request params

import ID

Response

Errors

GET

Source and error file

Aim: To enable Clients to retrieve the source or error file for a previous store import 

Route

Supported protocol: HTTPS

GET <host>/api/v5/<project>/store-import/file/<fileID>

Ex. https://services.traxretail.com/api/v5/myproject/store-mport/file/63bc1776aa849663db977fce

Request

Request Headers

Authorization string

Value: 'Auth-Token {project auth token}'

Authentication token provided by Trax

Request Param:

fileID*

Source or error file ID as provided in the response to a GET upload details request.

Response

  • Error: File in CSV format

  • Source file: as provided in the upload request (ie. CSV or Excel or JSON)

Errors

400 invalid token

500 bad request (in case of invalid fileID)

500 server error

bottom of page