For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Create a Storefront token (with CORS) for browser/client use → stored in storefront_token
Create a Private Token for server-to-server use → stored in private_storefront_token
View the GraphQL Storefront API example with your own store’s data
Log in a customer account
Create a Store-level API Account
Log in to your BigCommerce store.
Navigate to Settings > Store-level API Accounts.
Click the Create API Account button.
Choose “V2/V3 API token” as the token type.
Type a name for the API Account.
Configure OAuth scopes as follows (some of these scopes are for later labs).
Scope
Permission
Create payments
create
Get payment methods
read-only
Storefront API Tokens
manage
Storefront API Customer Impersonation Tokens
manage
Click the Save button.
Copy the Access Token and save the API account information in a place you can access later.
Create a Storefront Token (browser/client use)
You’ll create a Storefront token with allowed_cors_origins so it can be used from a browser (e.g. for the “View Example” step later). This token is stored in storefront_token. These instructions assume Postman.
Step 1: Configure an Environment
Record the store hash for your BigCommerce store. You can find this in the URL of your control panel, which is in the format https://store-{store hash}.mybigcommerce.com.
In Postman, create a new environment and give it a name.
Create the following environment variables.
Variable Name
Value
v3_token
The access token of your store-level V2/V3 API account
store_hash
Your store hash
storefront_channel_id
1
Step 2: Configure the Storefront Token Request
Create a Postman collection and give it an appropriate name, such as “BC GraphQL Storefront API.”
Create a new HTTP request, then Save it in your new collection with the name “REST Create Storefront Token (with origin).”
In the Authorization tab, set Type to “No Auth.” We will eventually configure GraphQL style authentication on the collection, and this ensures that this authentication will not be used for this REST request.
Set “POST” as the request method.
Enter the following exact value as the URL for your request:
In the Headers tab, use the Presets drop-down to Manage Presets, then Add a header preset (for REST) with the following values:
Field
Value
Accept
application/json
Content-Type
application/json
X-Auth-Token
{{v3_token}}
Select your newly created header preset to populate headers.
In the Body tab, select “raw” as the body type, then select “JSON” in the drop-down list. Enter the following body.
{
"allowed_cors_origins": [
"https://bigcommerce.github.io"
],
"channel_id": {{storefront_channel_id}},
"expires_at": 2147483647
}
The expires_at value used here is simply the maximum allowed expiration date/time. Customer impersonation tokens can be long-lived, but for production tokens you will likely use a more controlled expiration time and rotate the token periodically. In Postman, try using a Pre-request Script to dynamically calculate an appropriate expiration time and set it as a collection variable.
You should test your request now (make sure to select your environment in the environments drop-down) and verify that a token is successfully received.
Step 3: Add Tests
In the Scripts tab of your “REST Create Storefront Token (with origin)” request, add the following “Post-response” value.
This will run tests whenever the request is sent, verifying that the response is not an error and contains a token in the body.
Make sure your environment is selected in the environments drop-down, send the request, and verify that the tests pass in the “Test Results” tab of the response panel.
Create a Private Token
For server-to-server GraphQL requests (and the rest of this course), use a Private Token. Create a new request like the Storefront token one above, with these differences so the token is stored in private_storefront_token:
Step 1: Configure the Private Token Request
Save the request with the name “REST Create Private Token (server-to-server).”
Enter a body with channel_id, expires_at, and scopes (required):
{
"channel_id": {{storefront_channel_id}},
"expires_at": 2147483647,
"scopes": [
"Unauthenticated",
"Customer"
]
}
You should test your request now (make sure to select your environment in the environments drop-down) and verify that a token is successfully received. In our next steps, however, we’ll tweak the request to store the token permanently.
Step 2: Store the Private Token
You’ve now got a reliable Postman request for generating a new GraphQL token at any time. Rather than manually copy/pasting the token to store it for later use, we can expand the configuration of the request to automatically store the value in our Postman environment variables, right alongside the other credentials we’ve saved. This approach will also make it simple to utilize the token in any other GraphQL Storefront requests you may want to prototype in Postman.
While we’re at it, we’ll also include appropriate tests to verify the response.
In the Scripts tab of your “REST Create Private Token (server-to-server)” request, add the following “Post-response” value.
Make sure your environment is selected in the environments drop-down, send the request, and verify that the tests pass in the “Test Results” tab of the response panel.
Back in the Scripts tab, add the following code after the tests.
If you view your Postman environment, you should now see a private_storefront_token variable in addition to the v3_token and other values you’ve stored!
Step 3: Configure GraphQL Authorization on the Collection
Open your “BC GraphQL Storefront API” collection.
In the Authorization tab, set Type to “Bearer Token.”
Enter the following as the value for Token (this uses the Private Token for server-to-server GraphQL requests):
{{private_storefront_token}}
Save the collection.
You’ve now configured your collection to automatically use the most recently generated token for any GraphQL requests.
View Example With Your Store’s Data
Run your “REST Create Storefront Token (with origin)” request and copy the token from the response.