API Authentication

Access CommerceClarity APIs via Bearer Token

CommerceClarity APIs use Bearer Token authentication to protect endpoints and ensure that only authorized clients can access the data. Each API request must include a valid access token in the HTTP header.

Getting an API Token

Currently, API tokens are provided directly by the CommerceClarity support team. To request an access token, fill out the support form available at this link providing your organization name and the API token request in the description.

Using the Token

To authenticate your API requests, include the token in the Authorization header of each HTTP request using the format Bearer <token>.

Header Format
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

API Request Examples

cURL Example
curl -X GET "https://api.commerceclarity.com/api/2026-05/entities" \
     -H "Authorization: Bearer YOUR_API_TOKEN" \
     -H "Accept: application/json"
JavaScript Example (Fetch)
const apiUrl = 'https://api.commerceclarity.com/api/2026-05/entities';
const token = 'YOUR_API_TOKEN';

fetch(apiUrl, {
  method: 'GET',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Accept': 'application/json'
  }
})
.then(response => {
  if (!response.ok) {
    throw new Error(`Status: ${response.status}`);
  }
  return response.json();
})
.then(data => {
  console.log('Received data:', data);
  // Process the data
})
.catch(error => {
  console.error('Error during the API request:', error);
});
PHP Example (Guzzle)
<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;

$client = new Client([
    'base_uri' => 'https://api.commerceclarity.com/api/2026-05/',
    'timeout'  => 10.0,
    'headers' => [
        'Authorization' => 'Bearer YOUR_API_TOKEN',
        'Accept' => 'application/json',
    ]
]);

try {
    $response = $client->get('entities');
    $data = json_decode($response->getBody()->getContents(), true);
    
    // Process the data
    
} catch (RequestException $e) {
    if ($e->hasResponse()) {
        $errorResponse = json_decode($e->getResponse()->getBody()->getContents(), true);
        // Handle the error...
    }
}
Python Example (Requests)
import requests

api_url = 'https://api.commerceclarity.com/api/2026-05/entities'
token = 'YOUR_API_TOKEN'

headers = {
    'Authorization': f'Bearer {token}',
    'Accept': 'application/json'
}

try:
    response = requests.get(api_url, headers=headers)
    response.raise_for_status()  # Raise an exception for HTTP 4XX/5XX responses
    
    data = response.json()
    
    # Process the data
    
except requests.exceptions.HTTPError as err:
    print(f'HTTP Error: {err}')
    if response.text:
        error_data = response.json()
        print(f'Error message: {error_data.get("message", "No message")}')
except requests.exceptions.RequestException as err:
    print(f'Request error: {err}')

Authentication Errors

If the token is missing or invalid, the API request will receive a 401 Unauthorized error response.

Authentication Error Response Example
{
  "status": "error",
  "timestamp": "2026-10-29T10:00:00.000000Z",
  "errors": {
    "error": "Authentication failed. Please check your authentication credentials"
  }
}

Token Security

API Token Protection

Your API token provides full access to your CommerceClarity account. To protect your data:

  • Treat the token like a password - do not share it with unauthorized third parties
  • Never include the token directly in public source code or repositories
  • Use environment variables or secret management systems to store the token
  • Immediately revoke any compromised token by contacting support

Best Practices

Communication Security

Always use HTTPS for API requests to ensure that the token and all transmitted data are encrypted during transit.

Tokens in Frontend Clients

Avoid including API tokens in publicly accessible JavaScript frontend applications. Instead, use a backend server to make API requests.

Troubleshooting

Problem Possible Cause Solution
"Unauthenticated" or 401 error Missing or invalid token Verify that the token is correctly formatted and included in the Authorization header
403 or 404 on some requests brand_id names a brand you do not belong to (403) or that does not exist (404) Take brand_id from Workspace & brands

Next Steps

Create entity

Create entities from product codes and have them enriched automatically.

Go to Create entity
List / Query entities

Retrieve and filter your entities and their attributes with the declarative filter tree.

Go to List / Query entities
List attributes

Discover the brand's attributes and their norm_name for use in filters.

Go to List attributes

Assistance

Technical Support

If you have questions or encounter issues with the APIs, our support team is available to help. Fill out the support form available at this link including details about your request and any error messages received.