Dev

Authentication

How to authenticate with CloudCart APIs.

CloudCart supports two authentication methods depending on the API you're using.

Admin API & REST JSON:API

Both APIs use token-based authentication via request headers.

Personal Access Token (PAT)

Generate a PAT from your store admin panel at Settings → PAT Tokens — illustrated guide.

POST /api/gql HTTP/1.1
Host: {shop}.cloudcart.com
Authorization: Bearer cc_pat_xxxxxxxxxxxxx
Content-Type: application/json

For the REST JSON:API, use the X-CloudCart-ApiKey header instead:

GET /api/v2/products HTTP/1.1
Host: {shop}.cloudcart.com
X-CloudCart-ApiKey: your-api-key-here
Content-Type: application/vnd.api+json

Storefront API

The Storefront API uses a Storefront Access Token which is safe to expose in client-side code.

POST /api/sf HTTP/1.1
Host: {shop}.cloudcart.com
X-Storefront-Access-Token: YOUR_STOREFRONT_TOKEN
Content-Type: application/json

For customer-specific operations, additionally include a Customer JWT:

Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...

Each Nitrogen storefront gets its own token — cloudcart nitrogen env pull writes it to your .env.

Best Practices

  • Never expose Admin API or REST JSON:API keys in client-side code
  • Rotate tokens periodically
  • Use the minimum scope required for your integration
  • Store tokens in environment variables, never in source code

On this page