Start using the GraphQL API
Note
The GraphQL API is currently available at the following endpoint:
https://graph.cleverbridge.com/graphql
If you are interested in using this API, contact Client Experience.
Before integrating our GraphQL API, read through the following information to help you get started:
Authentication
Important
Before you set up authentication for the Cleverbridge GraphQL API, you MUST register with Client Experience.
For more information about the registration process, see below.
The Cleverbridge GraphQL API uses the open-source OpenID Connect framework for authentication. It allows Cleverbridge to not only verify your identity using our identity server, but also obtain basic profile information which we then use to grant you an access token for the API.
OpenID Connect allows clients of all types, including web-based, mobile, and JavaScript clients, to request and receive access tokens. Therefore, you can set up authentication in a variety of ways. The following describes how to set up authentication for the Cleverbridge GraphQL API and two types of clients that you can use to authenticate.
Note
Our Security Policies ✱ apply to the technical users Cleverbridge sets up in the platform. As per these policies, users are locked out after three failed login attempts.

Generally, you will want to enable an application to communicate with the Cleverbridge GraphQL API. To do so, integrate our implicit authentication flow into your application by completing the following:
- Decide what type of client you would like to use to request and receive access tokens from our identity server.
-
Register to use the CleverbridgeGraphQL API. To do so, contact Client Experience and provide them with the following information:
- ID of your client application (
client_id
) that you will be using to communicate with our identity serverWarning
This is NOT your Cleverbridge client account ID (
client_id
). - Your
redirect
URL - Your
postlogout
URL
- ID of your client application (
- Set up your client application to authenticate using the OpenId Connect implicit flow. To do so, you need the information that you provided in step 2, and the information that you received from Cleverbridge after your registration. This includes:
Field Value authority
https://identity.cleverbridge.com
scope
openid GQL cb_useraccount.profile
For a full description of the OpenId Connect implicit flow, see Implicit Flow.
- Test the authentication process using your client application. If you have any questions during this process, contact Client Experience.

In certain situations, you may want to enable your back-end to communicate directly with the Cleverbridge GraphQL API. To do so, integrate our client-credential authentication flow into your back-end by completing the following:
- In the Commerce Assistant, go to Setup > Add User and set up a Cleverbridge user specifically for authentication purposes:
- Enter a Username in the format <clientname>.GQL.<context>.
- Select the API User privilege for the user.
- Set up one user for each context in which you will use the GraphQL API.
Example
Shieldware Inc. uses the GraphQL API for monitoring purposes. They set up a new user in the Commerce Assistant, naming it Shieldware.GQL.Monitoring.
For more information on how to set up users, see Users ✱.
- Contact Client Experience and provide them with the name of the Cleverbridge user that you will use to authenticate.
- Assign any additional privileges to your Cleverbridge user that you may need for your API calls. For example, if your back-end needs to access purchase information, you or your administrator should assign a privilege that provides full access to purchase-related features. For more information, see Privileges ✱.
- Set up your back-end to authenticate using the client-credential flow. To do so, you need to send an HTTP POST request to the Cleverbridge IDentity server using the following information:
- Send the credentials in an HTTP POST body
Request Header
Content-Type: application/x-www-form-urlencoded
Request Body
grant_type=client_credentials&scope=GQL&client_id=myOidcClient&client_secret=xxxxxx
- Send the credentials in an HTTP POST Basic Auth header
Request Headers
Content-Type: application/x-www-form-urlencoded
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxx
Request Body
grant_type=client_credentials&scope=GQL
Note
With Basic Auth, the
client_id
is used as the username and theclient_secret
is used as the password. - Test the authentication process using your back-end. If you have any questions during this process, contact Client Experience.
Note
Get your Access Token at the following endpoint:
https://identity.cleverbridge.com/connect/token
Field | Value |
---|---|
grant_type
|
Use the fixed value |
client_id
|
The username for the Cleverbridge user that you are using to authenticate. WarningThis is NOT your Cleverbridge client account ID ( |
client_secret
|
The password for the Cleverbridge user that you are using to authenticate. |
scope
|
GQL
|
There are two ways to request a token:
If authenticated, the Cleverbridge IDentity server responds with an access token in JSON Web Token (JWT) format:
{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6IjNmMWI0MTc1OGU0NzM3ZmI[...]",
"expires_in": 3600,
"token_type": "Bearer"
}

One method of integrating with the Cleverbridge GraphQL API is building a browser-based JavaScript client application. For an example of how to build such an application, see Adding a JavaScript client.
Example
A user integrated with the Cleverbridge GraphQL API by building a browser-based JavaScript client application. During the authentication process, the following tasks were performed:
- The user's JavaScript client sends a login request to the Cleverbridge IDentity server. The login request is made possible through specifically-configured HTML and JavaScript files, which include the user's client app ID (
client_id
). For an example, see Add your HTML and JavaScript files. - The Cleverbridge IDentity server authenticates the user and obtains authorization.
- The Cleverbridge IDentity server issues an access token, which allows the user to access the Cleverbridge GraphQL API. The token is valid for one hour.
- The user's JavaScript client retrieves the access token, which it resubmits to the identity server, along with the
Authorization
header andBearer
scheme that are contained within the JavaScript file (see step 1 above). The user can now send a request to the Cleverbridge GraphQL API. - Cleverbridge validates the access token. Once validated, Cleverbridge sends an API response to the user.
- The user's JavaScript client sends a logout request to the Cleverbridge IDentity server. The logout request is contained within the JavaScript file (see step 1 above).

Another method of integrating with the Cleverbridge GraphQL API is using a ReactJS app. There are a number of open-source tools that you can use to build this connection, including react-openidconnect and redux-oidc.

One method of integrating the Cleverbridge GraphQL API into your back-end is using an HTTP client for PHP. The example below uses the PHP library Guzzle.
Example
Shieldware, Inc., adds x-parameters to their order URLs to track their sources of revenue. They want to use the GraphQL API to pull the data stored in the x-parameters into their internal reporting system. For this purpose, they build an HTTP client for PHP.
<?php
$username = Shieldware.GQL.SubscriptionManagement;
$password = test123!;
$query = 'query subParam($id: Int!){
subscription(id: $id) {
id
extraParameters {
key
value
}
}
}';
$subscriptionid = 23431030;
$arguments = ['id' => $subscriptionid];
public function graphql($username, $password, $query, $arguments = null)
{
//Send a login request to the Cleverbridge IDentity server. Use the username and password of the Cleverbridge user that you set up for GraphQL authentication.
$client = new GuzzleHttp\Client(['base_uri' => 'https://identity.cleverbridge.com']);
$request = ['headers' => ['Accept' => 'application/x-www-form-urlencoded'], 'form_params' => ['grant_type' => 'client_credentials', 'client_id' => $username, 'client_secret' => $password]];
//Retrieve the access token returned by the identity server upon successful authentication and authorization.
try
{
$response = $client->request('POST', '/connect/token', $request);
}
catch(GuzzleHttp\Exception\RequestException $e)
{
if ($e->hasResponse())
{
$body = $e->getResponse()
->getreasonPhrase();
$message .= PHP_EOL . 'Response: ' . $body;
}
return false;
}
$token = json_decode($response->getBody()
->getContents())->access_token;
if (!isset($token))
{
$message .= PHP_EOL . 'Token not generated';
return false;
}
//Send a request to the GraphQL server, passing the access token in the Authorization header. Define separate variables for the query string and the arguments associated with the query.
$client2 = new GuzzleHttp\Client(['base_uri' => 'https://graph.cleverbridge.com']);
$request = ['headers' => ['Authorization' => 'Bearer ' . $token, 'Content-Type' => 'application/json', 'Accept' => 'application/json', ], 'body' => json_encode(['query' => $query, 'variables' => $arguments]) ];
$message .= PHP_EOL . $request['body'];
//Retrieve the response returned by the GraphQL server upon successful validation of the access token.
try
{
$response = $client2->request('POST', '/graphql', $request);
}
catch(GuzzleHttp\Exception\RequestException $e)
{
if ($e->hasResponse())
{
$body = $e->getResponse()
->getreasonPhrase();
$message .= PHP_EOL . 'Response: ' . $body;
}
return false;
}
$response = json_decode($response->getBody()
->getContents());
if (isset($response->errors))
{
$message .= PHP_EOL . 'Response: ' . $response->errors[0]->message . ' ' . $response->errors[0]->code;
return false;
}
return $response;
}
?>

To authenticate your requests to the GraphQL API, you must pass the generated access token with each request. The GrapQL API uses OAuth 2.0 for authentication and authorization, and the Bearer authentication scheme. Here is an example of what a request looks like:
curl --location --request POST 'https://graph.cleverbridge.com/graphql' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjNmMWI0MTc1OGU0NzM3ZmI[...]' \
--header 'Content-Type: application/json' \
--data-raw '{"query":"query { subscription(id: 23431030) { id extraParameters { key value } }}","variables":{}}'
Our GraphQL server validates the access token. If the server finds the access token to be valid, the request is allowed to proceed. Requests made with an invalid token receive a 401 Unauthorized
error code.
Header Values
The most relevant GraphQL request header values for our GraphQL API are the following:
Field Name | Description | Example Values |
---|---|---|
Authorization
|
Credentials that authenticate a user-agent with a server. | Basic xxxxxxxxxxxxxxxxxxxxxx or Bearer Token |
Content-Type
|
Format of the request content. | application/json
|
In the following example, the requested resource is a json
object and the request type is a Bearer
access token:
curl --location --request POST 'https://graph.cleverbridge.com/graphql' \
--header 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjNmMWI0MTc1OGU0NzM3ZmI[...]'\
--header 'Content-Type: application/json' \
--data-raw '{"query":"query { subscription(id: 23431030) { id extraParameters { key value } }}","variables":{}}'
Status Codes
The following describes the status codes that result from successful and unsuccessful calls to our GraphQL API.

The Cleverbridge GraphQL API uses conventional HTTP response codes to indicate success or failure of an API call. In general:
- Codes in the 2xx range indicate that the function call was successful.
- Codes in the 4xx range indicate an error that resulted from an incorrectly specified request (for example, a required parameter was missing or the data type passed in a parameter was incorrect).
- Codes in the 5xx range indicate an error on the Cleverbridge side.

Status Code | Description |
---|---|
200 | Successful completion of the call. |
400 | Bad Request (incomplete message, required fields missing, incorrectly formatted JSON). |
401 | Unauthorized Request. Authentication with Cleverbridge failed. Not applicable to cart queries. |
402 | Request failed: Invalid parameters. |
404 | Not Found: The other unique identifier (for example, the subscription ID) set and passed in the call is invalid or does not exist. |
429 | Too Many Requests: Rate limit reached. |
Rate Limits
To guarantee a stable and reliable performance of our platform, Cleverbridge places limits on the amount of data that can be consumed:
- IP Rate Limit: Clients or users are limited to a maximum of 150 requests per second from an IPv4 address or IPv6/64 IP range. All API requests count towards the rate limit.
- Rate Limit per Resource and Client: Some GraphQL resources only accept a certain number of requests from a client per time unit or in total. The limit is configured in the settings for the client.

When an individual IPv4 address or IPv6/64 IP range exceeds the per-second request limit, further requests to our API are blocked with an HTTP 429 status code until the block time has expired. This happens after one minute. The HTTP response contains a Retry-After
header to indicate when you can resume sending requests.
HTTP/1.1 429 Too Many Requests
Content-Type: text/html
Retry-After: 60

The most likely cause of an HTTP 429 Too Many Requests
error is that you perform a batch operation that sends multiple API requests in parallel. To avoid reaching the rate limit with batch operations, observe the following best practices:
- Send API requests in serial and not in parallel, that is the next call included in the batch operation cannot be made until the current call is completed.
- Limit concurrent threads that make requests (across all processes and machines) to a maximum of four.
Developer Guides
In the following guide, you can find additional information about the GRAPHQL API, including a list of available queries and mutations, as well as descriptions of how to implement particular use cases:
Reference Documentation
In the following reference documentation, you can find the GraphQL schema with definitions of object types and fields:
GraphiQL Explorer
GraphiQL is an in-browser tool for writing, validating, and testing GraphQL queries. To use GraphiQL, log in with your Cleverbridge credentials: