Skip to main content
API Sales V4

Connect Bunker DB to your online forms and get all of your consumers data in real time.

Marcelo Ayala avatar
Written by Marcelo Ayala
Updated over a year ago

POST: /api/v4/sales

The information required to register each sale is: on the one hand, the match_key data that refers to the search model and assignment to the corresponding pre-existing record.

On the other hand, we have the information about the sale itself:

  • event_time: (required) - day and time in YYYY-MM-DD HH:MM:SS format.

  • order_id: (string) - Order number to link with the external sales system.

  • external_sale_id: (string) - Sale identifier or ID with the external sales system.

  • value - Sale value.

  • currency - Currency used in the transaction; if not provided, Bunker DB will use the currency defined for the brand. It follows the international standard ISO 4217.

Sale example:

[

{

"match_key": {

"phone": "4692023332"

},

"event_time": "2019-07-13 12:34:21",

"order_id": "12332223421"

}

]

As shown, the match_key contains the search expression to resolve the possible record.

The available fields are:

  • id

  • document

  • email

  • phone

  • cellphone

The assignment is direct and can produce the following results:

  • created/updated: Sale created or updated correctly for registration.

  • not found: The record was not found according to the provided id, email, phone, cellphone, document - These fields refer to the attribution model implemented in Bunker DB analytics where they can return the same states as the previous case if the related record could be accurately detected. Or either return:

  • not unique: In this case, a unique record could not be identified, and the matches are included in the response so that the operator can select the one that best fits (re-registering the sale but in this case using the corresponding id).

Response states

To create, update, not_found, and not_unique, another state is called invalid, which applies only when the event_time date is malformed or could not be recognized.

The response maintains the same order as the input information, adding:

  • sale_id: Sale identifier only for created/updated states.

  • status: Refers to one of the previously mentioned states (created, updated, not found, not unique, invalid).

  • reason: Complementary information to the state, if required.

  • matches: Only for the "not unique" state, and this is where the list of records corresponding to the mapping by attribution is provided, and for which a single record could not be identified.

  • userdata_id: The matched record identifier is returned. Only for the states: created/updated.


Example response for not_unique

[

{

"match_key": {

"email": "[email protected](opens in new tab)"

},

"event_time": "2016-08-10 11:14:13",

"value": 2200,

"response": {

"status": "not unique",

"reason": "Can't resolve unique registry by attribution",

"matches": [

{

"BunkerID": "41369",

"CampaignRefID": null,

"First Name": "Mateo",

"Last Name": "Menestrina",

"Email": "[email protected](opens in new tab)",

"Record created at": "2015-12-03 00:00:00",

"Document": null,

"Document Type": null,

"Document Country": null,

"Phone": null,

"Cellphone": null,

"Gender": null,

"Birthday": null,

"Address": null,

"City": null,

"State": null,

"Country": null,

"Postal Code": null,

"Device": null

},

{

"BunkerID": "41370",

"CampaignRefID": null,

"First Name": "Jow",

"Last Name": "Doe",

"Email": "[email protected]",

"Record created at": "",

"Document": null,

"Document Type": null,

"Document Country": null,

"Phone": null,

"Cellphone": null,

"Gender": null,

"Birthday": null,

"Address": null,

"City": null,

"State": null,

"Country": null,

"Postal Code": null,

"Device": null

}

]

}

}

]

Example response for: created and updated.

[

{

"match_key": {

"id": "41367"

},

"event_time": "2019-07-13 12:34:21",

"order_id": "12332223421",

"response": {

"sale_id": 5,

"status": "created",

"userdata_id": "41367"

}

},

{

"match_key": {

"email": "[email protected](opens in new tab)"

},

"event_time": "2016-02-10 11:14:13",

"order_id": "3325-uy",

"response": {

"sale_id": 3,

"status": "updated",

"userdata_id": "41367"

}

}

]

Example response for not_found

[

{

"match_key": {

"id": "4136799999"

},

"event_time": "2019-07-13 12:34:21",

"order_id": "12332223421",

"response": {

"status": "not_found",

"reason": "Userdata not found",

"userdata_id": "4136799999"

}

}

]

Example response for invalid

[

{

"match_key": {

"id": "4136799999"

},

"event_time": "30-02-2020",

"value": 545.5,

"response": {

"status": "invalid",

"reason": "The parsed event_time was invalid",

"userdata_id": "4136799999"

}

}

]


Did this answer your question?