When needed, as determined by the Nibble Widget nibble-session-start event, call this API function from a secure server to create a Nibble for negotiation. When successful, the full JSON response should be returned to the Nibble Widget via your successCallback.

HTTP Request

POST https://api.nibble.website/v1/session
Headers:
    X-Api-Key: XXX-XXX
    X-Nibble-Api-Secret: XXXX
    Content-Type: application/json

Header Fields

FieldRequired?Description
X-Api-KeyYesYour API Key, as provided to you by Nibble.
X-Nibble-Api-SecretYesYour API Secret, as provided to you by Nibble.
Content-TypeYesMust be application/json.

JSON Body

{
  "session_token": "XXXX",
  "currency_code": "GBP",
  "negotiation_type": "product",
  "product_id": "ABCD",
  "product_name": "My Product",
  "variant_id": "DEF123",
  "variant_name": "Small",
  "product_price": "150.00",
  "quantity": 2,
  "maxQuantity": 5
}
FieldRequired?Description
session_tokenYesThis should uniquely (or pseudo-uniquely) identify the user’s session within a reasonable period of time, and not be long lived (if a user returns days later, we expect a different Session Token to be provided). As an example, this could be a random string stored in a session cookie that expires in a few hours.
currency_codeNoISO 4217 alphabetic code of the currency in use for this Nibble. Optional, defaults to GBP.
negotiation_typeNoThe negotiation type which can either be set to "product" or cart for cart negotiations. Optional, defaults to "product" if not specified.
product_idYes - For product negotationsA string ID uniquely identifying the product. You can specify any string as a valid ID, but all negotiations for the same product should be created with the same product_id.
product_nameYes - For product negotiationsThe name of the product in question. This may be used by Nibble in the negotiation, or when reporting on negotiations later.
variant_idNo - product negotiations onlyA string ID uniquely identifying the variant, colourway or sub-product in question. If your product does not have such options, this field can be omitted.
variant_nameNo - product negotiations onlyThe name of the variant, colourway or sub-product in question. If your product does not have such options, this field can be omitted.
original_priceNoFor product negotiations, this should be normal retail unit price of the product. For cart negotiations, it is the total of all items in the cart, before shipping and taxes. Represented as a decimal number without currency symbol. E.g. 150.00.
quantityNo - product negotiations onlyThe quantity the user has chosen to buy/negotiate for. Optional, defaults to 1 if not specified.
max_quantityNo - product negotiations onlyThe maximum quantity of a product the user can negotiate on. If specified, should be set to the retailer’s current stock level for the product. Optional, defaults to 10 if not specified.

HTTP Response

HTTP CodeDescription
200The session was created successfully. Response body will be a JSON object that should be passed to the Nibble Widget via your successCallback.
400Bad Request. One or more required fields are missing or invalid. Request body will be a JSON object including an error message to help you identify the issue: { "errorMessage": "productId must be specified" }
401Unauthorized. 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." }