📍 Bolt Help / Products / Checkout / Bolt Checkout Direct API Integration Guide / How to Create a Bolt Order Token
How to Create a Bolt Order Token
Learn how to build a request that initiates checkout using a token.

Create an order token to initiate the checkout process. This token is used to reference the cart generated in your storefront.

Step 1: Configure Authorization & Headers

  1. Log in to the Merchant Dashboard.
  2. Navigate to Administration > API.
  3. Scroll to API Keys and click the eye icon to reveal your API Keys.
  4. Embed this Publishable Key on your website. The publishable key is a long string of lower and upper case letters and numbers that consists of three sections. publishable key

TIP

The Signing Secret found in the Key section must also be used to authenticate payloads sent by Bolt.

Headers

HEADER VALUE
X-Api-Key Provide the API_KEY
X-Nonce unique 12-16 digit for every request (UUID is a good option)
Content-Type application/json

API URLs

Environment Bolt API URLs
Sandbox https://api-sandbox.bolt.com
Production https://api.bolt.com

Step 2: Make a Create Order Request

Step 1: Call Order Endpoint

See the Official API Reference for a request example.

PHP Example

<?php
require(dirname(__FILE__) . '/init_example.php');

$client = new \BoltPay\ApiClient([
    'api_key' => \BoltPay\Bolt::$apiKey,
    'is_sandbox' => \BoltPay\Bolt::$isSandboxMode
]);


$exampleData = new \BoltPay\Example\Data();
$cartData = $exampleData->generateCart();

/** @var \BoltPay\Http\Response $response */
$response = $client->createOrder($cartData);
$orderToken = $response->isResponseSuccessful()  ? @$response->getBody()->token : '';

Step 2: Validate the Response

Request

Check for a HTTP 200 success code and that the response contains an order token.

Cart

Ensure that the order_reference value corresponds to the unique cart ID value provided in the request and that the cart_url matches as well.

Items & Totals

Ensure the following for each item and its values:

  • Items listed in the response must match the items listed in the request
  • The unit_price, total_amount and tax_amount must be in cents
  • Every item must have an image_url, name, and description
  • The total_amount must equal (quantity X unit_price) + tax_amount
  • Every cent must be precisely accounted for
  • You cannot not apply a discount amount that is more than the total order amount. Doing so will result in an error. It is recommended you calculate a max allowable discount amount using the formula line item totals + tax + shipping = max allowable discount