Overview

Tebex Headless API allows integration of your store directly into your own frontend or in-game.

The Headless API works with your existing packages, coupons, sales & creator codes.

If you haven't already done so, we recommend having a read of our quick start guide before beginning integration.

You can query the Headless API to retrieve your packages/categories, build a basket for a user, and direct them to checkout - all from within your own frontend implementation (be that a website or in-game).

The Headless API can be used with Tebex.js for a fully embedded checkout experience without the user ever leaving your own website.

Headless API Flow

Below is the expected flow your application should follow when utilizing the Headless API. For a list of all endpoints, please see the Endpoints page.

Packages & Listings

You can retrieve your store's listings in JSON format and display them however you wish:

Gets all categories available in the webstore.

get

Gets all categories from a webstore. This does not include package information. To include package information, add ?includePackages=1 to the URL.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
Responses
200

Successful response returns a list of category information.

application/json
get
/accounts/{token}/categories
200

Successful response returns a list of category information.

Gets a store's categories including all package information with them.

get

Gets all categories from a webstore including packages.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
Responses
200

Successful response returns a list of category information.

application/json
get
/accounts/{token}/categories?includePackages=1
200

Successful response returns a list of category information.

Gets information about a specific category

get

Gets information about a category and returns the packages in that category.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
categoryIdstringRequired

The ID of the category to fetch.

Example: 127244343
Responses
200

Successful response returns the category without package information.

application/json
get
/accounts/{token}/categories/{categoryId}
200

Successful response returns the category without package information.

Gets information about a specific category, including all the packages in the category

get

Gets information about a category and returns the packages in that category.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
categoryIdstringRequired

The ID of the category to fetch.

Example: 127244343
Responses
200

Successful response returns the category with package information.

application/json
get
/accounts/{token}/categories/{categoryId}?includePackages=1
200

Successful response returns the category with package information.

Fetch a package from a webstore by its identifier

get

Gets a package from a webstore by ID.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
packageIdnumberRequired

The package's ID.

Example: 1272441812
Responses
200

Successful response returns the package information.

application/json
get
/accounts/{token}/packages/{packageId}
200

Successful response returns the package information.

Fetch all packages from a webstore

get

Gets all packages from a webstore.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
Responses
200

Successful response returns a list of package information.

application/json
get
/accounts/{token}/packages
200

Successful response returns a list of package information.

Creating Baskets

In order to purchase items, a basket must be created for the customer. Create a basket and allow the customer to login with their username or other OAuth login mechanism (e.g Steam or FiveM).

Create a new basket

post

Creates a new basket for use during checkout.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
Body
complete_urlstringOptional

A URL the user can return to when checkout is completed.

Example: https://example.tebex.io/thank-you
cancel_urlstringOptional

A URL the user can return to when cancelling checkout.

Example: https://tebex.io/
customobjectOptional

Custom data you wish to associate with the basket. This data will be included with webhook responses and GET requests associated with the Basket.

Example: {"foo":"bar"}
complete_auto_redirectbooleanOptional

True if the user should automatically be redirected to the relevant complete/cancel URL

Example: true
Responses
200

Successful response returns the basket information.

application/json
post
/accounts/{token}/baskets

Get authentication links for a basket.

get

Fetches a basket's auth URL.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
returnUrlstringRequired

The URL you would like to redirect the user to after successful basket authentication.

Example: https://example.tebex.io/
Responses
200

Successful response returns the basket auth information.

application/json
get
/accounts/{token}/baskets/{basketIdent}/auth?returnUrl={returnUrl}

Adding and Removing Packages

You can add or remove packages programmatically to the created basket via the API as needed when the user interacts with your application.

Add a package to a basket

post

Add a package with the given ID to the basket.

Path parameters
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Body
package_idstringOptionalExample: 6276316
quantitynumberOptionalExample: 1
Responses
200

Successful response.

application/json
post
/baskets/{basketIdent}/packages

Remove a package from a basket

post

Remove the given package ID from the basket.

Path parameters
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Body
package_idstringOptionalExample: 6276316
Responses
200

Successful response returns the basket.

application/json
post
/baskets/{basketIdent}/packages/remove

Coupons, Gift Cards, and Creator Codes

Once all packages and quantities are selected, apply any relevant coupons, gift cards, or creator codes with these endpoints.

Apply a creator code to a basket.

post

Applies a creator code to a basket.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Body
creator_codestringOptionalExample: Academy10
Responses
200

Successful response returns the basket.

application/json
post
/accounts/{token}/baskets/{basketIdent}/creator-codes

Remove a creator code from the basket.

post

Applies a creator code to a basket.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Responses
200

Creator code removed successfully.

No content

post
/accounts/{token}/baskets/{basketIdent}/creator-codes/remove

No content

Apply a gift card to a basket.

post

Applies a creator code to a basket.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Body
card_numberstringOptionalExample: 0127 0244 7210 1111
Responses
200

Successful response returns the basket.

application/json
post
/accounts/{token}/baskets/{basketIdent}/giftcards
200

Successful response returns the basket.

Remove a gift card from the basket.

post

Removes a gift card from the basket.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Body
card_numberstringOptionalExample: 0127 0244 7210 1111
Responses
200

Gift card removed successfully.

No content

post
/accounts/{token}/baskets/{basketIdent}/giftcards/remove

No content

Apply a coupon to a basket.

post

Applies a creator code to a basket.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Body
coupon_codestringOptionalExample: Academy10
Responses
200

Successful response returns the basket.

application/json
post
/accounts/{token}/baskets/{basketIdent}/coupons
200

Successful response returns the basket.

Remove a coupon from the basket.

post

Removes a coupon code from a basket

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Responses
200

Successful response.

No content

post
/accounts/{token}/baskets/{basketIdent}/coupons/remove

No content

Checkout

When the user is ready to checkout, fetch the basket and direct the user to the links.checkout URL.

Fetch a basket from a webstore by its identifier

get

Gets a basket associated with the provided identifier.

Path parameters
tokenstringRequired

The webstore identifier.

Example: t66x-7cd928b1e9312709e6810edac6dc1fd1eefc57cb
basketIdentstringRequired

The basket identifier.

Example: c00244-d2ac2e77418a55b25292a6bc7a719ad9c529ba2c
Responses
200

Successful response returns the basket information.

application/json
get
/accounts/{token}/baskets/{basketIdent}
200

Successful response returns the basket information.

Starter Template

To get started with your own integration of the Headless API you're able to use our example integration built upon Nuxt.js, Vue & Typescript. Take a look at the tebexio/Headless-Template GitHub repo to begin.

Examples

The following websites are built using the Headless API - hosted via our customers own infrastructure, using frontend frameworks such as Vue or React.

Last updated

Was this helpful?