Skip to content
New Webhooks added: Inventory and Order modifications. Check the changelog →
Cartly Developers

Authentication

Learn about Cartly's authentication methods: Public API, Session, JWT, and OAuth 2.0.

Authentication Methods

MethodUse CaseAuth Header
Public (none)Storefront API — products, collections, searchX-Shop-ID: {shop_id}
Session CookieCustomer accounts — orders, addresses, wishlist__session cookie
JWT BearerAdmin panel — product management, order processingAuthorization: Bearer {token}
OAuth 2.0Third-party apps — marketplace integrationsAuthorization: Bearer {access_token}

OAuth 2.0 Flow

Cartly implements the standard Authorization Code flow per RFC 6749:

  1. Register your app — Create an OAuth app in the Cartly admin with redirect URIs and requested scopes
  2. Authorization request — Redirect merchant to /oauth/authorize with a PKCE code_challenge (S256, required)
  3. User consent — Merchant approves requested permissions
  4. Token exchange — Exchange authorization code for access + refresh tokens
  5. API access — Use access token in Bearer header

Rules worth knowing

  • PKCE — code_challenge = base64url(SHA-256(code_verifier)) without = padding, code_challenge_method=S256; plain is refused at the token exchange.
  • Scopes — space-separated. Names Cartly doesn't know are dropped. Request only scopes registered for your app: a registered-scope mismatch makes the merchant's approval fail (the consent page shows an error) and your redirect_uri gets no callback.
  • Refresh tokens rotate — each refresh_token grant returns a new access token AND a new refresh token; store the new refresh token, the old one is revoked.

OAuth Scopes

Available permission scopes for OAuth applications

NameTypeRequiredDescription
products:readscopeNoView products and variants
products:writescopeNoCreate, update, and delete products
orders:readscopeNoView orders and order history
orders:writescopeNoUpdate order status and fulfillment
orders:ownscopeNoView only orders created by this app
customers:readscopeNoView customer information
customers:writescopeNoCreate and update customers
discounts:readscopeNoView discount codes and rules
discounts:writescopeNoCreate, update, and delete discounts
metafields:readscopeNoView custom metafields
metafields:writescopeNoCreate, update, and delete metafields
webhooks:managescopeNoManage webhook subscriptions
shop:readscopeNoView shop settings and configuration
collections:readscopeNoView product collections
collections:writescopeNoCreate, update, and delete collections
shipping:readscopeNoView shipping zones and rates
shipping:writescopeNoManage shipping configuration
analytics:readscopeNoView analytics and reports
inventory:readscopeNoView inventory levels
inventory:writescopeNoSet inventory levels (PUT /apps/api/inventory/:variant_id)
theme_extensions:writescopeNoAdd app blocks that render on the storefront (OAuth apps only)
checkout_extensions:writescopeNoAdd extensions that render during checkout (OAuth apps only)

Code Examples

bash
# Step 1: send the merchant's browser to (one line):
# https://cartly.pro/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri=https%3A%2F%2Fyourapp.com%2Fcallback&scope=products%3Aread%20orders%3Aread&state=RANDOM_STATE&code_challenge=BASE64URL_SHA256_OF_CODE_VERIFIER&code_challenge_method=S256

# Step 2: Exchange code for token (send the code_verifier)
curl -X POST https://cartly.pro/oauth/token \
  -H "Content-Type: application/json" \
  -d '{"grant_type":"authorization_code","code":"AUTH_CODE","client_id":"YOUR_CLIENT_ID","client_secret":"YOUR_SECRET","redirect_uri":"https://yourapp.com/callback","code_verifier":"CODE_VERIFIER"}'