After a negotiation session finishes, you will be notified by the Nibble Widget nibble-session-end
event. In the case
of successful negotiations, you can call this API function from a secure server to verify the session details.
HTTP Request link
GET https://api.nibble.website/v1/session/nibbleId
Headers:
X-Api-Key: XXX-XXX
X-Nibble-Api-Secret: XXXX
Content-Type: application/json
Field | Required? | Description |
---|
X-Api-Key | Yes | Your API Key, as provided to you by Nibble. |
X-Nibble-Api-Secret | Yes | Your API Secret, as provided to you by Nibble. |
Content-Type | Yes | Must be application/json . |
Request Path link
Path | Required? | Description | Body |
---|
nibbleId | Yes | Replace with the Nibble ID as provided to the nibble-session-end event. For example, if the sessionId given was AB1934 , the request path should be /session/AB1934 . | None |
HTTP Response link
HTTP Code | Description |
---|
200 | The session was created successfully. Response body will be a JSON object that should be passed to the Nibble Widget via your successCallback . See below for JSON content. |
400 | Bad Request. Nibble ID is missing or invalid. Request body will be a JSON object including an error message to help you identify the issue: { "errorMessage": "sessionId must be specified" } |
401 | Unauthorized. The API Key and/or Secret are missing, invalid or expired. Request body will be a JSON object including an error message to help you identify the issue: { "errorMessage": "API Secret is not valid." } |
404 | Not Found. The requested session cannot be found. Tampering may have occurred, or the session may have long since expired. Treat this as an unsuccessful negotiation. Request body will be a JSON object including an error message to help you identify the issue: |
JSON Body link
{
"nibbleId": "AB1934",
"sessionStatus": "successful",
"productId": "ABCD",
"variantId": "DEF123",
"negotiatedPrice": "130.50",
"retailerSessionId": "XXXX",
"quantity": 2,
"additionalProducts": [
"productId": "ZYXW",
"negotiatedPrice": "20.00"
],
"nextAction": "checkout"
}
Field | Description | Notes |
---|
nibbleId | The Nibble ID, as passed to this API function. | |
sessionStatus | The status of the negotiation session, either open , successful or failed . Only successful negotiations should result in the product being added to basket. You must verify that the status is successful in such cases. | |
productId | The ID of the product, as provided to the Nibble Cloud API at time of session creation. You must verify that this matches the product in question, in order to determine that the session has not been hijacked or replayed. | |
subProductId | The ID of the variant, colourway or sub-product, as provided to the Nibble Cloud API at time of session creation (if it was provided). | If specified |
negotiatedPrice | The final negotiated total price, as agreed between Nibble and the user. You should add the product to the user’s basket at this price. | Only appears for successful sessions |
retailerSessionId | Your Retailer Session ID, as provided to the Nibble Cloud API at time of session creation. You must verify that this matches the user’s session. | |
quantity | The final negotiated quantity of items agreed on between Nibble and the user. You should set the number of units for the product in the user’s basket equal to this quantity. | Only appears for successful sessions |
additionalProducts | If Nibble has been configured to offer addon items during a negotiation (for example, free gifts as ‘sweeteners’ or bundle items), and if the user chooses to add one or more of those products, they will be specified here. They should be added to the basket alongside the main product in question, at the price specified in negotiatedPrice . | |
nextAction | The next action the user requested - either 'continue_shopping' or 'checkout' . | |
payload | The cryptographically signed payload of the Nibble’s details. | |