# Get Affiliate Source: https://chariow.dev/api-reference/affiliates/get-affiliate GET /affiliates/{affiliateCode} Retrieve details of a specific affiliate by their unique code Retrieves detailed information about a specific affiliate by their unique affiliate code. This endpoint returns comprehensive affiliate information including their account details, performance statistics, and earnings. The code is matched exactly. **Required scope:** `affiliates.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The unique affiliate code (e.g., `CREATOR123`, `PARTNER2025`) ## Response Unique store affiliate identifier (e.g., `saff_abc123xyz`) Affiliate status: `active` or `suspended` How the affiliate joined the store Human-readable label (e.g., `Invitation`, `Network`) Description of the source Source value: `invitation` or `network` Total number of visits through affiliate links Total number of sales made through referrals Total commission earnings Earnings amount Formatted earnings with currency symbol (e.g., `$1,250.00`) Abbreviated earnings (e.g., `1K`) Currency code (e.g., `USD`) ISO 8601 timestamp of first referral visit ISO 8601 timestamp of most recent referral visit ISO 8601 timestamp when the affiliate was suspended (if applicable) Reason for suspension (if applicable) Affiliate account details Affiliate account public ID (e.g., `aff_abc123def`) Affiliate's display name Affiliate's country: `name`, `code`, `alpha_3_code`, `dial_code`, `currency` and `flag` Account status User details: `id`, `name`, `first_name`, `last_name`, `nickname`, `email` and `profile_photo_url` Account creation timestamp ISO 8601 creation timestamp ISO 8601 last update timestamp ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/affiliates/CREATOR123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/affiliates/CREATOR123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); console.log(data); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/affiliates/CREATOR123'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/affiliates/CREATOR123', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json() ``` ```json Response (200) theme={null} { "data": { "id": "saff_xyz789abc", "status": "active", "source": { "label": "Invitation", "description": "Added via store invitation", "value": "invitation" }, "total_visits": 150, "total_sales": 25, "total_earnings": { "value": 1250, "formatted": "$1,250.00", "short": "1K", "currency": "USD" }, "first_visit_at": "2025-01-16T09:00:00+00:00", "last_visit_at": "2025-01-25T14:30:00+00:00", "suspended_at": null, "suspended_reason": null, "account": { "id": "aff_abc123def", "pseudo": "creative_studio", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" }, "status": "active", "user": { "id": "usr_def456", "name": "John Doe", "first_name": "John", "last_name": "Doe", "nickname": null, "email": "john@example.com", "profile_photo_url": null }, "created_at": "2025-01-15T10:30:00+00:00" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-25T14:30:00+00:00" } } ``` ```json Not Found (404) theme={null} { "message": "Affiliate not found. Please verify the affiliate code and ensure it is associated with this store.", "errors": [] } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` # Send Affiliate Invitations Source: https://chariow.dev/api-reference/affiliates/send-invitations POST /affiliates/invitations Send invitation emails to potential affiliates Sends invitation emails to the provided email addresses. Up to 25 emails can be sent in a single request. Existing affiliates and pending invitations are automatically skipped, and only the invitations created are returned. **Required scope:** `affiliates.write`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Request Body Array of email addresses (1-25 items, each a valid address of at most 255 characters). Addresses are lower-cased and duplicates are removed. **Example:** `["john@example.com", "jane@example.com"]` ## Response Returns `201 Created`. `Invitation sent successfully.` for one invitation, or `N invitations sent successfully.` otherwise Invitations created by this request. Skipped addresses (existing affiliates of your store and addresses with a pending invitation) are not listed: when every address is skipped, `data` is an empty array. Unique invitation identifier (e.g., `affinv_abc123xyz`) Email address the invitation was sent to Invitation status: `pending` ISO 8601 expiration timestamp ISO 8601 acceptance timestamp (`null` until accepted) ISO 8601 creation timestamp Always empty on success ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/affiliates/invitations" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "emails": ["john@example.com", "jane@example.com"] }' ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/affiliates/invitations', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ emails: ['john@example.com', 'jane@example.com'] }) }); const data = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/affiliates/invitations'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'emails' => ['john@example.com', 'jane@example.com'] ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); ``` ```json Response (201 Created) theme={null} { "message": "2 invitations sent successfully.", "data": [ { "id": "affinv_abc123xyz", "email": "john@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" }, { "id": "affinv_def456uvw", "email": "jane@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" } ], "errors": [] } ``` ```json Partial Success (201 Created) theme={null} { "message": "Invitation sent successfully.", "data": [ { "id": "affinv_abc123xyz", "email": "john@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" } ], "errors": [] } ``` ```json Validation Error (422) theme={null} { "message": "The emails field is required.", "data": [], "errors": { "emails": ["The emails field is required."] } } ``` # Authentication Source: https://chariow.dev/api-reference/authentication How to authenticate with the Chariow API and which scopes each endpoint requires The Chariow API uses store API keys to authenticate requests. Each key carries **scopes** that decide which endpoints it can call. ## Creating an API Key Go to [app.chariow.com](https://app.chariow.com) and log in to your account. Click on **Settings** in the sidebar. Select **API Keys** from the settings menu. Click **Create API Key**, give it a descriptive name, choose its scopes, and copy the generated key. Copy your API key immediately after creation. For security reasons, the full key is only shown once. If you do not choose any scopes, the key receives every scope your team role allows. You can change the scopes of an existing key later without regenerating it. ## Making Authenticated Requests Include your API key in the `Authorization` header: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ## Scopes | Scope | Grants access to | | - | - | | `store.read` | Store name, currency, settings and public information | | `products.read` | Products, prices and their published details | | `sales.read` | Sales, their status and amounts | | `customers.read` | Customer list and purchase history | | `customers.pii.read` | Customer email addresses and phone numbers (includes `customers.read`) | | `discounts.read` | Discount codes and their conditions | | `licenses.read` | Licence keys and their activations | | `licenses.write` | Activate and revoke licence keys (includes `licenses.read`) | | `affiliates.read` | Affiliate profiles and codes | | `affiliates.write` | Send affiliate invitations (includes `affiliates.read`) | | `webhooks.read` | Pulse webhooks configured on the store | | `webhooks.write` | Create and delete the Make, Zapier and n8n connections (includes `webhooks.read`) | | `checkout.write` | Start a checkout for a product on behalf of a customer | ### Required scope per endpoint | Endpoint | Required scopes | | - | - | | [Get Store](/api-reference/store/get-store) | `store.read` | | [List Products](/api-reference/products/list-products), [Get Product](/api-reference/products/get-product) | `products.read` | | [Initiate Checkout](/api-reference/checkout/init-checkout) | `checkout.write` | | [List Sales](/api-reference/sales/list-sales), [Get Sale](/api-reference/sales/get-sale) | `sales.read` | | [List Customers](/api-reference/customers/list-customers), [Get Customer](/api-reference/customers/get-customer) | `customers.read` and `customers.pii.read` | | [List Licenses](/api-reference/licenses/list-licenses), [Get License](/api-reference/licenses/get-license), [Get Activations](/api-reference/licenses/get-activations) | `licenses.read` | | [Activate License](/api-reference/licenses/activate-license), [Revoke License](/api-reference/licenses/revoke-license) | `licenses.write` | | [List Discounts](/api-reference/discounts/list-discounts), [Get Discount](/api-reference/discounts/get-discount) | `discounts.read` | | [List Pulses](/api-reference/pulses/list-pulses), [Get Pulse](/api-reference/pulses/get-pulse) | `webhooks.read` | | [Get Affiliate](/api-reference/affiliates/get-affiliate) | `affiliates.read` | | [Send Invitations](/api-reference/affiliates/send-invitations) | `affiliates.write` | A key can never hold more scopes than the team role of the member who created it, and it loses scopes when that role is downgraded. See [Authentication](/en/introduction/authentication#scopes) for the full rules. ## Security Best Practices Never expose your API key in client-side code or public repositories. * Grant each key only the scopes its integration needs * Store keys in environment variables * Use different keys for development and production * Rotate keys periodically * Monitor key usage in your dashboard ## Authentication Errors | Status | Message | Cause | | - | - | - | | 401 | `API key is missing. Please provide a valid API key. Help: https://docs.chariow.com` | Missing `Authorization: Bearer` header | | 401 | `Invalid API key. Please check again. Help: https://docs.chariow.com` | Key is malformed, was deleted, or its creator is no longer an active team member | | 403 | `This credential is missing the required scope: {scopes}. Update its permissions in your dashboard.` | Key lacks a scope the endpoint requires | A `403` scope error lists the missing scopes in `errors.scopes` and in the `WWW-Authenticate` header: ```http theme={null} HTTP/1.1 403 Forbidden WWW-Authenticate: Bearer error="insufficient_scope", scope="customers.pii.read" ``` ```json theme={null} { "message": "This credential is missing the required scope: customers.pii.read. Update its permissions in your dashboard.", "data": [], "errors": { "scopes": ["customers.pii.read"] } } ``` # Initiate Checkout Source: https://chariow.dev/api-reference/checkout/init-checkout POST /checkout Create a new checkout session for a product purchase Initiates a new checkout session for purchasing a product. Creates a sale record and either returns a payment checkout URL for paid products or completes the sale immediately for free products. **Unsupported product types:** the following cannot be used to initiate a checkout through the API: * **Service** products * **Coaching** products * Products with **pay-what-you-want** pricing For these, redirect customers to your [Chariow storefront](https://chariow.com) or use the **Snap Widget** embed on your website. All sales initiated via this API endpoint will have their **Channel** set to **"API"** on your store dashboard. This helps you identify and track sales originating from your API integrations separately from other channels. **Rate limit:** checkout has its own rate-limit bucket of 100 requests per minute per API key, counted separately from the rest of the Public API. A sync job that reads sales or products in bulk cannot use up the budget your buyers need to start a payment. When the limit is exceeded, the API returns `429 Too Many Requests`. **Required scope:** `checkout.write`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Repeat Purchases The ability to purchase a product multiple times depends on the product type: | Product Type | Repeat Purchase | Behaviour | | - | - | - | | **License** | Always allowed | Customers can purchase license products multiple times. Each purchase generates a new unique license key. | | **Downloadable** | Blocked | Returns `already_purchased` if customer has an active access grant. | | **Course** | Blocked | Returns `already_purchased` if customer has an active access grant. | | **Bundle** | Blocked | Returns `already_purchased` if customer has an active access grant. | For blocked product types, if a customer's access has been **revoked** (e.g., after a refund), they will be able to purchase the product again. The system checks for **active** access grants only. ## Authentication This endpoint requires API key authentication via Bearer token: ``` Authorization: Bearer sk_live_your_api_key ``` ## Request Body The product public ID or slug to purchase. The product must be published. Example: `prd_abc123xyz` or `premium-course` Identifier of an active price variant of the product (max 100 characters, case-insensitive). Only applies to products with one-time pricing. An unknown or inactive variant is ignored silently and the product's regular price is used. Customer email address. Must be a valid email address (strict check, max 255 characters). The address is stored in lowercase. Example: `customer@example.com` Customer first name (max 50 characters). Example: `John` Customer last name (max 50 characters). Example: `Doe` Customer phone details Phone number (numeric only). Example: `1234567890` ISO 3166-1 alpha-2 country code of the phone number (max 10 characters). Must be a known country. Example: `US`, `CI`, `SN` **One customer per email address.** Emails are compared case-insensitively, so `John@Example.com` and `john@example.com` resolve to the same customer in your store. When the customer already exists, the checkout reuses that record and updates its first name, last name and phone number with the values you send. Discount code to apply (max 100 characters, case-insensitive). Discount codes only apply to products with one-time pricing. Example: `SAVE20` Affiliate tracking code used to attribute the sale to an affiliate (max 50 characters). Example: `abc12xyz` Campaign public ID or tracking code for analytics. An unknown campaign is ignored. Example: `camp_xyz789` Custom field values for the product (key-value pairs). Must match the product's configured custom fields. ISO 4217 code of the currency the buyer pays in. Defaults to your store currency. The code must be a currency supported by Chariow; an unsupported code returns a `422` validation error on `payment_currency`. When it differs from the product currency, the price is converted and a per-currency conversion markup is included in the amount charged. Example: `XOF`, `EUR`, `USD` Custom URL to redirect customers after payment completion (max 2048 characters). When provided, customers will be redirected to this URL instead of the default Chariow post-purchase page. Must be a valid active URL. Example: `https://yoursite.com/thank-you` Custom key-value metadata to store with the sale. Maximum 10 keys allowed, each value limited to 255 characters. This metadata is included in Pulse webhook payloads, making it useful for linking sales with external systems. Example: `{"order_ref": "ORD-123", "source": "landing_page"}` The buyer's IP address, IPv4 or IPv6. Example: `203.0.113.42` **Why send `customer_ip`?** This endpoint is called from your server, so the IP we see is your own infrastructure, not the buyer's. When you forward `customer_ip`, we store it on the sale and resolve the buyer's country from it, which improves the payment methods offered at checkout and the accuracy of your sales analytics. When the field is omitted, or the IP cannot be located, the buyer's country is taken from `phone.country_code` instead of your server's location, and the sale records the calling IP. HTTPS origins allowed to embed the hosted payment page (the `checkout_url`) in an iframe, up to 4. Each entry must be a canonical origin: lowercase `https://` scheme and host, an optional non-default port, and no path, query, fragment, credentials or trailing slash. Example: `["https://shop.example.com"]` Buy the product as a gift for someone else. The recipient receives access to the product instead of the buyer. Recipient email address (strict check, max 255 characters). Must differ from the buyer's email. Recipient first name (max 50 characters) Recipient last name (max 50 characters) Optional message for the recipient (max 500 characters) ### Shipping Address The `shipping` object is **required** when the product has "Require shipping address" enabled. If shipping is not required for the product, it is ignored. Shipping address of the customer Street address. Example: `123 Main Street` City. Example: `New York` State or region. Example: `NY` ISO 3166-1 alpha-2 country code. Must be a known country. Example: `US` Postal or ZIP code. Example: `10001` ## Response The checkout response object containing step, purchase, and payment information Current checkout step. Possible values: * `payment`: payment required, redirect the customer to `payment.checkout_url` * `completed`: sale completed immediately (free products, or a discount that brings the amount to zero) * `already_purchased`: the customer already owns this product, no sale was created Message for the customer. Set for `already_purchased` ("You already own this product. Access it in your Customer Portal."), otherwise `null`. The sale that was created (`null` for `already_purchased`). Same shape as an item of [List Sales](/api-reference/sales/list-sales). Sale public ID. Example: `sal_abc123xyz` Sale status: `awaiting_payment` for `payment`, `completed` for `completed` Values for conversion tracking pixels: `event_id` (the sale ID), `currency` and `value`. The value is reported in USD when a USD value was recorded at checkout, otherwise in the product currency. Original product price before discounts, in the product currency Amount value Human-readable formatted amount Short formatted amount ISO 4217 currency code Final amount after discounts, in the product currency Total discount applied Payment details Amount the buyer pays, in the payment currency. Omitted when nothing is to be paid. Payment status: `initiated` when a payment session was opened, `null` for a sale completed without payment Exchange rate applied between the product currency and the payment currency Payment failure details (`code`, `customer_message`) when the payment failed, otherwise `null` Shipping address (`address`, `city`, `state`, `country`, `zip`), each `null` when not collected Temporary signed URL to download the invoice (valid for 60 minutes). Only set once the sale is completed. ISO 8601 timestamp when the sale was created ISO 8601 timestamp when the sale was completed Store information (`id`, `name`, `logo_url`, `url`) Product information Customer information (`id`, `name`, `first_name`, `last_name`, `email`, `phone`, `avatar_url`) Name of the buyer as entered for this sale (`first_name`, `last_name`). Unlike `customer`, it does not change when the customer later updates their profile. Applied discount (`id`, `name`, `code`), or `null` Customer rating for the sale, `null` until the customer rates it Only present for gift purchases: `recipient` (customer object) and `message` Payment information Hosted payment page URL. Redirect the customer to this URL to complete payment. It carries the buyer's phone country and number as query parameters so the payment form is prefilled; use it as returned. `null` when no payment is needed. Payment transaction ID. `null` when no payment is needed. Identifier of the payment gateway handling the payment (for example `orqex`). `null` when no payment is needed. Treat it as an opaque string. ## Error Responses The checkout was refused by a business rule. The `message` explains why, for example: invalid phone number for the given country, product sold out, no licence available, empty bundle, discount code inactive, expired, not applicable or used up, store not allowed to receive orders, or the payment session could not be opened (the sale is then marked as failed). Invalid or missing API key Product not found or not published, or discount code not found The gift recipient already owns this product Validation errors (including an unsupported `payment_currency` or an unknown country code), pay-what-you-want product, unsupported product type (Service, Coaching), or a gift addressed to the buyer Checkout rate limit exceeded ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "discount_code": "SAVE20", "redirect_url": "https://yoursite.com/thank-you", "customer_ip": "203.0.113.42", "custom_metadata": { "order_ref": "ORD-123", "source": "landing_page" } }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ product_id: 'prd_abc123xyz', email: 'customer@example.com', first_name: 'John', last_name: 'Doe', phone: { number: '1234567890', country_code: 'US' }, discount_code: 'SAVE20', redirect_url: 'https://yoursite.com/thank-you', customer_ip: '203.0.113.42', custom_metadata: { order_ref: 'ORD-123', source: 'landing_page' } }) }); const result = await response.json(); if (result.data.step === 'payment') { // Redirect to payment URL window.location.href = result.data.payment.checkout_url; } else if (result.data.step === 'completed') { // Free product - sale completed console.log('Purchase completed:', result.data.purchase.id); } ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/checkout'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key', 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'product_id' => 'prd_abc123xyz', 'email' => 'customer@example.com', 'first_name' => 'John', 'last_name' => 'Doe', 'phone' => [ 'number' => '1234567890', 'country_code' => 'US' ], 'discount_code' => 'SAVE20', 'redirect_url' => 'https://yoursite.com/thank-you', 'customer_ip' => '203.0.113.42', 'custom_metadata' => [ 'order_ref' => 'ORD-123', 'source' => 'landing_page' ] ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); if ($data['data']['step'] === 'payment') { // Redirect to payment URL header('Location: ' . $data['data']['payment']['checkout_url']); } elseif ($data['data']['step'] === 'completed') { // Free product - sale completed echo 'Purchase completed: ' . $data['data']['purchase']['id']; } ``` ```python Python theme={null} import requests response = requests.post( 'https://api.chariow.com/v1/checkout', headers={ 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, json={ 'product_id': 'prd_abc123xyz', 'email': 'customer@example.com', 'first_name': 'John', 'last_name': 'Doe', 'phone': { 'number': '1234567890', 'country_code': 'US' }, 'discount_code': 'SAVE20', 'redirect_url': 'https://yoursite.com/thank-you', 'customer_ip': '203.0.113.42', 'custom_metadata': { 'order_ref': 'ORD-123', 'source': 'landing_page' } } ) data = response.json() if data['data']['step'] == 'payment': # Redirect to payment URL checkout_url = data['data']['payment']['checkout_url'] print(f'Redirect to: {checkout_url}') elif data['data']['step'] == 'completed': # Free product - sale completed print(f"Purchase completed: {data['data']['purchase']['id']}") ``` ```json Paid Product - Awaiting Payment theme={null} { "data": { "step": "payment", "message": null, "purchase": { "id": "sal_abc123xyz", "status": "awaiting_payment", "tracking": { "event_id": "sal_abc123xyz", "currency": "USD", "value": 79.2 }, "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "discount_amount": { "value": 19.80, "formatted": "$19.80", "short": "20", "currency": "USD" }, "payment": { "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "status": "initiated", "exchange_rate": { "value": 1, "formatted": "$1.00", "short": "1", "currency": "USD" }, "failure_error": null }, "shipping": { "address": null, "city": null, "state": null, "country": null, "zip": null }, "invoice_download_url": null, "created_at": "2025-01-15T10:30:00+00:00", "completed_at": null, "store": { "id": "str_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "product": { "id": "prd_abc123xyz", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null }, "customer": { "id": "cus_def456", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "avatar_url": null }, "buyer": { "first_name": "John", "last_name": "Doe" }, "discount": { "id": "dis_ghi789", "name": "Save 20%", "code": "SAVE20" }, "rate": null }, "payment": { "checkout_url": "https://payment.example.com/checkout/abc123?country=US&phone=...", "transaction_id": "txn_xyz789abc", "gateway": "orqex" } } } ``` ```json Free Product - Completed theme={null} { "data": { "step": "completed", "message": null, "purchase": { "id": "sal_abc123xyz", "status": "completed", "tracking": { "event_id": "sal_abc123xyz", "currency": "USD", "value": 0 }, "original_amount": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "amount": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "discount_amount": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "payment": { "status": null, "exchange_rate": { "value": 1, "formatted": "$1.00", "short": "1", "currency": "USD" }, "failure_error": null }, "shipping": { "address": null, "city": null, "state": null, "country": null, "zip": null }, "invoice_download_url": "https://api.chariow.com/...signed-invoice-url...", "created_at": "2025-01-15T10:30:00+00:00", "completed_at": "2025-01-15T10:30:01+00:00", "store": { "id": "str_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "product": { "id": "prd_abc123xyz", "name": "Free eBook", "type": "downloadable", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "free", "price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "effective": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" } }, "bundle": null, "metadata": null }, "customer": { "id": "cus_def456", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "avatar_url": null }, "buyer": { "first_name": "John", "last_name": "Doe" }, "discount": null, "rate": null }, "payment": { "checkout_url": null, "transaction_id": null, "gateway": null } } } ``` ```json Already Purchased theme={null} { "data": { "step": "already_purchased", "message": "You already own this product. Access it in your Customer Portal.", "purchase": null, "payment": { "checkout_url": null, "transaction_id": null, "gateway": null } } } ``` ```json Error - Product Not Found (404) theme={null} { "message": "Product not found. Please verify the product ID and ensure it is published.", "errors": [] } ``` ```json Error - Pay-What-You-Want Product (422) theme={null} { "message": "Pay-what-you-want products are not supported via the Public API. Please redirect customers to your Chariow store or use the Snap Widget embed on your website.", "errors": [] } ``` ```json Error - Unsupported Product Type (422) theme={null} { "message": "Service and Coaching products are not supported via the Public API. Please redirect customers to your Chariow store or use the Snap Widget embed on your website.", "errors": [] } ``` ```json Error - Validation Failed (422) theme={null} { "message": "The email field must be a valid email address. (and 1 more error)", "data": [], "errors": { "email": [ "The email field must be a valid email address." ], "phone.number": [ "The phone.number field is required." ] } } ``` ```json Error - Unsupported Payment Currency (422) theme={null} { "message": "Currency 'ABC' not found, if you think this is a mistake, please contact us.", "data": [], "errors": { "payment_currency": [ "Currency 'ABC' not found, if you think this is a mistake, please contact us." ] } } ``` ```json Error - Discount Code Not Found (404) theme={null} { "message": "This discount code doesn't exist. Check the code and try again.", "errors": [] } ``` ```json Error - Discount Expired (400) theme={null} { "message": "This discount has expired. Check the store for current offers.", "errors": [] } ``` ```json Error - Product Sold Out (400) theme={null} { "message": "This product is sold out. Check back later or contact the store.", "errors": [] } ``` ```json Error - Invalid Phone Number (400) theme={null} { "message": "Invalid phone number. Check the number and country code.", "errors": [] } ``` ```json Error - Missing Shipping Address (422) theme={null} { "message": "Please enter your address for shipping. (and 4 more errors)", "data": [], "errors": { "address": [ "Please enter your address for shipping." ], "city": [ "Please enter your city for shipping." ], "state": [ "Please enter your state/region for shipping." ], "country": [ "Please enter your country for shipping." ], "zip": [ "Please enter your postal code for shipping." ] } } ``` # Get Customer Source: https://chariow.dev/api-reference/customers/get-customer GET /customers/{customerId} Retrieve details of a specific customer Retrieves detailed information about a specific customer by their public ID. Returns the complete customer profile including contact information and store details. Each store has one customer per email address (compared case-insensitively). Customers that had been duplicated in the past were merged into the oldest record: the ID of a merged duplicate now returns `404`, and its sales belong to the surviving customer. **Required scopes:** `customers.read` and `customers.pii.read`. Granting `customers.pii.read` alone is enough, as it includes `customers.read`. A key without them receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The unique customer identifier (e.g., `cus_abc123xyz`) ## Response Unique customer identifier (e.g., `cus_abc123xyz`) Customer full name (combination of first and last name) Customer first name Customer last name Customer email address URL to the customer's avatar image Customer phone number International formatted phone number (e.g., `+1 234 567 890`) Country information Country name ISO 3166-1 alpha-2 country code ISO 3166-1 alpha-3 country code Country dial code Country currency code Country flag emoji Store information Store public ID Store name Store logo URL Store URL ISO 8601 timestamp of when the customer was created ISO 8601 timestamp of when the customer was last updated ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/customers/cus_abc123xyz" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/customers/cus_abc123xyz', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/customers/cus_abc123xyz'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/customers/cus_abc123xyz', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json()['data'] ``` ```json Success (200) theme={null} { "data": { "id": "cus_abc123xyz", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "avatar_url": "https://cdn.chariow.com/avatars/abc123.jpg", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.chariow.link" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-20T14:45:00+00:00" } } ``` ```json Not Found (404) theme={null} { "message": "No query results for model [App\\Models\\Customer] cus_unknown", "errors": [] } ``` # List Customers Source: https://chariow.dev/api-reference/customers/list-customers GET /customers Retrieve all customers from your store Retrieves a cursor-paginated list of all customers in your store. Customers are created automatically when they make a purchase. This endpoint supports search filtering and date range filtering. **Required scopes:** `customers.read` and `customers.pii.read`. Granting `customers.pii.read` alone is enough, as it includes `customers.read`. A key without them receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Query Parameters Number of customers to return per page (1 to 100). A value above 100 returns a `422` validation error. Cursor for pagination. Use the `next_cursor` from the previous response. Search customers by first name, last name, email or phone number Only return customers created on or after this date (Y-m-d format, e.g., `2025-01-01`) Only return customers created on or before this date (Y-m-d format, e.g., `2025-01-31`). Must not be earlier than `from`. Shortcut for a date range, used instead of `from` and `to`: `today`, `yesterday`, `last7days`, `last30days`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear` or `lastYear` Customers are returned newest first. `start_date` and `end_date` are not supported and are silently ignored: use `from` and `to`. ## Response Array of customer objects Unique customer identifier (e.g., `cus_abc123xyz`) Customer full name (combination of first and last name) Customer first name Customer last name Customer email address URL to the customer's avatar image Customer phone number International formatted phone number (e.g., `+1 234 567 890`) Country information Country name ISO 3166-1 alpha-2 country code ISO 3166-1 alpha-3 country code Country dial code Country currency code Country flag emoji Store information Store public ID Store name Store logo URL Store URL ISO 8601 timestamp of when the customer was created ISO 8601 timestamp of when the customer was last updated Cursor pagination metadata Cursor for the next page (`null` if no more pages) Cursor for the previous page (`null` on the first page) Whether there are more pages available Number of items per page ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/customers?per_page=20&search=john" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/customers?per_page=20&search=john', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data, pagination } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/customers?per_page=20&search=john'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/customers', params={'per_page': 20, 'search': 'john'}, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json()['data'] ``` ```json Response theme={null} { "data": [ { "id": "cus_abc123xyz", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "avatar_url": "https://cdn.chariow.com/avatars/abc123.jpg", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.chariow.link" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-20T14:45:00+00:00" } ], "pagination": { "per_page": 20, "next_cursor": "eyJpZCI6NTB9", "prev_cursor": null, "has_more_pages": true } } ``` # Get Discount Source: https://chariow.dev/api-reference/discounts/get-discount GET /discounts/{discountPublicId} Retrieve details of a specific discount code Retrieves detailed information about a specific discount code by its public ID, including type, value, usage statistics, validity period, and associated products. **Required scope:** `discounts.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The unique discount identifier (e.g., `dis_abc123`) ## Response Unique discount identifier (e.g., `dis_abc123`) Display name of the discount The discount code customers use at checkout Discount type (`percentage` or `fixed`) Discount status (`active` or `expired`) Discount value information Raw discount value (percentage number or amount in currency units) Human-readable formatted value (e.g., `20%` or `$10.00`) Products this discount applies to (empty if it applies to all products) Product public ID Product name Product type `thumbnail` and `cover` image URLs (each `null` when not set) Category `value` and `label` Pricing `type`, `price` and `effective` amounts, in the product currency Bundle value and savings, or `null` unless the product is a bundle Custom metadata set on the product Store information: `id`, `name`, `logo_url` and `url` Email of the customer this discount is restricted to (`null` if no restriction) Maximum number of uses in total (`null` if unlimited) Maximum number of uses per customer (`null` if unlimited) Number of times the discount has been used ISO 8601 timestamp when the discount becomes active (`null` if no start restriction) ISO 8601 timestamp when the discount expires (`null` if no expiration) Whether the discount was automatically generated by the system ISO 8601 timestamp when the discount was created ISO 8601 timestamp when the discount was last updated ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/discounts/dis_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/discounts/dis_abc123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/discounts/dis_abc123'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $result = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/discounts/dis_abc123', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) discount = response.json()['data'] ``` ```json Response theme={null} { "data": { "id": "dis_abc123", "name": "Summer Sale", "code": "SUMMER20", "type": "percentage", "status": "active", "value_off": { "raw": 20, "formatted": "20%" }, "products": [ { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/thumb.jpg", "cover": "https://cdn.chariow.com/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "store_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "customer_email": null, "usage_limit": 100, "usage_limit_per_customer": 1, "usage_count": 15, "start_date": "2025-01-01T00:00:00+00:00", "end_date": "2025-12-31T23:59:59+00:00", "is_auto_generated": false, "created_at": "2025-01-01T00:00:00+00:00", "updated_at": "2025-01-15T10:30:00+00:00" } } ``` ```json Not Found (404) theme={null} { "message": "No query results for model [App\\Models\\Discount].", "errors": [] } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` # List Discounts Source: https://chariow.dev/api-reference/discounts/list-discounts GET /discounts Retrieve all discount codes from your store Retrieves a cursor-paginated list of all discount codes in your store, newest first, with optional filtering and search capabilities. **Required scope:** `discounts.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Query Parameters Number of discounts to return per page (max 100) Cursor for pagination. Use the `next_cursor` from the previous response. Filter by status (`active`, `expired`) Search by discount code, name, or public ID Only discounts created on or after this date (`Y-m-d`, e.g., `2025-01-01`). Send it together with `to`. Only discounts created on or before this date (`Y-m-d`, e.g., `2025-01-31`). Send it together with `from`. Preset creation date range, used instead of `from` and `to`: `today`, `yesterday`, `last7days`, `last30days`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear`, `lastYear` ## Response The list is returned at the top level of the body, without the `message` and `errors` fields used by error responses. Array of discount objects, newest first Unique discount identifier (e.g., `dis_abc123`) Display name of the discount The discount code customers use at checkout Discount type (`percentage` or `fixed`) Discount status (`active` or `expired`) Discount value information Raw discount value (percentage number or amount in currency units) Human-readable formatted value (e.g., `20%` or `$10.00`) Products this discount applies to (empty if it applies to all products) Product public ID Product name Product type `thumbnail` and `cover` image URLs (each `null` when not set) Category `value` and `label` Pricing `type`, `price` and `effective` amounts, in the product currency Bundle value and savings, or `null` unless the product is a bundle Custom metadata set on the product Store information: `id`, `name`, `logo_url` and `url` Email of the customer this discount is restricted to (`null` if no restriction) Maximum number of uses in total (`null` if unlimited) Maximum number of uses per customer (`null` if unlimited) Number of times the discount has been used ISO 8601 timestamp when the discount becomes active (`null` if no start restriction) ISO 8601 timestamp when the discount expires (`null` if no expiration) Whether the discount was automatically generated by the system ISO 8601 timestamp when the discount was created ISO 8601 timestamp when the discount was last updated Cursor pagination metadata Number of items on this page Base URL of the endpoint Page size used for this request Cursor for the next page, or `null` if there are no more pages Full URL of the next page, or `null` Cursor for the previous page, or `null` on the first page Full URL of the previous page, or `null` Whether there are more items to fetch Whether the results span more than one page ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/discounts?status=active&per_page=20" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/discounts?status=active&per_page=20', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data, pagination } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/discounts?status=active&per_page=20'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $result = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/discounts', params={'status': 'active', 'per_page': 20}, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) discounts = response.json()['data'] ``` ```json Response theme={null} { "data": [ { "id": "dis_abc123", "name": "Summer Sale", "code": "SUMMER20", "type": "percentage", "status": "active", "value_off": { "raw": 20, "formatted": "20%" }, "products": [ { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/thumb.jpg", "cover": "https://cdn.chariow.com/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "store_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "customer_email": null, "usage_limit": 100, "usage_limit_per_customer": 1, "usage_count": 15, "start_date": "2025-01-01T00:00:00+00:00", "end_date": "2025-12-31T23:59:59+00:00", "is_auto_generated": false, "created_at": "2025-01-01T00:00:00+00:00", "updated_at": "2025-01-15T10:30:00+00:00" }, { "id": "dis_def456abc", "name": "VIP Discount", "code": "VIP50", "type": "fixed", "status": "active", "value_off": { "raw": 50, "formatted": "$50.00" }, "products": [], "store": { "id": "store_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "customer_email": "vip@example.com", "usage_limit": 1, "usage_limit_per_customer": null, "usage_count": 0, "start_date": null, "end_date": null, "is_auto_generated": false, "created_at": "2025-01-10T08:00:00+00:00", "updated_at": "2025-01-10T08:00:00+00:00" } ], "pagination": { "count": 2, "path": "https://api.chariow.com/v1/discounts", "per_page": 20, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` # Errors Source: https://chariow.dev/api-reference/errors API error codes and handling The Chariow API uses conventional HTTP response codes to indicate success or failure. ## HTTP Status Codes | Code | Description | | - | - | | 200 | Success | | 201 | Created | | 400 | Bad Request | | 401 | Unauthorised: missing or invalid API key | | 403 | Forbidden: the API key lacks a required scope | | 404 | Not Found | | 422 | Validation Error | | 429 | Rate Limited | | 500 | Server Error | ## Error Response Format Every error response carries a `message` and an `errors` field. Some errors also include an empty `data` field. ```json theme={null} { "message": "Error description", "data": [], "errors": { "field_name": ["Validation error message"] } } ``` ## Common Errors ### Unauthorised (401) ```json theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` ### Missing Scope (403) Returned when the API key is valid but lacks a scope the endpoint requires. `errors.scopes` lists the missing scopes, and the `WWW-Authenticate` header repeats them: ```http theme={null} WWW-Authenticate: Bearer error="insufficient_scope", scope="licenses.write" ``` ```json theme={null} { "message": "This credential is missing the required scope: licenses.write. Update its permissions in your dashboard.", "data": [], "errors": { "scopes": ["licenses.write"] } } ``` See [Authentication](/api-reference/authentication#scopes) for the scope each endpoint requires. ### Validation Error (422) ```json theme={null} { "message": "The email field is required. (and 1 more error)", "data": [], "errors": { "email": ["The email field is required."], "product_id": ["The selected product_id is invalid."] } } ``` ### Not Found (404) ```json theme={null} { "message": "No query results for model [App\\Models\\Product].", "data": [], "errors": [] } ``` ### Rate Limited (429) ```json theme={null} { "message": "Too Many Attempts.", "errors": [] } ``` The response carries a `Retry-After` header with the number of seconds to wait. See [Rate Limits](/en/resources/rate-limits). # API Introduction Source: https://chariow.dev/api-reference/introduction Welcome to the Chariow API Reference The Chariow API is a RESTful API that allows you to programmatically interact with your store. You can use it to retrieve products, manage customers, process sales, validate licenses, and more. ## Base URL All API requests should be made to: ``` https://api.chariow.com/v1 ``` ## Authentication The API uses Bearer token authentication. Include your API key in the `Authorization` header: ```bash theme={null} Authorization: Bearer YOUR_API_KEY ``` Each API key carries scopes, and every endpoint requires at least one of them. A key without the required scope receives a `403` response that lists the missing scopes. See [Authentication](/api-reference/authentication#scopes) for the scope each endpoint requires. Generate API keys in your store dashboard ## Request Format * All requests should include `Content-Type: application/json` header for POST/PUT requests * Request bodies should be JSON encoded * Query parameters should be URL encoded ## Response Format * A single resource is wrapped in `data`: `{"data": {...}}`. * A list returns `data` (an array) and `pagination` at the top level. * An error returns `message` and `errors`. Validation (`422`), authentication (`401`), missing scope (`403`) and not found (`404`) errors also carry an empty `data` array. * `activate` and `revoke` on licences also return a `message` next to `data`. ### Pagination List endpoints use cursor-based pagination: ```json theme={null} { "data": [...], "pagination": { "count": 10, "path": "https://api.chariow.com/v1/products", "per_page": 10, "next_cursor": "eyJpZCI6NTB9", "next_page_url": "https://api.chariow.com/v1/products?cursor=eyJpZCI6NTB9", "prev_cursor": null, "prev_page_url": null, "has_more_pages": true, "has_pages": true } } ``` Use the `cursor` query parameter to navigate pages: ``` GET /v1/products?cursor=eyJpZCI6NTB9&per_page=20 ``` ## Available Endpoints Retrieve store information List and retrieve products Initiate checkout sessions Manage sales and orders Customer management License key management Discount code management Webhook notification pulses Retrieve affiliates and send invitations ## Rate Limits | Endpoint Type | Limit | | - | - | | All endpoints except checkout | 100/min per API key | | `POST /checkout` | 100/min per API key, counted separately | See [Rate Limits](/en/resources/rate-limits) for more details. ## Need Help? Step-by-step tutorials Get help from our team Join the community # Activate License Source: https://chariow.dev/api-reference/licenses/activate-license POST /licenses/{licenseKey}/activate Activate a license on a device Activates a license for a device by recording activation details and incrementing the activation count. The system automatically captures the requesting IP address and user agent. On the first activation, the license status changes from `pending_activation` to `active`, and the expiration date is calculated based on the product's validity period settings. Each activation is tracked individually, allowing you to view the complete activation history. The license cannot be activated if it has been revoked, has expired, or if the maximum activation limit has been reached. **Required scope:** `licenses.write`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The licence key to activate (e.g., `ABC-123-XYZ-789`) ## Request Body Optional unique identifier for the device (e.g., MAC address, hardware UUID, machine ID). Max 255 characters. The IP address and user agent are automatically captured from the request and do not need to be provided. ## Response `License activated successfully` Licence public ID (e.g., `license_abc123`) Licence status: `pending_activation`, `active`, `expired`, or `revoked` Customer who owns the licence: `id`, `name`, `first_name`, `last_name`, `email`, `phone` (`number` and `country`) and `avatar_url` Product that issued the licence: `id`, `name`, `type`, `pictures`, `category`, `pricing` (`type`, `price`, `effective`), `bundle` and `metadata` Full licence key (e.g., `ABC-123-XYZ-789`) Masked licence key for display Whether the licence is currently active and usable Whether the licence has expired Whether the licence can be activated on another device (not revoked, not expired, slots left) Current number of activations Maximum number of activations allowed Number of activations remaining Signed URL to download the licence certificate. It expires 30 minutes after the response: fetch the licence again for a fresh link. Custom metadata attached to the licence ISO 8601 timestamp of the first activation (`null` if not yet activated) ISO 8601 expiration timestamp (`null` for a lifetime licence) ISO 8601 timestamp when the licence expired ISO 8601 timestamp when the licence was revoked ISO 8601 creation timestamp ISO 8601 last update timestamp ## Error Responses Returned when: * The licence has been revoked * The licence is already active on a product whose licences need no activation * The licence has expired * The activation limit has been reached Returned when the licence key doesn't exist or doesn't belong to your store Returned when `device_identifier` is not a string or exceeds 255 characters ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activate" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "device_identifier": "00:1B:44:11:3A:B7" }' ``` ```javascript Node.js theme={null} const response = await fetch( 'https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activate', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ device_identifier: '00:1B:44:11:3A:B7' }) } ); const data = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activate'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'device_identifier' => '00:1B:44:11:3A:B7' ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); ``` ```json Success (200) theme={null} { "message": "License activated successfully", "data": { "id": "license_abc123", "status": "active", "customer": { "id": "cus_xyz789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": { "number": "+1 202-555-0123", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } }, "avatar_url": null }, "product": { "id": "prd_abc456", "name": "Premium Software License", "type": "license", "pictures": { "thumbnail": null, "cover": null }, "category": { "value": "technology", "label": "Technology" }, "pricing": { "type": "one_time", "price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "effective": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" } }, "bundle": null, "metadata": null }, "license": { "key": "ABC-123-XYZ-789", "masked_key": "ABC-***-***-789" }, "is_active": true, "is_expired": false, "can_activate": true, "activations": { "count": 1, "max": 10, "remaining": 9 }, "certificate_url": "https://download.chariow.com/licenses/license_abc123?expires=1736937000&signature=4f1c...", "metadata": null, "activated_at": "2025-01-15T10:30:00.000000Z", "expires_at": "2026-01-15T10:30:00.000000Z", "expired_at": null, "revoked_at": null, "created_at": "2025-01-15T09:00:00.000000Z", "updated_at": "2025-01-15T10:30:00.000000Z" } } ``` ```json License Revoked (400) theme={null} { "message": "License has been revoked", "errors": [] } ``` ```json Activation Not Required (400) theme={null} { "message": "This license does not require activation and is already active.", "errors": [] } ``` ```json License Expired (400) theme={null} { "message": "License has expired", "errors": [] } ``` ```json Activation Limit Reached (400) theme={null} { "message": "Activation limit reached", "errors": [] } ``` ```json License Not Found (404) theme={null} { "message": "No query results for model [App\\Models\\IssuedLicense].", "errors": [] } ``` ## Implementation Notes ### First Activation When a licence is activated for the first time: * Status changes from `pending_activation` to `active` * `activated_at` is set to the current timestamp * `expires_at` is calculated based on the product's validity period (if configured) ### Subsequent Activations * `activations.count` is incremented * A new activation record is created in the activation history * The licence status remains `active`, and `activated_at` and `expires_at` keep their first values ### Licences That Need No Activation When the product's licence settings have `requires_activation` set to `false`, licences are issued already active. Calling this endpoint on such a licence returns `400`; validate it with [Get License](/api-reference/licenses/get-license) instead. See [Licences that need no activation](/en/guides/licenses#licences-that-need-no-activation). ### Device Tracking Each activation is recorded with: * the `device_identifier` you send (optional) * the IP address of the request, with its country * the parsed user agent of the request * the activation timestamp You can retrieve the full activation history using the [Get License Activations](/api-reference/licenses/get-activations) endpoint. ## Example: Desktop Application ```javascript theme={null} class LicenseActivator { constructor(apiKey) { this.apiKey = apiKey; this.baseUrl = 'https://api.chariow.com/v1'; } async activate(licenseKey) { // Get unique device identifier const deviceId = this.getDeviceIdentifier(); try { const response = await fetch( `${this.baseUrl}/licenses/${licenseKey}/activate`, { method: 'POST', headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ device_identifier: deviceId }) } ); if (!response.ok) { const error = await response.json(); throw new Error(error.message); } const result = await response.json(); console.log('License activated successfully'); console.log(`Activations remaining: ${result.data.activations.remaining}`); return result.data; } catch (error) { console.error('Activation failed:', error.message); throw error; } } getDeviceIdentifier() { // Implementation depends on your platform // Examples: MAC address, hardware UUID, machine ID return 'unique-device-id-here'; } } // Usage const activator = new LicenseActivator('sk_live_your_api_key'); await activator.activate('ABC-123-XYZ-789'); ``` # Get License Activations Source: https://chariow.dev/api-reference/licenses/get-activations GET /licenses/{licenseKey}/activations Retrieve activation history for a license Fetches a cursor-paginated list of all activation records for a specific license, ordered by most recent first. Each activation record contains detailed information about when and where the license was activated, including IP address, user agent, device identifier, and timestamp. This endpoint is useful for auditing license usage, tracking device activations, and debugging activation-related issues. The response includes pagination metadata; the activation totals are on the licence itself. **Required scope:** `licenses.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The licence key to retrieve activations for (e.g., `ABC-123-XYZ-789`) ## Query Parameters Number of activation records to return per page (max 100) Cursor for pagination. Use the `next_cursor` from the previous response. ## Response The list is returned at the top level of the body, without the `message` and `errors` fields used by error responses. Array of activation records, most recent first Activation public ID Who activated the licence `value` is the IP address of the activation request. `country` holds its `name`, `code`, `alpha_3_code`, `dial_code`, `currency` and `flag`, or is `null` when the IP cannot be located. Parsed user agent: `browser`, `version`, `platform`, `device`, and the booleans `is_desktop`, `is_mobile`, `is_phone`, `is_tablet`, `is_robot`, `is_ios` and `is_android`. `null` when the request sent no user agent. The `device_identifier` sent on activation, if any Additional metadata attached to the activation ISO 8601 timestamp of the activation ISO 8601 timestamp when the record was created Cursor pagination metadata Number of items on this page Base URL of the endpoint Page size used for this request Cursor for the next page, or `null` if there are no more pages Full URL of the next page, or `null` Cursor for the previous page, or `null` on the first page Full URL of the previous page, or `null` Whether there are more items to fetch Whether the results span more than one page The activation totals live on the licence itself: read `activations.count`, `activations.max` and `activations.remaining` from [Get License](/api-reference/licenses/get-license). ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activations?per_page=20" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch( 'https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activations?per_page=20', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const { data, pagination } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activations?per_page=20'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); ``` ```json Response theme={null} { "data": [ { "id": "V1StGXR8Z5jd", "activated_by": { "ip": { "value": "203.0.113.45", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } }, "user_agent": { "is_desktop": true, "is_robot": false, "platform": "OS X", "browser": "Chrome", "version": "120.0.0.0", "device": "Macintosh", "is_mobile": false, "is_phone": false, "is_tablet": false, "is_ios": false, "is_android": false }, "device": "00:1B:44:11:3A:B7" }, "metadata": null, "activated_at": "2025-01-18T15:42:00.000000Z", "created_at": "2025-01-18T15:42:00.000000Z" }, { "id": "Uakgb2KQ9xLm", "activated_by": { "ip": { "value": "198.51.100.12", "country": null }, "user_agent": null, "device": null }, "metadata": null, "activated_at": "2025-01-16T09:15:00.000000Z", "created_at": "2025-01-16T09:15:00.000000Z" } ], "pagination": { "count": 2, "path": "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activations", "per_page": 20, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ```json License Not Found (404) theme={null} { "message": "License key not found.", "errors": [] } ``` ## Use Cases ### Audit Trail Track all devices that have activated a licence: ```javascript theme={null} async function getActivationHistory(licenseKey) { const response = await fetch( `https://api.chariow.com/v1/licenses/${licenseKey}/activations`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const { data } = await response.json(); data.forEach(activation => { console.log(`Device: ${activation.activated_by.device}`); console.log(`IP: ${activation.activated_by.ip.value}`); console.log(`Date: ${activation.activated_at}`); }); return data; } ``` ### Device Management Display activation history to customers: ```javascript theme={null} async function showCustomerActivations(licenseKey) { const response = await fetch( `https://api.chariow.com/v1/licenses/${licenseKey}/activations`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const { data } = await response.json(); return data.map(a => ({ name: a.activated_by.device || 'Unknown Device', ip: a.activated_by.ip.value, country: a.activated_by.ip.country?.name, activatedAt: new Date(a.activated_at).toLocaleDateString() })); } ``` ### Fraud Detection Identify suspicious activation patterns: ```javascript theme={null} async function detectSuspiciousActivity(licenseKey) { const response = await fetch( `https://api.chariow.com/v1/licenses/${licenseKey}/activations?per_page=100`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const { data } = await response.json(); // Check for activations from many different IP addresses const uniqueIPs = new Set(data.map(a => a.activated_by.ip.value)); if (uniqueIPs.size > 5) { console.warn('Suspicious: License activated from multiple IP addresses'); } return { suspicious: uniqueIPs.size > 5, uniqueLocations: uniqueIPs.size, activations: data }; } ``` ## Pagination This endpoint uses cursor-based pagination for efficient traversal of large activation lists: ```javascript theme={null} async function getAllActivations(licenseKey) { let allActivations = []; let cursor = null; do { const url = cursor ? `https://api.chariow.com/v1/licenses/${licenseKey}/activations?cursor=${cursor}` : `https://api.chariow.com/v1/licenses/${licenseKey}/activations`; const response = await fetch(url, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const { data, pagination } = await response.json(); allActivations = [...allActivations, ...data]; cursor = pagination.next_cursor; } while (cursor); return allActivations; } ``` ## Notes * Activations are ordered by most recent first (`activated_at`, then creation order) * Each activation is immutable and cannot be modified * Activation records persist even after a licence is revoked * `activated_by.device` is `null` if no `device_identifier` was sent during activation * IP addresses and user agents are automatically captured during activation # Get License Source: https://chariow.dev/api-reference/licenses/get-license GET /licenses/{licenseKey} Retrieve details of a specific license Retrieves detailed information about a specific license by its license key or public ID. This endpoint returns comprehensive license information including activation status, usage counts, expiration dates, and the associated customer and product. **Required scope:** `licenses.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The licence key (e.g., `ABC-123-XYZ-789`). The licence public ID (e.g., `license_abc123`) is also accepted. ## Response Licence public ID (e.g., `license_abc123`) Licence status: `pending_activation`, `active`, `expired`, or `revoked` Customer who owns the licence: `id`, `name`, `first_name`, `last_name`, `email`, `phone` (`number` and `country`) and `avatar_url` Product that issued the licence: `id`, `name`, `type`, `pictures`, `category`, `pricing` (`type`, `price`, `effective`), `bundle` and `metadata` Full licence key (e.g., `ABC-123-XYZ-789`) Masked licence key for display Whether the licence is currently active and usable Whether the licence has expired Whether the licence can be activated on another device (not revoked, not expired, slots left) Current number of activations Maximum number of activations allowed Number of activations remaining Signed URL to download the licence certificate. It expires 30 minutes after the response: fetch the licence again for a fresh link. Custom metadata attached to the licence ISO 8601 timestamp of the first activation (`null` if not yet activated) ISO 8601 expiration timestamp (`null` for a lifetime licence) ISO 8601 timestamp when the licence expired ISO 8601 timestamp when the licence was revoked ISO 8601 creation timestamp ISO 8601 last update timestamp ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const { data } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); ``` ```json Response theme={null} { "data": { "id": "license_abc123", "status": "active", "customer": { "id": "cus_xyz789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": { "number": "+1 202-555-0123", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } }, "avatar_url": null }, "product": { "id": "prd_abc456", "name": "Premium Software License", "type": "license", "pictures": { "thumbnail": null, "cover": null }, "category": { "value": "technology", "label": "Technology" }, "pricing": { "type": "one_time", "price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "effective": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" } }, "bundle": null, "metadata": null }, "license": { "key": "ABC-123-XYZ-789", "masked_key": "ABC-***-***-789" }, "is_active": true, "is_expired": false, "can_activate": true, "activations": { "count": 3, "max": 10, "remaining": 7 }, "certificate_url": "https://download.chariow.com/licenses/license_abc123?expires=1736937000&signature=4f1c...", "metadata": null, "activated_at": "2025-01-15T10:30:00.000000Z", "expires_at": "2026-01-15T10:30:00.000000Z", "expired_at": null, "revoked_at": null, "created_at": "2025-01-15T09:00:00.000000Z", "updated_at": "2025-01-15T10:30:00.000000Z" } } ``` ```json License Not Found (404) theme={null} { "message": "License key not found.", "errors": [] } ``` # List Licenses Source: https://chariow.dev/api-reference/licenses/list-licenses GET /licenses Retrieve all licenses from your store Retrieves a cursor-paginated list of all licenses in your store. Licenses are automatically generated when customers purchase license-based products. This endpoint supports filtering by status and product, and searching by licence key. **Required scope:** `licenses.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Query Parameters Number of licences to return per page (max 100) Cursor for pagination. Use the `next_cursor` from the previous response. Filter by licence status. Valid values: `pending_activation`, `active`, `expired`, `revoked` Filter by product public ID (e.g., `prd_def456`) Search by licence key There is no customer filter: use [Get Customer](/api-reference/customers/get-customer) to find a customer, then filter the licences on `customer.id` on your side. ## Response The list is returned at the top level of the body, without the `message` and `errors` fields used by error responses. Array of licence objects, newest first Licence public ID (e.g., `license_abc123`) Licence status: `pending_activation`, `active`, `expired`, or `revoked` Customer who owns the licence: `id`, `name`, `first_name`, `last_name`, `email`, `phone` (`number` and `country`) and `avatar_url` Product that issued the licence: `id`, `name`, `type`, `pictures`, `category`, `pricing` (`type`, `price`, `effective`), `bundle` and `metadata` Full licence key (e.g., `ABC-123-XYZ-789`) Masked licence key for display Whether the licence is currently active and usable Whether the licence has expired Whether the licence can be activated on another device (not revoked, not expired, slots left) Current number of activations Maximum number of activations allowed Number of activations remaining Signed URL to download the licence certificate. It expires 30 minutes after the response: fetch the licence again for a fresh link. Custom metadata attached to the licence ISO 8601 timestamp of the first activation (`null` if not yet activated) ISO 8601 expiration timestamp (`null` for a lifetime licence) ISO 8601 timestamp when the licence expired ISO 8601 timestamp when the licence was revoked ISO 8601 creation timestamp ISO 8601 last update timestamp Cursor pagination metadata Number of items on this page Base URL of the endpoint Page size used for this request Cursor for the next page, or `null` if there are no more pages Full URL of the next page, or `null` Cursor for the previous page, or `null` on the first page Full URL of the previous page, or `null` Whether there are more items to fetch Whether the results span more than one page ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/licenses?status=active&per_page=20" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/licenses?status=active&per_page=20', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const { data, pagination } = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/licenses?status=active&per_page=20'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); ``` ```json Response theme={null} { "data": [ { "id": "license_abc123", "status": "active", "customer": { "id": "cus_xyz789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": { "number": "+1 202-555-0123", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } }, "avatar_url": null }, "product": { "id": "prd_abc456", "name": "Premium Software License", "type": "license", "pictures": { "thumbnail": null, "cover": null }, "category": { "value": "technology", "label": "Technology" }, "pricing": { "type": "one_time", "price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "effective": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" } }, "bundle": null, "metadata": null }, "license": { "key": "ABC-123-XYZ-789", "masked_key": "ABC-***-***-789" }, "is_active": true, "is_expired": false, "can_activate": true, "activations": { "count": 3, "max": 10, "remaining": 7 }, "certificate_url": "https://download.chariow.com/licenses/license_abc123?expires=1736937000&signature=4f1c...", "metadata": null, "activated_at": "2025-01-15T10:30:00.000000Z", "expires_at": "2026-01-15T10:30:00.000000Z", "expired_at": null, "revoked_at": null, "created_at": "2025-01-15T09:00:00.000000Z", "updated_at": "2025-01-15T10:30:00.000000Z" } ], "pagination": { "count": 1, "path": "https://api.chariow.com/v1/licenses", "per_page": 20, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` # Revoke License Source: https://chariow.dev/api-reference/licenses/revoke-license POST /licenses/{licenseKey}/revoke Permanently revoke a license Permanently revokes a license by changing its status to `revoked` and recording the revocation timestamp. Once revoked, the license cannot be activated on any device, and this action cannot be undone. The license will remain visible in reports and history for audit purposes. This endpoint is useful for handling customer refunds, policy violations, or when a license needs to be immediately terminated for any reason. Revoking a license is **permanent and irreversible**. The license cannot be reactivated after revocation. **Required scope:** `licenses.write`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The license key to revoke (e.g., `ABC-123-XYZ-789`) ## Request Body Optional reason for revocation. Max 500 characters. It is validated but not stored: it is not returned by the API or included in the `license.revoked` Pulse event, so keep your own record if you need one. ## Response `License revoked successfully` Licence public ID (e.g., `license_abc123`) Licence status: `pending_activation`, `active`, `expired`, or `revoked` Customer who owns the licence: `id`, `name`, `first_name`, `last_name`, `email`, `phone` (`number` and `country`) and `avatar_url` Product that issued the licence: `id`, `name`, `type`, `pictures`, `category`, `pricing` (`type`, `price`, `effective`), `bundle` and `metadata` Full licence key (e.g., `ABC-123-XYZ-789`) Masked licence key for display Whether the licence is currently active and usable Whether the licence has expired Whether the licence can be activated on another device (not revoked, not expired, slots left) Current number of activations Maximum number of activations allowed Number of activations remaining Signed URL to download the licence certificate. It expires 30 minutes after the response: fetch the licence again for a fresh link. Custom metadata attached to the licence ISO 8601 timestamp of the first activation (`null` if not yet activated) ISO 8601 expiration timestamp (`null` for a lifetime licence) ISO 8601 timestamp when the licence expired ISO 8601 timestamp when the licence was revoked ISO 8601 creation timestamp ISO 8601 last update timestamp ## Error Responses Returned when the licence has already been revoked Returned when the licence key doesn't exist or doesn't belong to your store Returned when validation fails (e.g., reason exceeds 500 characters) ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/revoke" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "reason": "Customer requested refund" }' ``` ```javascript Node.js theme={null} const response = await fetch( 'https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/revoke', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ reason: 'Customer requested refund' }) } ); const data = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/revoke'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'reason' => 'Customer requested refund' ])); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); ``` ```json Success (200) theme={null} { "message": "License revoked successfully", "data": { "id": "license_abc123", "status": "revoked", "customer": { "id": "cus_xyz789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": { "number": "+1 202-555-0123", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } }, "avatar_url": null }, "product": { "id": "prd_abc456", "name": "Premium Software License", "type": "license", "pictures": { "thumbnail": null, "cover": null }, "category": { "value": "technology", "label": "Technology" }, "pricing": { "type": "one_time", "price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "effective": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" } }, "bundle": null, "metadata": null }, "license": { "key": "ABC-123-XYZ-789", "masked_key": "ABC-***-***-789" }, "is_active": false, "is_expired": false, "can_activate": false, "activations": { "count": 3, "max": 10, "remaining": 7 }, "certificate_url": "https://download.chariow.com/licenses/license_abc123?expires=1736937000&signature=4f1c...", "metadata": null, "activated_at": "2025-01-15T10:30:00.000000Z", "expires_at": "2026-01-15T10:30:00.000000Z", "expired_at": null, "revoked_at": "2025-01-20T14:22:00.000000Z", "created_at": "2025-01-15T09:00:00.000000Z", "updated_at": "2025-01-20T14:22:00.000000Z" } } ``` ```json Already Revoked (400) theme={null} { "message": "License has already been revoked", "errors": [] } ``` ```json Validation Error (422) theme={null} { "message": "The reason must not exceed 500 characters", "data": [], "errors": { "reason": ["The reason must not exceed 500 characters"] } } ``` ```json License Not Found (404) theme={null} { "message": "No query results for model [App\\Models\\IssuedLicense].", "errors": [] } ``` ## Common Use Cases ### Refund Processing When processing a refund, revoke the license to prevent further use: ```javascript theme={null} async function processRefund(licenseKey) { await fetch(`https://api.chariow.com/v1/licenses/${licenseKey}/revoke`, { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ reason: 'Full refund processed via payment gateway' }) }); } ``` ### Terms of Service Violation Revoke licenses that violate your terms: ```javascript theme={null} async function revokeViolation(licenseKey, violationType) { await fetch(`https://api.chariow.com/v1/licenses/${licenseKey}/revoke`, { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ reason: `Terms of service violation: ${violationType}` }) }); } ``` ### Fraudulent Purchase Immediately revoke licenses from suspected fraudulent purchases: ```javascript theme={null} async function revokeFraudulent(licenseKey) { await fetch(`https://api.chariow.com/v1/licenses/${licenseKey}/revoke`, { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ reason: 'Suspected fraudulent purchase - payment flagged by gateway' }) }); } ``` ## What Happens After Revocation Once a license is revoked: 1. **Status Change**: The license status becomes `revoked` 2. **Timestamp**: The `revoked_at` field is set to the current timestamp 3. **No Future Activations**: The license cannot be activated on any device 4. **Existing Activations**: Any existing activations remain in the system for audit purposes 5. **Permanent**: The revocation **cannot be undone** - you must issue a new license if needed 6. **Visible in Reports**: The license remains visible in your dashboard and API responses for historical tracking ## Alternative: Deactivating Individual Devices If you want to free up an activation slot without permanently revoking the entire license, you should instead remove specific activations. This can be done through your store dashboard, allowing the license to be activated on a different device. There is currently no Public API endpoint for deactivating individual device activations. This must be done through the store dashboard or Core API. # Get Product Source: https://chariow.dev/api-reference/products/get-product GET /products/{productId} Retrieve detailed information about a specific product Retrieves comprehensive information about a specific product by its public ID or slug, whatever its status (published, draft or suspended). This endpoint returns detailed pricing information, images, ratings, sales count, stock, and bundle or coaching information (if applicable). **Required scope:** `products.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The unique product identifier or slug (e.g., `prd_abc123` or `premium-course`) ## Response Unique product identifier (e.g., `prd_abc123`) Product name, as plain text URL-friendly product identifier Product description as HTML, sanitised by Chariow to strip unsafe markup such as scripts Product type: `downloadable`, `service`, `course`, `license`, `bundle`, or `coaching` Category value Human-readable category label Publication status: `published`, `draft`, or `suspended`. The API returns products whatever their status. Whether the product is free Thumbnail image URL Cover image URL Pricing type: `free`, `one_time`, or `what_you_want` Price a buyer pays now (the sale price while a sale is active) Numeric amount Formatted amount with currency symbol (e.g., `$99.00`) Abbreviated amount (e.g., `99`, `5K`, `1.25M`) ISO 4217 currency code Regular price (same structure as `current_price`) Effective price (same structure as `current_price`) Sale price while a sale is active, otherwise `null` (same structure as `current_price`) Minimum price for pay-what-you-want products (same structure as `current_price`) Suggested price for pay-what-you-want products (same structure as `current_price`) Sale discount as a percentage string (e.g., `34%`), or `null` when no sale is active Current price converted to USD for ad trackers such as the Meta Pixel, whatever the display currency `USD`, or the product currency when no conversion rate is available Amount rounded to two decimals Whether the product has price variants Exact stock of a limited-quantity product, or `null` when the quantity is unlimited Total stock Remaining quantity Remaining share, as a whole number from 0 to 100 Sold quantity Sold share, as a whole number from 0 to 100 Total stock (same as `value`) Whether the buyer must provide a shipping address Buyer ratings (thumbs up or down) Number of ratings Exact number Formatted number (e.g., `1,250`) Abbreviated number (e.g., `1K`) Abbreviated number with a plus sign (e.g., `1K+`) Number of positive ratings Share of positive ratings (e.g., `96%`) Sale end date (ISO 8601) Exact number of successful sales, or `null` when the product hides its sales count. New products hide it by default; turn it on in the product settings. Exact number Formatted number (e.g., `1,250`) Abbreviated number (e.g., `1K`) Abbreviated number with a plus sign (e.g., `1K+`) Not loaded by the public API: always `null` Custom call-to-action text CTA value CTA label Not loaded by the public API: always `null` Not loaded by the public API: always `null`. Use [Get Store](/api-reference/store/get-store) instead. Bundle value and savings, or `null` unless the product is a bundle Total value of the bundled products bought separately (amount object) Amount saved (amount object) Share saved, as `{ "value": 33, "formatted": "33%" }` Coaching settings, or `null` unless the product is a coaching product Session duration: `value` in minutes (`15`, `30`, `45`, `60`, `90` or `120`) and a `label` Where the session takes place: `value` is `video_conference`, `in_person` or `custom_link`, with a `label` Time zone of the coach's availability Break between two sessions: `value` in minutes (`5`, `15`, `30` or `60`) and a `label` ## Error Responses Returned when no product of your store has this public ID or slug ```bash cURL (by ID) theme={null} curl -X GET "https://api.chariow.com/v1/products/prd_abc123" \ -H "Authorization: Bearer sk_live_YOUR_API_KEY" ``` ```bash cURL (by slug) theme={null} curl -X GET "https://api.chariow.com/v1/products/premium-course" \ -H "Authorization: Bearer sk_live_YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/products/prd_abc123', { headers: { 'Authorization': 'Bearer sk_live_YOUR_API_KEY' } }); const { data } = await response.json(); console.log(data); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/products/prd_abc123'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/products/prd_abc123', headers={'Authorization': 'Bearer sk_live_YOUR_API_KEY'} ) data = response.json() ``` ```json Success Response (200) theme={null} { "data": { "id": "prd_abc123", "name": "Premium Web Development Course", "slug": "premium-web-dev-course", "description": "

A comprehensive course covering advanced web development techniques and best practices.

", "type": "course", "category": { "value": "education_and_learning", "label": "Education and Learning" }, "status": "published", "is_free": false, "pictures": { "thumbnail": "https://cdn.chariow.com/products/abc123/thumb.jpg", "cover": "https://cdn.chariow.com/products/abc123/cover.jpg" }, "pricing": { "type": "one_time", "current_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "price": { "value": 149, "formatted": "$149.00", "short": "149", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "sale_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": "34%", "tracking": { "currency": "USD", "value": 99 } }, "has_variant_pricing": false, "quantity": null, "settings": { "is_shipping_address_required": false }, "rating": { "total_ratings": { "value": 245, "formatted": "245", "short": "245", "short_plus": "245+" }, "thumbs_up_count": 236, "thumbs_up_percentage": "96%" }, "on_sale_until": "2025-02-28T23:59:59.000000Z", "sales_count": { "value": 1250, "formatted": "1,250", "short": "1K", "short_plus": "1K+" }, "seo": null, "custom_cta_text": { "value": null, "label": null }, "fields": null, "store": null, "bundle": null, "coaching": null } } ``` ```json Bundle Product Response theme={null} { "data": { "id": "prd_bundle789", "name": "Complete Developer Bundle", "slug": "developer-bundle", "description": "

Everything you need to become a professional developer.

", "type": "bundle", "category": { "value": "technology", "label": "Technology" }, "status": "published", "is_free": false, "pictures": { "thumbnail": "https://cdn.chariow.com/products/bundle789/thumb.jpg", "cover": null }, "pricing": { "type": "one_time", "current_price": { "value": 199, "formatted": "$199.00", "short": "199", "currency": "USD" }, "price": { "value": 199, "formatted": "$199.00", "short": "199", "currency": "USD" }, "effective": { "value": 199, "formatted": "$199.00", "short": "199", "currency": "USD" }, "sale_price": null, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": null, "tracking": { "currency": "USD", "value": 199 } }, "has_variant_pricing": false, "quantity": { "value": 100, "remaining": { "value": 35, "percent": 35 }, "sold": { "value": 65, "percent": 65 }, "total": 100 }, "settings": { "is_shipping_address_required": false }, "rating": { "total_ratings": { "value": 89, "formatted": "89", "short": "89", "short_plus": "89+" }, "thumbs_up_count": 87, "thumbs_up_percentage": "98%" }, "on_sale_until": null, "sales_count": null, "seo": null, "custom_cta_text": { "value": null, "label": null }, "fields": null, "store": null, "bundle": { "value": { "value": 297, "formatted": "$297.00", "short": "297", "currency": "USD" }, "savings": { "amount": { "value": 98, "formatted": "$98.00", "short": "98", "currency": "USD" }, "percentage": { "value": 33, "formatted": "33%" } } }, "coaching": null } } ``` ```json Not Found (404) theme={null} { "message": "No query results for model [App\\Models\\Product].", "errors": [] } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ```
# List Products Source: https://chariow.dev/api-reference/products/list-products GET /products Retrieve the products of your store Retrieves a cursor-paginated list of the products in your store, newest first. Products are returned whatever their status (`published`, `draft` or `suspended`): check `status` before showing a product to buyers. Supports optional filtering by category, type, or search term. **Required scope:** `products.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Query Parameters Number of products to return per page (maximum 100) Cursor for pagination. Use the `next_cursor` from the previous response to fetch the next page. Search products by public ID, name, slug, category or type Filter by product category. Available values: `creative_arts`, `technology`, `business_and_finance`, `personal_development`, `education_and_learning`, `entertainment`, `health_and_wellness`, `literature_and_publishing`, `media_and_communication`, `miscellaneous` Filter by product type. Available values: `downloadable`, `service`, `course`, `license`, `bundle`, `coaching` ## Response The list is returned at the top level of the body, without the `message` and `errors` fields used by error responses. Array of product objects, newest first. Each product has the same fields as the [Get Product](/api-reference/products/get-product) response, including `status`, `sales_count` and `quantity`. Cursor pagination metadata Number of items on this page Base URL of the endpoint Page size used for this request Cursor for the next page, or `null` if there are no more pages Full URL of the next page, or `null` Cursor for the previous page, or `null` on the first page Full URL of the previous page, or `null` Whether there are more items to fetch Whether the results span more than one page ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/products?per_page=20&type=course" \ -H "Authorization: Bearer sk_live_YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/products?per_page=20&type=course', { headers: { 'Authorization': 'Bearer sk_live_YOUR_API_KEY' } }); const { data, pagination } = await response.json(); const published = data.filter(product => product.status === 'published'); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/products?per_page=20&type=course'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/products', params={'per_page': 20, 'type': 'course'}, headers={'Authorization': 'Bearer sk_live_YOUR_API_KEY'} ) data = response.json() ``` ```json Success Response (200) theme={null} { "data": [ { "id": "prd_abc123", "name": "Premium Web Development Course", "slug": "premium-web-dev-course", "description": "

A comprehensive course covering advanced web development techniques and best practices.

", "type": "course", "category": { "value": "education_and_learning", "label": "Education and Learning" }, "status": "published", "is_free": false, "pictures": { "thumbnail": "https://cdn.chariow.com/products/abc123/thumb.jpg", "cover": "https://cdn.chariow.com/products/abc123/cover.jpg" }, "pricing": { "type": "one_time", "current_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "price": { "value": 149, "formatted": "$149.00", "short": "149", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "sale_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": "34%", "tracking": { "currency": "USD", "value": 99 } }, "has_variant_pricing": false, "quantity": null, "settings": { "is_shipping_address_required": false }, "rating": { "total_ratings": { "value": 245, "formatted": "245", "short": "245", "short_plus": "245+" }, "thumbs_up_count": 236, "thumbs_up_percentage": "96%" }, "on_sale_until": "2025-02-28T23:59:59.000000Z", "sales_count": { "value": 1250, "formatted": "1,250", "short": "1K", "short_plus": "1K+" }, "seo": null, "custom_cta_text": { "value": null, "label": null }, "fields": null, "store": null, "bundle": null, "coaching": null } ], "pagination": { "count": 1, "path": "https://api.chariow.com/v1/products", "per_page": 20, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ```
# Get Pulse Source: https://chariow.dev/api-reference/pulses/get-pulse GET /pulses/{pulsePublicId} Retrieve details of a specific webhook notification pulse Retrieves detailed information about a specific pulse webhook by its public ID, including configured triggers, associated products, source information, and current status. Requires an API key with the `webhooks.read` scope (`webhooks.write` includes it). A key without it receives a `403` listing the missing scope. **Required scope:** `webhooks.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The unique pulse identifier (e.g., `pulse_abc123xyz789`) ## Response Unique pulse identifier (e.g., `pulse_abc123xyz789`) Webhook URL where notifications are sent Whether the pulse is currently active. Chariow sets it to `false` automatically when a delivery fails all 5 attempts. Masked form of the pulse signing secret, e.g. `whsec_β€’β€’β€’β€’a1b2`. The full secret is never returned by the public API; reveal it from the dashboard. See [Pulse Security](/en/guides/pulse-security). How the pulse was created Source value: `manual`, `zapier`, `make` or `n8n` Human-readable source label Description of the source Array of trigger event objects that will activate this pulse Trigger event value (e.g., `successful_sale`, `license_activated`, `affiliate_joined`, `all`) Human-readable label Description of when this trigger fires Products this pulse is limited to, sorted by creation order. An empty array means every product triggers this pulse. The filter only applies to sale and licence events: `affiliate.joined` reaches the pulse regardless. Product identifier Product name Product type (e.g., `course`, `license`, `downloadable`) `thumbnail` and `cover` image URLs Product category, with `value` and `label` `type`, plus `price` and `effective` amount objects (`value`, `formatted`, `short`, `currency`) Bundle value and savings, or `null` when the product is not a bundle Custom metadata attached to the product Store information Store identifier Store name Store logo URL Store URL `true` for pulses created manually. Pulses created by an integration (Zapier, Make, n8n) are managed by that integration and cannot be edited or deleted from Chariow. ISO 8601 timestamp ISO 8601 timestamp ## Available Trigger Events Pulses can be configured to trigger on the following events: ### Sale Events | Value | Label | Description | | - | - | - | | `successful_sale` | Successful Sale | Triggers when a sale is successful. | | `abandoned_sale` | Abandoned Sale | Triggers when a sale is abandoned. | | `failed_sale` | Failed Sale | Triggers when a sale fails. | ### License Events | Value | Label | Description | | - | - | - | | `license_activated` | License Activated | Triggers when a license is activated. | | `license_expired` | License Expired | Triggers when a license expires. | | `license_issued` | License Issued | Triggers when a license is issued to a customer. | | `license_nearing_expiry` | License Nearing Expiry | Triggers when a license is approaching its expiry date. | | `license_revoked` | License Revoked | Triggers when a license is revoked. | ### Affiliate Events | Value | Label | Description | | - | - | - | | `affiliate_joined` | Affiliate Joined | Triggers when an affiliate joins the store. | ### Special Events | Value | Label | Description | | - | - | - | | `all` | All Events | Triggers for all events. | Trigger values use underscores (`successful_sale`). The `event` field of the webhook payload and the `x-pulse-event` header use dots (`successful.sale`). See [Pulse Events](/en/guides/pulses#pulse-events). ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/pulses/pulse_abc123xyz789" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/pulses/pulse_abc123xyz789', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const data = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/pulses/pulse_abc123xyz789'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```json Response theme={null} { "data": { "id": "pulse_abc123xyz789", "url": "https://example.com/webhooks/chariow", "is_enabled": true, "masked_secret": "whsec_β€’β€’β€’β€’a1b2", "source": { "value": "manual", "label": "Manual", "description": "Created manually by user" }, "triggers": [ { "value": "successful_sale", "label": "Successful Sale", "description": "Triggers when a sale is successful." }, { "value": "license_activated", "label": "License Activated", "description": "Triggers when a license is activated." } ], "products": [], "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "is_editable": true, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-15T10:30:00+00:00" } } ``` ```json Not Found (404) theme={null} { "message": "We couldn't find this Pulse.", "errors": [] } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` ```json Missing scope (403) theme={null} { "message": "This credential is missing the required scope: webhooks.read. Update its permissions in your dashboard.", "data": [], "errors": { "scopes": ["webhooks.read"] } } ``` # List Pulses Source: https://chariow.dev/api-reference/pulses/list-pulses GET /pulses Retrieve all webhook notification pulses for your store Retrieves a cursor-paginated list of all pulse webhooks configured for your store, newest first, including pulses created by integrations (Zapier, Make, n8n). Pulses are webhook notifications sent to your specified endpoints when specific events occur, such as successful sales, abandoned sales, licence activations or new affiliates. Requires an API key with the `webhooks.read` scope (`webhooks.write` includes it). A key without it receives a `403` listing the missing scope. **Required scope:** `webhooks.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Query Parameters Number of pulses to return per page (maximum 100) Cursor for pagination. Use the `next_cursor` from the previous response to retrieve the next page. Search pulses by URL, public ID, or trigger value (e.g., `successful_sale`) ## Response The list is returned at the top level of the body, without the `message` and `errors` envelope used by single-resource endpoints. Array of pulse objects Unique pulse identifier (e.g., `pulse_abc123xyz789`) Webhook URL where notifications are sent Whether the pulse is currently active. Chariow sets it to `false` automatically when a delivery fails all 5 attempts. Masked form of the pulse signing secret, e.g. `whsec_β€’β€’β€’β€’a1b2`. The full secret is never returned by the public API; reveal it from the dashboard. See [Pulse Security](/en/guides/pulse-security). How the pulse was created Source value: `manual`, `zapier`, `make` or `n8n` Human-readable source label Description of the source Array of trigger event objects that will activate this pulse Trigger event value (e.g., `successful_sale`, `license_activated`, `affiliate_joined`, `all`) Human-readable label Description of when this trigger fires Products this pulse is limited to, sorted by creation order. An empty array means every product triggers this pulse. The filter only applies to sale and licence events: `affiliate.joined` reaches the pulse regardless. Product identifier Product name Product type (e.g., `course`, `license`, `downloadable`) `thumbnail` and `cover` image URLs Product category, with `value` and `label` `type`, plus `price` and `effective` amount objects (`value`, `formatted`, `short`, `currency`) Bundle value and savings, or `null` when the product is not a bundle Custom metadata attached to the product Store information Store identifier Store name Store logo URL Store URL `true` for pulses created manually. Pulses created by an integration (Zapier, Make, n8n) are managed by that integration and cannot be edited or deleted from Chariow. ISO 8601 timestamp ISO 8601 timestamp Cursor pagination metadata Number of items on this page Base URL of the endpoint Page size used for this request Cursor for the next page, or `null` if there are no more pages Full URL of the next page, or `null` Cursor for the previous page, or `null` on the first page Full URL of the previous page, or `null` Whether there are more items to fetch Whether the results span more than one page ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/pulses?per_page=20&search=webhook" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript Node.js theme={null} const response = await fetch('https://api.chariow.com/v1/pulses?per_page=20&search=webhook', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); const data = await response.json(); ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/pulses?per_page=20&search=webhook'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```json Response theme={null} { "data": [ { "id": "pulse_abc123xyz789", "url": "https://example.com/webhooks/chariow", "is_enabled": true, "masked_secret": "whsec_β€’β€’β€’β€’a1b2", "source": { "value": "manual", "label": "Manual", "description": "Created manually by user" }, "triggers": [ { "value": "successful_sale", "label": "Successful Sale", "description": "Triggers when a sale is successful." }, { "value": "license_activated", "label": "License Activated", "description": "Triggers when a license is activated." } ], "products": [], "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "is_editable": true, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-15T10:30:00+00:00" }, { "id": "pulse_def456uvw012", "url": "https://hooks.zapier.com/hooks/catch/12345/abcde", "is_enabled": true, "masked_secret": "whsec_β€’β€’β€’β€’9f8e", "source": { "value": "zapier", "label": "Zapier", "description": "Created via Zapier integration" }, "triggers": [ { "value": "successful_sale", "label": "Successful Sale", "description": "Triggers when a sale is successful." } ], "products": [ { "id": "prd_xyz789", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "is_editable": false, "created_at": "2025-01-10T08:00:00+00:00", "updated_at": "2025-01-10T08:00:00+00:00" } ], "pagination": { "count": 2, "path": "https://api.chariow.com/v1/pulses", "per_page": 20, "next_cursor": "eyJpZCI6NTB9", "next_page_url": "https://api.chariow.com/v1/pulses?cursor=eyJpZCI6NTB9", "prev_cursor": null, "prev_page_url": null, "has_more_pages": true, "has_pages": true } } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` ```json Missing scope (403) theme={null} { "message": "This credential is missing the required scope: webhooks.read. Update its permissions in your dashboard.", "data": [], "errors": { "scopes": ["webhooks.read"] } } ``` # Get Sale Source: https://chariow.dev/api-reference/sales/get-sale GET /sales/{saleId} Retrieve details of a specific sale Retrieves comprehensive information about a specific sale by its public ID, including customer details, product information, payment details, applied discounts, marketing campaign, shipping information, and customer rating. **Required scope:** `sales.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Path Parameters The unique sale public identifier (e.g., `sal_abc123xyz`) ## Response Unique sale identifier (e.g., `sal_abc123xyz`) Sale status (`initiated`, `awaiting_payment`, `completed`, `failed`, `abandoned`, `settled`). See [Sale Statuses](/en/guides/sales#sale-statuses). Sales channel information Channel value (`store`, `affiliate`, `discover`, `widget`, `api`) Human-readable label Channel description Final amount after discount, in the product currency Amount value (e.g., 99 for \$99.00) Formatted amount with currency symbol Short formatted amount Three-letter ISO currency code Original amount before discount Discount amount applied Settlement details Amount to be settled to the merchant ISO 8601 timestamp when settlement is due ISO 8601 timestamp when settlement was completed Platform service fee amount Download statistics Total number of downloads ISO 8601 timestamp of last download Temporary signed URL to download the invoice (valid for 60 minutes). Only set for completed and settled sales. Payment details Payment status (`initiated`, `pending`, `cancelled`, `failed`, `success`), `null` when no payment was needed Payment transaction ID Identifier of the payment gateway that handled the payment (for example `orqex`). Older sales can carry another identifier; treat the value as an opaque string. Payment method used by the buyer, with `name` and `icon_url`. `null` when unknown. Amount paid, in the payment currency Payment processing fee, in the product currency Payment fee rate as a percentage Currency conversion markup applied when the payment currency differs from the product currency: `rate` (percentage, or `null`) and `fee` (amount object). The rate depends on the payment currency. Exchange rate between the product currency and the payment currency Payment failure details, `null` unless the payment failed Failure code Explanation for you Explanation you can show to the buyer Whether the buyer should be invited to contact support Shipping address (fields are `null` when not collected) Street address City name State or province Country details (`name`, `code`, `alpha_3_code`, `dial_code`, `currency`, `flag`) Postal/ZIP code Purchase context information User agent of the request that created the sale Buyer IP address. For API checkouts, the `customer_ip` you forwarded, otherwise the IP of the calling server. Buyer country. For API checkouts it is resolved from `customer_ip`, or from the phone country when no usable IP was forwarded. Device type (`desktop`, `mobile`, `tablet`) Customer locale Custom field values provided during checkout Marketing campaign (`id`, `name`), if tracked Customer rating (`id`, `is_thumbs_up`, `comment`, `created_at`), if provided Store information (`id`, `name`, `logo_url`, `url`) Product information Customer information (`id`, `name`, `first_name`, `last_name`, `email`, `phone`, `avatar_url`) Name of the buyer as entered for this sale (`first_name`, `last_name`). Unlike `customer`, it keeps the name used at purchase time. Applied discount (`id`, `name`, `code`), if any Only present for gift purchases: `recipient` (customer object) and `message` Whether the customer's access to the product has been revoked for this sale Whether the sale has been reconciled with the payment gateway ISO 8601 timestamp of last reconciliation ISO 8601 timestamp when the sale failed ISO 8601 timestamp when the sale entered awaiting payment status ISO 8601 timestamp when the sale was abandoned. Cleared if a later payment confirmation reopens the sale. ISO 8601 timestamp when the sale was completed ISO 8601 timestamp when the sale was created ISO 8601 timestamp when the sale was last updated ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/sales/sal_abc123xyz" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/sales/sal_abc123xyz', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); console.log(data); // Sale object ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/sales/sal_abc123xyz'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/sales/sal_abc123xyz', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) sale = response.json()['data'] ``` ```json Response theme={null} { "data": { "id": "sal_abc123xyz", "status": "completed", "channel": { "value": "api", "label": "API", "description": "Sale created programmatically through the public API" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "discount_amount": { "value": 19.80, "formatted": "$19.80", "short": "20", "currency": "USD" }, "settlement": { "amount": { "value": 75.24, "formatted": "$75.24", "short": "75", "currency": "USD" }, "due_at": "2025-02-01T00:00:00+00:00", "done_at": null, "service_fee": { "value": 3.96, "formatted": "$3.96", "short": "4", "currency": "USD" } }, "download": { "total": 3, "last_at": "2025-01-20T14:30:00+00:00" }, "invoice_download_url": "https://api.chariow.com/...signed-invoice-url...", "payment": { "status": "success", "transaction_id": "txn_xyz789", "gateway": "orqex", "method": { "name": "Orange Money Senegal", "icon_url": "https://assets.example.com/icons/orange_money.svg" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "fee": { "value": 2.37, "formatted": "$2.37", "short": "2", "currency": "USD" }, "fee_rate": "3%", "interchange": { "rate": null, "fee": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" } }, "exchange_rate": { "value": 1, "formatted": "$1.00", "short": "1", "currency": "USD" }, "failure_error": null }, "shipping": { "address": "123 Main Street", "city": "New York", "state": "NY", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" }, "zip": "10001" }, "context": { "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", "ip_address": "203.0.113.42", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" }, "device_type": "desktop", "locale": "en_US" }, "custom_fields_values": { "company_name": "Acme Corp", "vat_number": "GB123456789" }, "campaign": { "id": "cmp_def456", "name": "Black Friday Campaign" }, "rating": { "id": "rat_ghi789", "is_thumbs_up": true, "comment": "Excellent product!", "created_at": "2025-01-18T09:00:00+00:00" }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "product": { "id": "prd_jkl012", "name": "Advanced Laravel Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null }, "customer": { "id": "cus_mno345", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "avatar_url": null }, "buyer": { "first_name": "John", "last_name": "Doe" }, "discount": { "id": "dis_pqr678", "name": "Save 20%", "code": "SAVE20" }, "is_access_revoked": false, "is_reconciled": false, "last_reconciled_at": null, "failed_at": null, "awaiting_payment_at": "2025-01-15T10:30:00+00:00", "abandoned_at": null, "completed_at": "2025-01-15T10:32:00+00:00", "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-15T10:32:00+00:00" } } ``` ```json Not Found (404) theme={null} { "message": "No query results for model [App\\Models\\Sale] sal_unknown", "errors": [] } ``` # List Sales Source: https://chariow.dev/api-reference/sales/list-sales GET /sales Retrieve all sales from your store Retrieves a cursor-paginated list of all sales in your store. The response includes customer, product, discount and rating information for each sale. **Required scope:** `sales.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Query Parameters Number of sales to return per page (1 to 100). A value above 100 returns a `422` validation error. Cursor for pagination. Use the `next_cursor` from the previous response. Filter by sale status: `initiated`, `awaiting_payment`, `completed`, `failed`, `abandoned`, or `settled` Filter by customer public ID (e.g., `cus_abc123xyz`) Search by sale ID (e.g., `sal_abc123xyz`) or payment transaction ID Only return sales created on or after this date (format: `Y-m-d`, e.g., `2025-01-01`) Only return sales created on or before this date (format: `Y-m-d`, e.g., `2025-01-31`). Must not be earlier than `from`. Shortcut for a date range, used instead of `from` and `to`: `today`, `yesterday`, `last7days`, `last30days`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear` or `lastYear` Sales are returned newest first. `start_date` and `end_date` are not supported and are silently ignored: use `from` and `to`. ## Response Array of sale objects Unique sale identifier (e.g., `sal_abc123xyz`) Sale status (`initiated`, `awaiting_payment`, `completed`, `failed`, `abandoned`, `settled`) Values for conversion tracking pixels: `event_id` (the sale ID), `currency` and `value` Original amount before discount Amount value (e.g., 99 for \$99.00) Formatted amount with currency symbol (e.g., `$99.00`) Short formatted amount Three-letter ISO currency code (e.g., `USD`, `XOF`) Final amount after discount Discount amount applied Payment details Amount paid in the payment currency. Omitted when nothing was to be paid. Payment status (`initiated`, `pending`, `cancelled`, `failed`, `success`) Exchange rate between the product currency and the payment currency When the payment failed: `code` and `customer_message` (a message you can show to the buyer). Otherwise `null`. Shipping address details (fields are `null` when not collected) Street address City name State or province ISO 3166-1 alpha-2 country code Postal/ZIP code Temporary signed URL to download the invoice (valid for 60 minutes), only for completed and settled sales ISO 8601 timestamp when the sale was created ISO 8601 timestamp when the sale was completed Store information (`id`, `name`, `logo_url`, `url`) Product information Customer information (`id`, `name`, `first_name`, `last_name`, `email`, `phone`, `avatar_url`) Name of the buyer as entered for this sale (`first_name`, `last_name`) Applied discount (`id`, `name`, `code`), if any Customer rating (`id`, `is_thumbs_up`, `comment`, `created_at`), if provided Only present for gift purchases: `recipient` (customer object) and `message` Cursor pagination metadata Cursor for the next page (`null` if no more pages) Cursor for the previous page (`null` on the first page) Whether more results are available Number of items per page ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/sales?status=completed&per_page=20&from=2025-01-01&to=2025-01-31" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/sales?status=completed&per_page=20&from=2025-01-01&to=2025-01-31', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); console.log(result.data); // Array of sales console.log(result.pagination); // Pagination info ``` ```php PHP theme={null} $ch = curl_init('https://api.chariow.com/v1/sales?status=completed&per_page=20&from=2025-01-01&to=2025-01-31'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key' ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $data = json_decode($response, true); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/sales', params={ 'status': 'completed', 'per_page': 20, 'from': '2025-01-01', 'to': '2025-01-31' }, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) data = response.json() sales = data['data'] ``` ```json Response theme={null} { "data": [ { "id": "sal_abc123xyz", "status": "completed", "tracking": { "event_id": "sal_abc123xyz", "currency": "USD", "value": 79.2 }, "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "discount_amount": { "value": 19.80, "formatted": "$19.80", "short": "20", "currency": "USD" }, "payment": { "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "status": "success", "exchange_rate": { "value": 1, "formatted": "$1.00", "short": "1", "currency": "USD" }, "failure_error": null }, "shipping": { "address": "123 Main Street", "city": "New York", "state": "NY", "country": "US", "zip": "10001" }, "invoice_download_url": "https://api.chariow.com/...signed-invoice-url...", "created_at": "2025-01-15T10:30:00+00:00", "completed_at": "2025-01-15T10:32:00+00:00", "store": { "id": "str_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "product": { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null }, "customer": { "id": "cus_ghi789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "avatar_url": null }, "buyer": { "first_name": "John", "last_name": "Doe" }, "discount": { "id": "dis_jkl012", "name": "Save 20%", "code": "SAVE20" }, "rate": null } ], "pagination": { "per_page": 20, "next_cursor": "eyJpZCI6NTB9", "prev_cursor": null, "has_more_pages": true } } ``` # Get Store Source: https://chariow.dev/api-reference/store/get-store GET /store Retrieve detailed information about your store Retrieves information about the store associated with the authenticated API key, including branding, social links, status, and statistics. **Required scope:** `store.read`. A key without it receives a `403` error. See [Authentication](/api-reference/authentication#scopes). ## Authentication This endpoint requires authentication using a Store API key. Include your API key in the `Authorization` header as a Bearer token. ``` Authorization: Bearer YOUR_API_KEY ``` ## Response Store information object Unique store identifier with `store_` prefix (e.g., `store_abc123xyz`) Store name, as plain text Store description displayed on your storefront, as plain text Full URL to the store logo image. Returns `null` if no logo is set. Public URL of the store (custom domain or Chariow subdomain) Social media links configured for the store. Each link is `null` when not set. Telegram channel or group URL Instagram profile URL Facebook page URL X (formerly Twitter) profile URL LinkedIn profile or company page URL YouTube channel URL TikTok profile URL Discord server invite URL Current store status. Possible values: `active`, `under_review`, `suspended`, `archived` Store statistics, cached for up to one hour Number of customers in the store Ratings left on completed sales Number of ratings Number of positive ratings Share of positive ratings (e.g., `95%`) Appearance settings (theme, fonts, colours) are not returned by this endpoint. ## Error Responses Returned when the API key is missing or invalid ```json theme={null} { "message": "API key is missing. Please provide a valid API key. Help: https://docs.chariow.com", "errors": [] } ``` Or: ```json theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer sk_live_abc123xyz..." ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/store', { method: 'GET', headers: { 'Authorization': 'Bearer sk_live_abc123xyz...', 'Content-Type': 'application/json' } }); const { data } = await response.json(); console.log(data); ``` ```php PHP theme={null} ```json Success Response (200) theme={null} { "data": { "id": "store_abc123xyz", "name": "My Digital Store", "description": "A marketplace for premium digital products and courses", "logo_url": "https://cdn.chariow.com/stores/store_abc123xyz/logo.png", "url": "https://mystore.chariow.com", "social_links": { "telegram": null, "instagram": "https://instagram.com/mystore", "facebook": "https://facebook.com/mystore", "x": "https://x.com/mystore", "linkedin": null, "youtube": null, "tiktok": null, "discord": null }, "status": "active", "stats": { "total_customers": 1840, "ratings": { "total_ratings": 312, "thumbs_up_count": 297, "thumbs_up_percentage": "95%" } } } } ``` ```json Unauthorised (401) theme={null} { "message": "Invalid API key. Please check again. Help: https://docs.chariow.com", "errors": [] } ``` # Affiliates Source: https://chariow.dev/en/guides/affiliates Learn how to manage your affiliate programme via the Chariow API Chariow provides a comprehensive affiliate management system that allows you to grow your sales through partnerships. Affiliates can promote your products using unique referral codes and earn commissions on successful sales. ## Affiliate Object An affiliate contains information about their account, performance metrics, and nested account details: ```json theme={null} { "id": "saff_xyz789abc", "status": "active", "source": { "value": "invitation", "label": "Invitation", "description": "Added via store invitation" }, "total_visits": 156, "total_sales": 32, "total_earnings": { "value": 1250, "formatted": "$1,250.00", "short": "1K", "currency": "USD" }, "first_visit_at": "2025-01-16T08:00:00+00:00", "last_visit_at": "2025-02-01T14:22:00+00:00", "suspended_at": null, "suspended_reason": null, "account": { "id": "aff_abc123def", "pseudo": "creative_studio", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" }, "status": "active", "user": { "id": "usr_def456", "name": "John Doe", "first_name": "John", "last_name": "Doe", "nickname": null, "email": "john@example.com", "profile_photo_url": null }, "created_at": "2025-01-15T09:00:00+00:00" }, "created_at": "2025-01-15T10:00:00+00:00", "updated_at": "2025-02-01T14:22:00+00:00" } ``` ### Key Fields * **`id`**: Store affiliate public ID (prefixed with `saff_`) * **`status`**: Current status (`active` or `suspended`) * **`source`**: How the affiliate joined (e.g., `invitation`, `network`) * **`total_visits`**: Number of referral link visits * **`total_sales`**: Number of completed sales from referrals * **`total_earnings`**: Total commission earned with formatted amount * **`account`**: Nested affiliate account details including user information * **`account.user`**: The affiliate's user profile (name, email, etc.) * **`account.pseudo`**: Display name used by the affiliate * **`account.country`**: The affiliate's country (name, ISO codes, dial code, currency and flag) * **`suspended_at`**: Timestamp when suspended (null if active) * **`suspended_reason`**: Reason for suspension (null if active) ## Affiliate Statuses | Status | Description | | - | - | | `active` | Affiliate is active and can earn commissions | | `suspended` | Affiliate account has been suspended | ## Getting an Affiliate Retrieve a specific affiliate using their unique referral code: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/affiliates/CREATOR123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/affiliates/CREATOR123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` This is useful for: * Validating an affiliate code before applying commissions * Displaying affiliate information on your website * Building affiliate dashboards ## Sending Affiliate Invitations Invite potential affiliates to join your programme by sending invitation emails: ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/affiliates/invitations" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "emails": ["john@example.com", "jane@example.com", "partner@business.com"] }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/affiliates/invitations', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ emails: ['john@example.com', 'jane@example.com', 'partner@business.com'] }) }); const { data } = await response.json(); ``` ### Batch Invitations You can send up to 25 invitations in a single request. The API will: * Create and send invitations for valid new emails * Skip emails that are already registered affiliates * Skip emails that have pending invitations * Lower-case the addresses and drop duplicates Skipped addresses are not listed in the response: `data` only holds the invitations created, and is empty when every address was skipped. The message reads `Invitation sent successfully.` for one invitation and `N invitations sent successfully.` otherwise. ### Response ```json theme={null} { "message": "2 invitations sent successfully.", "data": [ { "id": "affinv_abc123xyz", "email": "john@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" }, { "id": "affinv_def456uvw", "email": "jane@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" } ], "errors": [] } ``` ## Invitation Object An invitation contains information about its status and expiration: ```json theme={null} { "id": "affinv_abc123xyz", "email": "john@example.com", "status": "pending", "expires_at": "2026-02-10T10:30:00+00:00", "accepted_at": null, "created_at": "2026-01-11T10:30:00+00:00" } ``` ### Invitation Statuses | Status | Description | | - | - | | `pending` | Invitation sent but not yet accepted | | `accepted` | Invitation has been accepted | | `expired` | Invitation has passed its expiration date | | `cancelled` | Invitation has been cancelled | ## Webhook Events When an affiliate joins your store, whether through an invitation or the affiliate network, a webhook event is triggered via [Pulses](/en/guides/pulses). The event is signed and recorded like every other Pulse event; see the [Pulses guide](/en/guides/pulses) for the payload details. ### affiliate.joined Triggered when a new affiliate joins your store. ```json theme={null} { "event": "affiliate.joined", "affiliate": { "id": "saff_xyz789abc", "account": { "id": "aff_abc123def", "code": "CREATOR123", "pseudo": "creative_studio", "email": "creator@example.com", "first_name": "John", "last_name": "Doe", "name": "John Doe", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" }, "phone": { "number": 12025550123, "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } } }, "source": { "value": "invitation", "label": "Invitation", "description": "Added via store invitation" }, "status": "active", "joined_at": "2025-01-15T10:40:00+00:00" }, "store": { "id": "str_xyz789", "name": "My Digital Store", "url": "https://mystore.mychariow.com" } } ``` Configure Pulses in your Chariow dashboard (**Automation** > **Pulses**) to receive these events. ## Implementation Example Here's a complete example of managing affiliates in your application: ```javascript theme={null} class AffiliateManager { constructor(apiKey) { this.apiKey = apiKey; this.baseUrl = 'https://api.chariow.com/v1'; } async getAffiliate(code) { const response = await fetch( `${this.baseUrl}/affiliates/${code}`, { headers: { 'Authorization': `Bearer ${this.apiKey}` }} ); if (!response.ok) { throw new Error('Affiliate not found'); } const { data } = await response.json(); return data; } async sendInvitations(emails) { const response = await fetch( `${this.baseUrl}/affiliates/invitations`, { method: 'POST', headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ emails }) } ); if (!response.ok) { const error = await response.json(); throw new Error(error.message); } return response.json(); } async validateAffiliateCode(code) { try { const affiliate = await this.getAffiliate(code); return { valid: affiliate.status === 'active', affiliate }; } catch (error) { return { valid: false, error: error.message }; } } } // Usage const manager = new AffiliateManager('sk_live_your_api_key'); // Validate an affiliate code at checkout const { valid, affiliate } = await manager.validateAffiliateCode('CREATOR123'); if (valid) { console.log(`Affiliate ${affiliate.account.user.name} is active`); console.log(`Total earnings: ${affiliate.total_earnings.formatted}`); } // Send invitations to potential affiliates const result = await manager.sendInvitations([ 'partner1@example.com', 'partner2@example.com' ]); console.log(`${result.data.length} invitations sent`); ``` ## API Endpoints Summary | Endpoint | Method | Description | | - | - | - | | `/v1/affiliates/{affiliateCode}` | GET | Get affiliate details by code | | `/v1/affiliates/invitations` | POST | Send affiliate invitations | ## Best Practices ### Affiliate Code Validation * Always validate affiliate codes before applying commissions * Check the affiliate status is `active` * Cache affiliate data to reduce API calls ### Invitation Management * Use batch invitations for efficiency (up to 25 emails) * Handle skipped emails gracefully * Implement retry logic for failed invitations ### Webhook Integration * Set up webhooks to receive `affiliate.joined` events * Use webhooks to trigger onboarding workflows * Store affiliate data when they join for faster lookups ### Commission Tracking * Track affiliate referrals accurately * Provide affiliates with real-time statistics * Implement proper attribution windows ## Related Resources Set up webhooks for affiliate events View the Get Affiliate API reference View the Send Invitations API reference Track affiliate sales # Best Practices Source: https://chariow.dev/en/guides/best-practices Production-ready guidelines for integrating with the Chariow Checkout API Follow these best practices to build robust, secure, and reliable integrations with the Chariow API, especially when handling checkout flows. ## Checkout API Best Practices ### Always Handle All Response States The checkout API returns different states that require different handling. Never assume a checkout will always require payment. ```javascript theme={null} async function handleCheckout(checkoutData) { const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify(checkoutData) }); const result = await response.json(); switch (result.data.step) { case 'awaiting_payment': // Redirect to payment - most common case return { action: 'redirect', url: result.data.payment.checkout_url }; case 'completed': // Free product - sale completed immediately return { action: 'success', saleId: result.data.purchase.id }; case 'already_purchased': // Customer already owns this product return { action: 'already_owned', message: result.data.message }; default: // Handle unexpected states gracefully console.error('Unexpected checkout state:', result.data.step); return { action: 'error', message: 'Unexpected response from payment system' }; } } ``` ### Validate Data Before Submitting Reduce failed checkouts by validating customer data on your end before calling the API. ```javascript theme={null} function validateCheckoutData(data) { const errors = []; // Email validation const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!data.email || !emailRegex.test(data.email)) { errors.push('Valid email is required'); } // Name validation if (!data.first_name || data.first_name.length > 50) { errors.push('First name is required (max 50 characters)'); } if (!data.last_name || data.last_name.length > 50) { errors.push('Last name is required (max 50 characters)'); } // Phone validation - numeric only const phoneNumber = data.phone?.number?.replace(/\D/g, ''); if (!phoneNumber || phoneNumber.length < 6) { errors.push('Valid phone number is required'); } // Country code validation const validCountryCodes = ['US', 'CA', 'GB', 'FR', 'DE', 'ES', 'IT', /* ... */]; if (!data.phone?.country_code || !validCountryCodes.includes(data.phone.country_code)) { errors.push('Valid country code is required'); } return { valid: errors.length === 0, errors }; } ``` ### Store Sale IDs Immediately Always persist the sale ID as soon as you receive it. This is critical for customer support, refunds, and order tracking. ```javascript theme={null} async function processCheckout(checkoutData, orderId) { const result = await initiateCheckout(checkoutData); if (result.data.purchase?.id) { // Store immediately - before any redirect await database.orders.update(orderId, { chariow_sale_id: result.data.purchase.id, checkout_initiated_at: new Date() }); } return result; } ``` ### Use Pulses for Reliable Sale Confirmation Never rely solely on redirect URLs to confirm purchases. Payment pages can be closed, redirects can fail, and customers may not return to your site. The `redirect_url` is for user experience only. Always use [Pulses](/en/guides/pulses) (webhooks) for reliable sale confirmation. ```javascript theme={null} // Set up a Pulse endpoint for sale confirmation. // express.raw is required: the signature covers the raw body bytes. app.post('/webhooks/chariow', express.raw({ type: 'application/json' }), async (req, res) => { if (!verifySignature(req.body, req.header('x-chariow-signature'), SECRET)) { return res.status(401).send('Invalid signature'); } const payload = JSON.parse(req.body.toString('utf8')); switch (payload.event) { case 'successful.sale': await fulfillOrder(payload.sale.id); await sendConfirmationEmail(payload.customer.email); break; case 'abandoned.sale': await scheduleRecoveryEmail(payload.sale.id); break; } res.status(200).send('OK'); } ); ``` Deduplicate on the `x-pulse-delivery-id` header and see [Pulse Security](/en/guides/pulse-security) for the full signing contract. *** ## Security Best Practices ### Never Expose API Keys in Client Code API keys should only be used server-side. Never include them in JavaScript bundles, mobile apps, or any client-facing code. ```javascript theme={null} // Server-side (Node.js) const API_KEY = process.env.CHARIOW_API_KEY; app.post('/api/checkout', async (req, res) => { const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify(req.body) }); res.json(await response.json()); }); ``` ```javascript theme={null} // Client-side - NEVER DO THIS const API_KEY = 'sk_live_abc123'; // EXPOSED! fetch('https://api.chariow.com/v1/checkout', { headers: { 'Authorization': `Bearer ${API_KEY}` } }); ``` ### Validate Webhook Signatures Always verify that incoming webhooks are genuinely from Chariow by checking the signature. The signature is an HMAC-SHA256 of the **raw body bytes**, prefixed with `sha256=`. ```javascript theme={null} const crypto = require('crypto'); function verifySignature(rawBody, receivedSignature, secret) { // rawBody must be the untouched Buffer, never a re-serialised object: // JSON.stringify does not reproduce the escaped forward slashes Chariow sends. const expected = 'sha256=' + crypto .createHmac('sha256', secret) .update(rawBody) .digest('hex'); const a = Buffer.from(receivedSignature ?? ''); const b = Buffer.from(expected); // timingSafeEqual throws on buffers of different lengths. return a.length === b.length && crypto.timingSafeEqual(a, b); } ``` Each Pulse has its own signing secret, prefixed `whsec_`, available from the Pulse's Overview tab in the dashboard. It is not your API key. See [Pulse Security](/en/guides/pulse-security). ### Use Environment Variables Store all sensitive configuration in environment variables, never in code. ```bash theme={null} # .env file (never commit this) CHARIOW_API_KEY=sk_live_your_api_key CHARIOW_WEBHOOK_SECRET=whsec_your_webhook_secret ``` ```javascript theme={null} // Load from environment const config = { apiKey: process.env.CHARIOW_API_KEY, webhookSecret: process.env.CHARIOW_WEBHOOK_SECRET }; ``` *** ## Error Handling Best Practices ### Implement Comprehensive Error Handling Handle all possible error scenarios gracefully to provide a good user experience. ```javascript theme={null} async function safeCheckout(checkoutData) { try { const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify(checkoutData) }); // Handle HTTP errors if (!response.ok) { const error = await response.json(); switch (response.status) { case 401: console.error('API key invalid'); return { error: 'Payment system configuration error' }; case 404: return { error: 'Product not found or unavailable' }; case 422: // Validation errors - return field-specific messages return { error: 'Validation failed', fields: error.errors }; case 429: return { error: 'Too many requests. Please try again shortly.' }; default: return { error: 'Payment system unavailable. Please try again.' }; } } return await response.json(); } catch (networkError) { // Handle network failures console.error('Network error:', networkError); return { error: 'Unable to connect to payment system. Check your connection.' }; } } ``` ### Display User-Friendly Error Messages Map API errors to helpful messages that guide users to fix issues. ```javascript theme={null} const errorMessages = { 'email': 'Please enter a valid email address', 'phone.number': 'Please enter a valid phone number (digits only)', 'phone.country_code': 'Please select your country', 'address': 'Please enter your shipping address', 'city': 'Please enter your city', 'state': 'Please enter your state or region', 'country': 'Please select your country', 'zip': 'Please enter your postal code', 'discount_code': 'This discount code is invalid or has expired' }; function getFieldError(fieldName, apiErrors) { if (apiErrors[fieldName]) { return errorMessages[fieldName] || apiErrors[fieldName][0]; } return null; } ``` ### Log Errors for Debugging Maintain detailed logs for troubleshooting while keeping sensitive data secure. ```javascript theme={null} function logCheckoutError(error, checkoutData) { // Remove sensitive data before logging const safeData = { product_id: checkoutData.product_id, email: maskEmail(checkoutData.email), timestamp: new Date().toISOString(), error: error.message || error }; console.error('Checkout failed:', JSON.stringify(safeData)); // Send to monitoring service monitoring.captureError(error, { context: safeData }); } function maskEmail(email) { const [local, domain] = email.split('@'); return `${local.slice(0, 2)}***@${domain}`; } ``` *** ## Performance Best Practices ### Implement Request Timeouts Don't let API calls hang indefinitely. Set reasonable timeouts. ```javascript theme={null} async function checkoutWithTimeout(checkoutData, timeoutMs = 30000) { const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), timeoutMs); try { const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify(checkoutData), signal: controller.signal }); return await response.json(); } finally { clearTimeout(timeout); } } ``` ### Cache Product Data Reduce API calls by caching product information that doesn't change frequently. ```javascript theme={null} const productCache = new Map(); const CACHE_TTL = 5 * 60 * 1000; // 5 minutes async function getProduct(productId) { const cached = productCache.get(productId); if (cached && Date.now() - cached.timestamp < CACHE_TTL) { return cached.data; } const response = await fetch(`https://api.chariow.com/v1/products/${productId}`, { headers: { 'Authorization': `Bearer ${API_KEY}` } }); const data = await response.json(); productCache.set(productId, { data: data.data, timestamp: Date.now() }); return data.data; } ``` ### Respect Rate Limits Handle rate limiting gracefully with exponential backoff. ```javascript theme={null} async function fetchWithRetry(url, options, maxRetries = 3) { for (let attempt = 0; attempt < maxRetries; attempt++) { const response = await fetch(url, options); if (response.status === 429) { const retryAfter = response.headers.get('Retry-After') || Math.pow(2, attempt); console.log(`Rate limited. Retrying after ${retryAfter}s`); await sleep(retryAfter * 1000); continue; } return response; } throw new Error('Max retries exceeded'); } function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } ``` *** ## Testing Best Practices ### Test All Checkout Scenarios Create comprehensive tests for every possible checkout outcome. ```javascript theme={null} describe('Checkout Integration', () => { test('handles paid product checkout', async () => { const result = await handleCheckout({ product_id: 'prd_paid_product', email: 'test@example.com', // ... }); expect(result.action).toBe('redirect'); expect(result.url).toContain('payment.chariow.com'); }); test('handles free product checkout', async () => { const result = await handleCheckout({ product_id: 'prd_free_product', email: 'test@example.com', // ... }); expect(result.action).toBe('success'); expect(result.saleId).toBeDefined(); }); test('handles already purchased product', async () => { const result = await handleCheckout({ product_id: 'prd_already_owned', email: 'existing@example.com', // ... }); expect(result.action).toBe('already_owned'); }); test('handles invalid product gracefully', async () => { const result = await handleCheckout({ product_id: 'prd_nonexistent', email: 'test@example.com', // ... }); expect(result.error).toBeDefined(); }); test('handles shipping required products', async () => { const result = await handleCheckout({ product_id: 'prd_physical', email: 'test@example.com', address: '123 Main St', city: 'New York', state: 'NY', country: 'US', zip: '10001', // ... }); expect(result.action).toBe('redirect'); }); }); ``` ### Use Staging Environment for Integration Tests Always test against a staging environment before deploying to production. ```javascript theme={null} const config = { development: { apiUrl: 'https://api.staging.chariow.com/v1', apiKey: process.env.CHARIOW_STAGING_KEY }, production: { apiUrl: 'https://api.chariow.com/v1', apiKey: process.env.CHARIOW_LIVE_KEY } }; const env = process.env.NODE_ENV || 'development'; const apiConfig = config[env]; ``` *** ## Checklist for Production Before going live, ensure you've completed this checklist: * [ ] API keys stored in environment variables * [ ] API calls made server-side only * [ ] Webhook signatures verified * [ ] HTTPS used for all endpoints * [ ] Sensitive data not logged * [ ] All HTTP status codes handled * [ ] Network errors caught * [ ] User-friendly error messages displayed * [ ] Errors logged for debugging * [ ] Rate limiting handled gracefully * [ ] All checkout states handled (payment, completed, already\_purchased) * [ ] Sale IDs stored immediately * [ ] Pulses configured for sale confirmation * [ ] Customer data validated before submission * [ ] Shipping fields included when required * [ ] Unit tests for checkout logic * [ ] Integration tests with staging API * [ ] All product types tested * [ ] Error scenarios tested * [ ] Load testing completed *** ## Next Steps Explore real-world integration examples Learn the complete checkout flow Set up webhooks for notifications Explore the complete API # Checkout Source: https://chariow.dev/en/guides/checkout Learn how to initiate and manage checkout sessions via the Chariow API The checkout API allows you to programmatically create purchase sessions for your customers. This is useful for custom storefronts, integrations, or automated sales flows. **Unsupported product types:** the following cannot be used to initiate a checkout through the API: * **Service** products * **Coaching** products * Products with **pay-what-you-want** pricing For these, redirect customers to your [Chariow storefront](https://chariow.com) or use the **Snap Widget** embed on your website. All sales initiated via the checkout API will have their **Channel** set to **"API"** on your store dashboard. This helps you identify and track sales originating from your API integrations separately from other channels like your storefront or Snap Widget. ## Repeat Purchases The ability to purchase a product multiple times depends on the product type: | Product Type | Repeat Purchase | Behaviour | | - | - | - | | **License** | Always allowed | Customers can purchase license products multiple times. Each purchase generates a new unique license key. | | **Downloadable** | Blocked | Returns `already_purchased` if customer has an active access grant. | | **Course** | Blocked | Returns `already_purchased` if customer has an active access grant. | | **Bundle** | Blocked | Returns `already_purchased` if customer has an active access grant. | For blocked product types, if a customer's access has been **revoked** (e.g., after a refund), they will be able to purchase the product again. The system checks for **active** access grants only. ## Checkout Flow Overview The Chariow checkout API handles the complete purchase flow from initiation to completion: The product must be **published** before initiating a checkout. Unpublished products will return a 404 error. Call the `/checkout` endpoint with product ID and customer details Check the `step` field in the response: * **payment**: Redirect customer to `checkout_url` for payment * **completed**: Sale completed immediately (free products) * **already\_purchased**: Customer already owns this product Customer completes payment on the secure hosted payment page, using the methods available in their country Get notified of sale status changes via webhooks (recommended) Customer receives automatic access to files, licenses, courses, etc. ## Product Types Supported The checkout API supports the following Chariow product types: * **Downloadable Products**: Digital files (PDFs, software, media) * **Courses**: Educational content with lessons and chapters * **Licenses**: Software license keys with activation management * **Bundles**: Collections of multiple products **Service** and **Coaching** product types are not supported via the Public API. For these products, redirect customers to your Chariow store or use the Snap Widget. Products using pay-what-you-want pricing are also not supported. ## Initiating a Checkout Create a new checkout session: ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prd_abc123", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "discount_code": "SAVE20" }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ product_id: 'prd_abc123', email: 'customer@example.com', first_name: 'John', last_name: 'Doe', phone: { number: '1234567890', country_code: 'US' }, discount_code: 'SAVE20' }) }); const data = await response.json(); ``` ```python Python theme={null} import requests response = requests.post( 'https://api.chariow.com/v1/checkout', headers={ 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, json={ 'product_id': 'prd_abc123', 'email': 'customer@example.com', 'first_name': 'John', 'last_name': 'Doe', 'phone': { 'number': '1234567890', 'country_code': 'US' }, 'discount_code': 'SAVE20' } ) ``` ### Request Parameters | Parameter | Type | Required | Description | | - | - | - | - | | `product_id` | string | Yes | Product public ID or slug (e.g., `prd_abc123xyz` or `premium-course`) | | `price_variant_id` | string | No | Identifier of an active price variant (one-time pricing only). An unknown or inactive variant is ignored and the regular price is used | | `email` | string | Yes | Customer email address (strict check, max 255 characters). Stored in lowercase | | `first_name` | string | Yes | Customer first name (max 50 characters) | | `last_name` | string | Yes | Customer last name (max 50 characters) | | `phone.number` | string | Yes | Phone number (numeric only) | | `phone.country_code` | string | Yes | ISO 3166-1 alpha-2 country code of a known country (e.g., "US", "CI", "SN") | | `discount_code` | string | No | Discount code to apply (max 100 characters) | | `affiliate_code` | string | No | Affiliate tracking code for commission attribution (max 50 characters) | | `campaign_id` | string | No | Campaign public ID or tracking code | | `custom_fields` | object | No | Custom field values (key-value pairs) | | `payment_currency` | string | No | ISO 4217 code of a currency supported by Chariow (e.g., "XOF", "EUR"). Defaults to your store currency. See [Multi-Currency Support](#multi-currency-support) | | `redirect_url` | string | No | Custom redirect URL after payment completion (max 2048 characters) | | `custom_metadata` | object | No | Custom key-value metadata to store with the sale (max 10 keys, 255 chars per value). Included in Pulse webhook payloads. | | `customer_ip` | string | No | The buyer's IP address, IPv4 or IPv6 (e.g., "203.0.113.42"). See [Buyer IP address](#buyer-ip-address). | | `embed_origins` | array | No | Up to 4 HTTPS origins allowed to embed the payment page in an iframe. See [Embedding the Payment Page](#embedding-the-payment-page) | | `gift` | object | No | Buy the product for someone else. See [Gift Purchases](#gift-purchases) | | `shipping` | object | Conditional | Shipping address, required when the product requires one. See below | ### Shipping Address Fields When the product has "Require shipping address" enabled, you must send a `shipping` object in your checkout request: | Parameter | Type | Required | Description | | - | - | - | - | | `shipping.address` | string | Conditional | Street address for shipping | | `shipping.city` | string | Conditional | City for shipping | | `shipping.state` | string | Conditional | State or region for shipping | | `shipping.country` | string | Conditional | Country code of a known country (ISO 3166-1 alpha-2, e.g., "US", "FR") | | `shipping.zip` | string | Conditional | Postal/ZIP code for shipping | These fields are **required** only when the product has shipping enabled. If shipping is not required, the `shipping` object is ignored. Address fields sent at the top level of the request body are not read. #### Example with Shipping Address ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "shipping": { "address": "123 Main Street", "city": "New York", "state": "NY", "country": "US", "zip": "10001" } } ``` ## Checkout Response States The checkout response includes a `step` field indicating the current state: ### Awaiting Payment For paid products, you'll receive a payment URL: ```json theme={null} { "data": { "step": "payment", "message": null, "purchase": { "id": "sal_xyz789", "status": "awaiting_payment", "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" } }, "payment": { "checkout_url": "https://payment.example.com/checkout/abc123?country=US&phone=...", "transaction_id": "txn_def456", "gateway": "orqex" } } } ``` The `purchase` object is truncated here; it has the same shape as a sale returned by [List Sales](/api-reference/sales/list-sales). Redirect the customer to `checkout_url` to complete their payment. The URL carries the buyer's phone country and number as query parameters so the payment form is prefilled: use it exactly as returned. `gateway` identifies the payment gateway handling the payment; treat it as an opaque string. ### Completed (Free Products) For free products, the sale completes immediately: ```json theme={null} { "data": { "step": "completed", "message": null, "purchase": { "id": "sal_xyz789", "status": "completed" }, "payment": { "checkout_url": null, "transaction_id": null, "gateway": null } } } ``` A paid product also completes immediately when a discount brings the amount to zero. ### Already Purchased If the customer already owns the product: ```json theme={null} { "data": { "step": "already_purchased", "message": "You already own this product. Access it in your Customer Portal.", "purchase": null, "payment": { "checkout_url": null, "transaction_id": null, "gateway": null } } } ``` No sale is created in this case. ## Custom Redirect URLs You can specify a custom redirect URL to send customers to your own thank-you page after payment completion: ```bash theme={null} curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "redirect_url": "https://yoursite.com/thank-you?sale={sale_id}" }' ``` The redirect URL must be a valid active URL (max 2048 characters). When not provided, customers will be redirected to the default Chariow post-purchase page. ## Multi-Currency Support Specify the payment currency to charge customers in a different currency from your store's default: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "payment_currency": "EUR" } ``` The response will include exchange rate information when currency conversion is applied. * The code must be a currency supported by Chariow. An unsupported code returns a `422` validation error on `payment_currency` instead of starting the checkout * When the payment currency differs from the product currency, the price is converted and a conversion markup is added. The markup rate depends on the payment currency and is the same one applied to prices shown on your storefront, so the buyer pays the amount they were shown * The sale amounts (`amount`, `original_amount`) stay in the product currency; `purchase.payment.amount` is what the buyer pays, in the payment currency ## Applying Discount Codes Pass a discount code to apply savings: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "discount_code": "SAVE20" } ``` The response will show the discounted amount: ```json theme={null} { "data": { "purchase": { "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "discount_amount": { "value": 19.80, "formatted": "$19.80", "short": "20", "currency": "USD" }, "discount": { "id": "dis_xyz789", "name": "Save 20%", "code": "SAVE20" } } } } ``` ## Custom Fields If your product has custom fields configured, you can collect and validate them during checkout: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "custom_fields": { "company_name": "Acme Corp", "job_title": "Developer", "team_size": "10-50" } } ``` Custom fields must match the product's configured custom field definitions. Invalid or missing required custom fields will result in validation errors. ## Campaign Tracking Track the source of sales by including a campaign ID: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "campaign_id": "camp_summer2024" } ``` This helps you: * Track which marketing campaigns drive the most sales * Attribute revenue to specific channels * Analyse campaign performance in your Chariow dashboard ## Custom Metadata Store custom data with the sale for your own tracking and integration purposes: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "custom_metadata": { "order_ref": "ORD-123", "source": "landing_page", "utm_campaign": "summer_sale" } } ``` ### Important Notes * Maximum 10 keys allowed per sale * Each value is limited to 255 characters * Keys should be strings with alphanumeric characters and underscores * Custom metadata is included in Pulse webhook payloads Use custom metadata to link Chariow sales with your CRM, analytics platform, or internal systems. The metadata is returned in all sale-related webhooks. ## Buyer IP Address The checkout endpoint is called from your server, so the IP address we observe is your own infrastructure, not the buyer's. Pass the buyer's IP in `customer_ip` to correct that: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "customer_ip": "203.0.113.42" } ``` Read the buyer's IP from the request that reaches your own server, typically the leftmost entry of the `X-Forwarded-For` header, or `CF-Connecting-IP` if you sit behind Cloudflare. ### What it improves * **Payment methods**: the buyer's country is resolved from this IP, and the country determines which payment methods appear on the checkout page * **Analytics**: sales are attributed to the buyer's country rather than to your server's hosting region * **Fraud review**: the sale record carries the buyer's real IP ### Important notes * The field is optional. Without it, or when the IP cannot be located, the buyer's country is taken from `phone.country_code`, never from your server's location. The sale then records the calling IP as its IP address * Both IPv4 and IPv6 are accepted; a malformed value returns a `422` * The field is only honoured on API checkouts, so it cannot be spoofed from a browser ## Embedding the Payment Page To show the hosted payment page inside an iframe on your own site, list the origins that will embed it in `embed_origins` (up to 4): ```json theme={null} { "product_id": "prd_abc123xyz", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "embed_origins": ["https://shop.example.com"] } ``` Each entry must be a canonical HTTPS origin: lowercase `https://` scheme and host, an optional non-default port, and no path, query string, fragment, credentials or trailing slash. `https://shop.example.com` is valid; `https://shop.example.com/`, `http://shop.example.com` and `https://Shop.example.com` are rejected with a `422`. ## Gift Purchases Send a `gift` object to buy the product for someone else. The recipient receives access to the product, and the buyer pays: ```json theme={null} { "product_id": "prd_abc123xyz", "email": "buyer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "gift": { "recipient_email": "friend@example.com", "recipient_first_name": "Jane", "recipient_last_name": "Smith", "message": "Happy birthday!" } } ``` | Parameter | Type | Required | Description | | - | - | - | - | | `gift.recipient_email` | string | Yes (with `gift`) | Recipient email (max 255 characters). Must differ from the buyer's email, otherwise the API returns `422` | | `gift.recipient_first_name` | string | Yes (with `gift`) | Recipient first name (max 50 characters) | | `gift.recipient_last_name` | string | Yes (with `gift`) | Recipient last name (max 50 characters) | | `gift.message` | string | No | Message for the recipient (max 500 characters) | If the recipient already owns the product, the API returns `409`. The sale carries a `gift` object with the recipient and the message. ## Existing Customers Each store has one customer per email address, compared case-insensitively. When a checkout uses the email of an existing customer, that customer is reused and their first name, last name and phone number are updated with the values sent. The same applies to a gift recipient. ## Rate Limits Checkout has its own rate-limit bucket of 100 requests per minute per API key, separate from the rest of the Public API, so a bulk sync of sales or products cannot block your buyers from paying. Above the limit the API returns `429 Too Many Requests`. ## Error Handling Common checkout errors and how to handle them: | HTTP Status | Error | Cause | Solution | | - | - | - | - | | 400 | Invalid phone number | `phone.number` is not valid for `phone.country_code` | Check the number and country code | | 400 | Product sold out | The product's stock is exhausted, or no licence key is left in stock | Restock the product or its licences | | 400 | Discount not applicable | Discount code inactive, expired, used up, reserved for another customer, or not valid for this product or price variant | Verify the discount code is active and applicable | | 400 | Store cannot sell | Your store is not currently allowed to receive orders | Contact Chariow support | | 400 | Payment could not start | The payment session could not be opened; the sale is marked as failed | Retry the checkout | | 401 | Unauthorised | Invalid or missing API key | Check your API key is correct and included in the `Authorization` header | | 404 | Product not found | Invalid product ID or unpublished product | Verify the product ID/slug exists and is published | | 404 | Discount code not found | No discount with this code in your store | Check the code | | 409 | Recipient already owns the product | Gift recipient already has access to the product | Choose another product or recipient | | 422 | Validation failed | Missing or invalid fields, unsupported `payment_currency`, unknown country code | Check all required fields are provided with correct formats | | 422 | Pay-what-you-want not supported | Product uses pay-what-you-want pricing | Redirect customers to your Chariow store or use the Snap Widget | | 422 | Product type not supported | Product is a Service or Coaching type | Redirect customers to your Chariow store or use the Snap Widget | | 422 | Gift for yourself | Gift recipient email equals the buyer's email | Use the recipient's own email | | 422 | Missing shipping address | Product requires shipping but the `shipping` fields are missing | Include `shipping.address`, `shipping.city`, `shipping.state`, `shipping.country` and `shipping.zip` | | 429 | Too many requests | Checkout rate limit exceeded | Retry after a short delay | Errors raised by business rules (`400`, `404`, `409`) return a `message` and an empty `errors` array. Validation errors (`422` with field errors) list each invalid field in `errors`. ### Example Error Response ```json theme={null} { "message": "The email field must be a valid email address.", "data": [], "errors": { "email": [ "The email field must be a valid email address." ], "phone.number": [ "The phone.number field is required." ] } } ``` Always check the `errors` object for field-specific validation messages to help users correct their input. ## Best Practices ### Handle All Response Steps Always check the `step` field and handle all possible states: ```javascript theme={null} const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify(checkoutData) }); const result = await response.json(); switch (result.data.step) { case 'payment': // Redirect to payment URL window.location.href = result.data.payment.checkout_url; break; case 'completed': // Show success message for free products showSuccessMessage(result.data.purchase); break; case 'already_purchased': // Inform customer they already own this product showAlreadyPurchasedMessage(result.data.message); break; } ``` ### Use Pulses for Sale Updates Don't rely solely on redirect URLs to track sale completion. Set up Pulses (webhooks) to receive reliable notifications: * Sale completed * Payment received * Refund processed See the [Pulses Guide](/en/guides/pulses) for setup instructions. ### Validate Before Checkout Reduce failed checkouts by validating data before calling the API: * Email format validation * Phone number format validation * Required field checks * Custom field validation ### Handle Network Errors Implement proper error handling for network issues: ```javascript theme={null} try { const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify(checkoutData) }); if (!response.ok) { const error = await response.json(); handleCheckoutError(error); return; } const data = await response.json(); handleCheckoutSuccess(data); } catch (error) { // Handle network errors console.error('Checkout failed:', error); showErrorMessage('Unable to process checkout. Please try again.'); } ``` ### Store Sale IDs Always store the returned sale ID (`purchase.id`) for: * Customer service inquiries * Refund processing * Access management * Analytics tracking ### Test with Different Scenarios Test your integration with: * Free products (immediate completion) * Paid products (payment flow) * Products with discount codes * Products with custom fields * Products that require a shipping address * Products with limited stock * Invalid product IDs * Invalid discount codes ## Next Steps Learn how to retrieve and manage sales Set up notifications for completed sales View the complete Checkout API reference # Customers Source: https://chariow.dev/en/guides/customers Learn how to manage and retrieve customer data via the Chariow API Customers are created automatically when they check out in your store, including through the Checkout API. Each customer is specific to your store and has their own profile with contact information, purchase history, and product access. Your store has **one customer per email address**. Emails are stored in lowercase and compared case-insensitively, so a buyer who types `John@Example.com` and later `john@example.com` is the same customer. Each new checkout with that email updates the customer's first name, last name and phone number. Customers that had been duplicated in the past were merged into the oldest record: its ID is kept, the sales of the duplicates now belong to it, and the IDs of the merged duplicates return `404`. ## Customer Object A customer object contains the following information: ```json theme={null} { "id": "cus_abc123xyz", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "avatar_url": "https://cdn.chariow.com/avatars/abc123.jpg", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.chariow.link" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-20T14:45:00+00:00" } ``` ### Customer Properties | Property | Type | Description | | - | - | - | | `id` | string | Unique customer identifier with `cus_` prefix | | `name` | string | Full name (combination of first and last name) | | `first_name` | string | Customer's first name | | `last_name` | string | Customer's last name | | `email` | string | Customer's email address | | `avatar_url` | string | URL to the customer's avatar image | | `phone` | object | Phone number with country information | | `store` | object | Store the customer belongs to | | `created_at` | string | ISO 8601 timestamp of when the customer was created | | `updated_at` | string | ISO 8601 timestamp of when the customer was last updated | ## Listing Customers Retrieve all customers for your store: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/customers" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/customers', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/customers', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) result = response.json() customers = result['data'] ``` ### Query Parameters | Parameter | Type | Description | | - | - | - | | `per_page` | integer | Number of customers per page (default: 10, from 1 to 100) | | `cursor` | string | Cursor for pagination (use `next_cursor` from previous response) | | `search` | string | Search by first name, last name, email or phone number | | `from` | string | Customers created on or after this date (Y-m-d format) | | `to` | string | Customers created on or before this date (Y-m-d format) | | `period` | string | Date range shortcut used instead of `from` and `to`: `today`, `yesterday`, `last7days`, `last30days`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear`, `lastYear` | `start_date` and `end_date` are not supported and are silently ignored, which returns customers of every date. Use `from` and `to`. ### Searching Customers Search for customers by first name, last name, email or phone number: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/customers?search=john" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Filtering by Date Range Retrieve customers created within a specific date range: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/customers?from=2025-01-01&to=2025-01-31" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Example Response ```json theme={null} { "data": [ { "id": "cus_abc123xyz", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "avatar_url": "https://cdn.chariow.com/avatars/abc123.jpg", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.chariow.link" }, "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-20T14:45:00+00:00" } ], "pagination": { "per_page": 10, "next_cursor": "eyJpZCI6NTB9", "prev_cursor": null, "has_more_pages": true } } ``` ## Getting a Single Customer Retrieve a specific customer by their public ID: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/customers/cus_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/customers/cus_abc123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); ``` ## Customer Lifecycle A customer record is created at their first checkout, before the payment is confirmed. A buyer who abandons the payment is therefore still listed as a customer. Each purchase is linked to the customer's profile. The customer receives access to their purchased products (downloads, courses, licenses). Customers can access the customer portal to view their purchases and downloads. ## Common Use Cases Sync customers to your CRM by fetching new customers using date filters: ```javascript theme={null} // Fetch customers created in the last 24 hours const today = new Date().toISOString().split('T')[0]; const yesterday = new Date(Date.now() - 86400000).toISOString().split('T')[0]; const response = await fetch( `https://api.chariow.com/v1/customers?from=${yesterday}&to=${today}`, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); const result = await response.json(); // Sync result.data to your CRM ``` Add customers to your email lists based on their purchases: ```javascript theme={null} // Get customer details for email list const response = await fetch( 'https://api.chariow.com/v1/customers/cus_abc123xyz', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); const result = await response.json(); await addToMailingList({ email: result.data.email, firstName: result.data.first_name, lastName: result.data.last_name, tags: ['customer', 'purchased'] }); ``` Look up a customer by email when they contact support: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/customers?search=customer@example.com" \ -H "Authorization: Bearer sk_live_your_api_key" ``` The search parameter matches against the first name, last name, email and phone number fields. Generate monthly customer acquisition reports using date filters: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/customers?from=2025-01-01&to=2025-01-31&per_page=100" \ -H "Authorization: Bearer sk_live_your_api_key" ``` This retrieves all customers created in January 2025. ## Related Resources View customer purchase history Manage customer licenses View the complete Customers API reference # Discounts Source: https://chariow.dev/en/guides/discounts Learn how to manage discount codes via the Chariow API Discounts allow you to offer promotional pricing to your customers. Create percentage or fixed-amount discounts with optional usage limits, expiration dates, product restrictions, and customer-specific codes. ## Discount Object A discount contains the following information: ```json theme={null} { "id": "dis_abc123", "name": "Summer Sale", "code": "SUMMER20", "type": "percentage", "status": "active", "value_off": { "raw": 20, "formatted": "20%" }, "products": [ { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "store_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "customer_email": null, "usage_limit": 100, "usage_limit_per_customer": 1, "usage_count": 45, "start_date": "2025-06-01T00:00:00+00:00", "end_date": "2025-08-31T23:59:59+00:00", "is_auto_generated": false, "created_at": "2025-05-15T10:00:00+00:00", "updated_at": "2025-06-20T15:30:00+00:00" } ``` ## Discount Types | Type | Description | Example | | - | - | - | | `percentage` | Percentage off the price | 20% off | | `fixed` | Fixed amount off | \$10 off | ## Discount Statuses | Status | Description | | - | - | | `active` | Discount is valid and can be used (within date range and under usage limit) | | `expired` | Discount has passed its end date or usage limit has been reached | ## Listing Discounts Retrieve all discounts for your store: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/discounts" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/discounts', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/discounts', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) discounts = response.json()['data'] ``` ### Query Parameters | Parameter | Type | Description | | - | - | - | | `per_page` | integer | Number of discounts per page (max 100, default 10) | | `cursor` | string | Pagination cursor from previous response | | `status` | string | Filter by status (`active`, `expired`) | | `search` | string | Search by discount code, name, or public ID | | `from` | string | Only discounts created on or after this date (Y-m-d format). Send it with `to` | | `to` | string | Only discounts created on or before this date (Y-m-d format). Send it with `from` | | `period` | string | Preset creation date range used instead of `from` and `to`: `today`, `yesterday`, `last7days`, `last30days`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear`, `lastYear` | ### Filtering Examples ```bash theme={null} # Get active discounts only curl -X GET "https://api.chariow.com/v1/discounts?status=active" \ -H "Authorization: Bearer sk_live_your_api_key" # Search for a specific code or name curl -X GET "https://api.chariow.com/v1/discounts?search=SUMMER" \ -H "Authorization: Bearer sk_live_your_api_key" # Filter by date range curl -X GET "https://api.chariow.com/v1/discounts?from=2025-01-01&to=2025-01-31" \ -H "Authorization: Bearer sk_live_your_api_key" # Combine multiple filters curl -X GET "https://api.chariow.com/v1/discounts?status=active&search=VIP&per_page=50" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Example Response ```json theme={null} { "data": [ { "id": "dis_abc123", "name": "Summer Sale", "code": "SUMMER20", "type": "percentage", "status": "active", "value_off": { "raw": 20, "formatted": "20%" }, "products": [ { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "store_xyz789", "name": "My Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "customer_email": null, "usage_limit": 100, "usage_limit_per_customer": 1, "usage_count": 45, "start_date": "2025-06-01T00:00:00+00:00", "end_date": "2025-08-31T23:59:59+00:00", "is_auto_generated": false, "created_at": "2025-05-15T10:00:00+00:00", "updated_at": "2025-06-20T15:30:00+00:00" } ], "pagination": { "count": 1, "path": "https://api.chariow.com/v1/discounts", "per_page": 10, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ## Getting a Single Discount Retrieve a specific discount by its public ID: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/discounts/dis_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/discounts/dis_abc123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ## Applying Discounts at Checkout Use a discount code when initiating checkout: ```bash theme={null} curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prd_abc123", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" }, "discount_code": "SUMMER20" }' ``` ## Discount Restrictions Discounts can have various restrictions: Limit how many times a discount can be used: ```json theme={null} { "usage_limit": 100, "usage_limit_per_customer": 1, "usage_count": 45 } ``` When `usage_count` reaches `usage_limit`, the discount is rejected at checkout. `usage_limit_per_customer` caps the successful uses by a single customer email. Set start and end dates for the discount: ```json theme={null} { "start_date": "2025-06-01T00:00:00+00:00", "end_date": "2025-08-31T23:59:59+00:00" } ``` The discount is only valid between these dates. Limit the discount to specific products: ```json theme={null} { "products": [ { "id": "prd_abc123", "name": "Course A" }, { "id": "prd_def456", "name": "Course B" } ] } ``` If `products` is empty, the discount applies to all products. Limit the discount to a specific customer: ```json theme={null} { "customer_email": "vip@example.com" } ``` Only the specified customer can use this discount. ## Discount Validation When applying a discount at checkout, it's automatically validated against these criteria: 1. **Status** - Must be `active` 2. **Date range** - Current date must be within `start_date` and `end_date` (if specified) 3. **Usage limit** - `usage_count` must not have reached `usage_limit` (if specified) 4. **Per-customer limit** - The customer must not have reached `usage_limit_per_customer` successful uses (if specified) 5. **Product eligibility** - Product must be in the `products` array (if not empty, applies to all products) 6. **Customer eligibility** - Customer email must match `customer_email` (if specified) 7. **Fixed amount** - A `fixed` discount cannot exceed the product's current price The discount status changes to `expired` once its `end_date` has passed (a scheduled task updates it). A discount that has reached its usage limit, or whose `start_date` is still in the future, keeps its `active` status but is rejected at checkout. If validation fails during checkout, the API will return an appropriate error message. ## Common Use Cases Track discount performance for marketing campaigns: ```javascript theme={null} const discounts = await getDiscounts({ status: 'active' }); const campaignStats = discounts.map(d => ({ code: d.code, uses: d.usage_count, remaining: d.usage_limit - d.usage_count, conversionRate: (d.usage_count / d.usage_limit * 100).toFixed(1) + '%' })); ``` Create unique discount codes for affiliates and track usage: ```javascript theme={null} // Fetch discount by public ID const response = await fetch('https://api.chariow.com/v1/discounts/dis_affiliate123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data: discount } = await response.json(); console.log(`Affiliate code ${discount.code} has been used ${discount.usage_count} times`); ``` Create single-use discounts for VIP customers: ```json theme={null} { "code": "VIP_CUSTOMER_ABC", "customer_email": "vip@example.com", "usage_limit": 1 } ``` ## Related Resources Apply discounts during checkout View the complete Discounts API reference # Licenses Source: https://chariow.dev/en/guides/licenses Learn how to manage software licenses via the Chariow API Chariow provides built-in license key management for software products. Licenses are automatically generated when customers purchase license-type products and can be activated, validated, and revoked through the API. ## License Object A license contains comprehensive information about its status, activation history, and validity: ```json theme={null} { "id": "license_abc123", "status": "active", "customer": { "id": "cus_xyz789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "john@example.com", "phone": null, "avatar_url": null }, "product": { "id": "prd_abc456", "name": "Premium Software License", "type": "license", "pictures": { "thumbnail": null, "cover": null }, "category": { "value": "technology", "label": "Technology" }, "pricing": { "type": "one_time", "price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "effective": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" } }, "bundle": null, "metadata": null }, "license": { "key": "ABC-123-XYZ-789", "masked_key": "ABC-***-***-789" }, "is_active": true, "is_expired": false, "can_activate": true, "activations": { "count": 3, "max": 10, "remaining": 7 }, "certificate_url": "https://download.chariow.com/licenses/license_abc123?expires=1736937000&signature=4f1c...", "metadata": null, "activated_at": "2025-01-15T10:30:00.000000Z", "expires_at": "2026-01-15T10:30:00.000000Z", "expired_at": null, "revoked_at": null, "created_at": "2025-01-15T09:00:00.000000Z", "updated_at": "2025-01-15T10:30:00.000000Z" } ``` ### Key Fields * **`license.key`**: The unique license key string (e.g., `ABC-123-XYZ-789`) * **`license.masked_key`**: Masked version for display (e.g., `ABC-***-***-789`) * **`status`**: Current license status (see table below) * **`is_active`**: Boolean indicating if the license is currently active and usable * **`is_expired`**: Boolean indicating if the license has expired * **`can_activate`**: Boolean indicating if the license can be activated (has remaining slots) * **`activations.count`**: Current number of device activations * **`activations.max`**: Maximum allowed activations * **`activations.remaining`**: Number of activation slots remaining * **`certificate_url`**: Signed URL to download the license certificate. It expires 30 minutes after the response, so fetch the license again for a fresh link * **`activated_at`**: When the license was first activated (null if never activated) * **`expires_at`**: When the license will expire (null for lifetime licenses) * **`revoked_at`**: When the license was revoked (null if not revoked) ## License Statuses | Status | Description | | - | - | | `pending_activation` | License created but not yet activated | | `active` | License is activated and valid for use | | `expired` | License has passed its expiration date | | `revoked` | License has been permanently revoked | ## Listing Licenses Retrieve all issued licenses for your store: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/licenses" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/licenses', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ### Query Parameters | Parameter | Type | Description | | - | - | - | | `per_page` | integer | Number of licenses per page (default 10, max 100) | | `cursor` | string | Pagination cursor from previous response | | `status` | string | Filter by status (`pending_activation`, `active`, `expired`, `revoked`) | | `product_id` | string | Filter by product public ID (e.g., `prd_def456`) | | `search` | string | Search by license key | There is no customer filter: filter the results on `customer.id` on your side. ### Filtering Examples ```bash theme={null} # Get active licenses only curl -X GET "https://api.chariow.com/v1/licenses?status=active" \ -H "Authorization: Bearer sk_live_your_api_key" # Get licenses for a specific product curl -X GET "https://api.chariow.com/v1/licenses?product_id=prd_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" # Find a license by its key curl -X GET "https://api.chariow.com/v1/licenses?search=ABC-123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ## Getting a License by Key Retrieve a specific license using its license key (the license public ID, such as `license_abc123`, also works): ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/licenses/ABC-123-XYZ-789', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const { data } = await response.json(); ``` ## Validating a License To validate a license in your application, retrieve it and check the status: ```javascript theme={null} async function validateLicense(licenseKey) { const response = await fetch( `https://api.chariow.com/v1/licenses/${licenseKey}`, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); if (!response.ok) { return { valid: false, reason: 'License not found' }; } const { data } = await response.json(); if (!data.is_active) { return { valid: false, reason: 'License is not active' }; } if (data.is_expired) { return { valid: false, reason: 'License has expired' }; } return { valid: true, license: data }; } ``` ## Activating a License Activate a license on a device. The system automatically captures IP address and user agent: ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activate" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "device_identifier": "00:1B:44:11:3A:B7" }' ``` ```javascript JavaScript theme={null} const response = await fetch( 'https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activate', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ device_identifier: '00:1B:44:11:3A:B7' // MAC address, UUID, etc. }) } ); ``` ### First Activation Behaviour On the first activation: * Status changes from `pending_activation` to `active` * `activated_at` timestamp is set * `expires_at` is calculated based on product validity period * `activation_count` increments to 1 ### Subsequent Activations On additional activations: * `activation_count` is incremented * A new activation record is created * License status remains `active` ### Licences That Need No Activation A product can be configured so that its licences never require an activation call. Set `requires_activation` to `false` in the product's licence settings from your Chariow dashboard. This is the mode for SaaS products and services that police their own devices and have no reason to call back into Chariow. From then on, every licence the product issues: * is created **already active** β€” the status is `active`, never `pending_activation`; * has `activated_at` stamped at issuance; * starts its validity period at issuance, so `expires_at` is computed from the purchase date rather than from a first activation; * emits both the `license.issued` and the `license.activated` Pulse events at once. Licences issued **before** the setting was turned off keep their current state. One that is still `pending_activation` can be activated as usual. Calling the activation endpoint on a licence that is already active under this mode returns `400`: ```json theme={null} { "message": "This license does not require activation and is already active.", "errors": [] } ``` Validate such licences with `GET /v1/licenses/{licenseKey}` instead of activating them. ### Activation Limits Each license has a maximum number of activations (`max_activations`). When the limit is reached, further activations will fail: ```json theme={null} { "message": "Activation limit reached", "errors": [] } ``` Check `can_activate` and `activations.remaining` before attempting activation. ## Revoking a License Revoke a license to prevent further use: ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/revoke" \ -H "Authorization: Bearer sk_live_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "reason": "Customer requested refund" }' ``` ```javascript JavaScript theme={null} const response = await fetch( 'https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/revoke', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ reason: 'Customer requested refund' }) } ); ``` Revoking a license is permanent. The license cannot be reactivated after revocation. The optional `reason` (500 characters at most) is validated but not stored: it is not returned by the API or included in the `license.revoked` Pulse event. ## Getting Activation History View all activations for a specific license with detailed device tracking: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activations?per_page=20" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Response ```json theme={null} { "data": [ { "id": "V1StGXR8Z5jd", "activated_by": { "ip": { "value": "203.0.113.45", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } }, "user_agent": { "is_desktop": true, "is_robot": false, "platform": "OS X", "browser": "Chrome", "version": "120.0.0.0", "device": "Macintosh", "is_mobile": false, "is_phone": false, "is_tablet": false, "is_ios": false, "is_android": false }, "device": "00:1B:44:11:3A:B7" }, "metadata": null, "activated_at": "2025-01-18T15:42:00.000000Z", "created_at": "2025-01-18T15:42:00.000000Z" }, { "id": "Uakgb2KQ9xLm", "activated_by": { "ip": { "value": "198.51.100.12", "country": null }, "user_agent": null, "device": null }, "metadata": null, "activated_at": "2025-01-16T09:15:00.000000Z", "created_at": "2025-01-16T09:15:00.000000Z" } ], "pagination": { "count": 2, "path": "https://api.chariow.com/v1/licenses/ABC-123-XYZ-789/activations", "per_page": 20, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ### What's Tracked Each activation record contains: * **IP Address**: Automatically captured from the activation request, with geolocation * **User Agent**: Parsed browser, platform and device information (`null` when the request sent no user agent) * **Device Identifier**: Optional identifier you provide (MAC address, UUID, etc.) * **Timestamp**: When the activation occurred * **Metadata**: Optional custom data This is useful for: * Auditing license usage * Detecting suspicious activity * Providing customers with device management * Debugging activation issues ## Implementation Example Here's a complete example of license validation in a desktop application: ```javascript theme={null} class LicenseManager { constructor(apiKey) { this.apiKey = apiKey; this.baseUrl = 'https://api.chariow.com/v1'; } async validate(licenseKey) { const response = await fetch( `${this.baseUrl}/licenses/${licenseKey}`, { headers: { 'Authorization': `Bearer ${this.apiKey}` }} ); if (!response.ok) { throw new Error('Invalid license key'); } const { data } = await response.json(); if (!data.can_activate) { throw new Error('License cannot be activated'); } return data; } async activate(licenseKey, deviceId) { const response = await fetch( `${this.baseUrl}/licenses/${licenseKey}/activate`, { method: 'POST', headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ device_identifier: deviceId }) } ); if (!response.ok) { const error = await response.json(); throw new Error(error.message); } return response.json(); } } // Usage const manager = new LicenseManager('sk_live_your_api_key'); try { const license = await manager.validate('ABC-123-XYZ-789'); console.log('License valid:', license.is_active); await manager.activate('ABC-123-XYZ-789', getDeviceId()); console.log('License activated successfully'); } catch (error) { console.error('License error:', error.message); } ``` ## API Endpoints Summary | Endpoint | Method | Description | | - | - | - | | `/v1/licenses` | GET | List all licenses with filtering | | `/v1/licenses/{licenseKey}` | GET | Get specific license details | | `/v1/licenses/{licenseKey}/activate` | POST | Activate license on a device | | `/v1/licenses/{licenseKey}/revoke` | POST | Permanently revoke a license | | `/v1/licenses/{licenseKey}/activations` | GET | Get activation history | ## Best Practices ### Security * Never expose your API key in client-side code * Use API keys server-side only * Validate licenses server-side before granting access * Store license keys securely on the customer's device ### Device Identification * Use unique, persistent device identifiers (MAC address, hardware UUID) * Don't use user-changeable identifiers (computer name, username) * Consider platform-specific identifiers (Windows: machine GUID, macOS: hardware UUID) ### Activation Management * Check `can_activate` before attempting activation * Display `activations.remaining` to users * Implement device management UI for customers * Handle activation errors gracefully ### Validation Frequency * Validate on application startup * Re-validate periodically (e.g., every 24 hours) * Cache validation results locally * Implement offline grace period ### Error Handling * Handle network errors gracefully * Provide clear error messages to users * Implement retry logic with exponential backoff * Log activation attempts for debugging ## Related Resources Create license-type products View the complete Licenses API reference Retrieve license details Activate on a device # Products Source: https://chariow.dev/en/guides/products Learn how to retrieve and work with products via the Chariow API Products are the core of your Chariow store. This guide covers how to retrieve and work with products through the Public API. ## Product Types Chariow supports several product types: | Type | Description | | - | - | | `downloadable` | Digital files that customers can download after purchase | | `course` | Online courses with structured chapters and lessons | | `license` | Software licenses with activation and validation management | | `service` | Digital services, consultations, or custom work | | `bundle` | A collection of multiple products sold together at a discounted price | | `coaching` | Coaching or mentoring sessions | A creator can change the type of a product that has never been sold. Do not treat `type` as permanent if you cache products. ## Product Categories Products are organised into the following categories: | Category | Value | | - | - | | Creative Arts | `creative_arts` | | Technology | `technology` | | Business and Finance | `business_and_finance` | | Personal Development | `personal_development` | | Education and Learning | `education_and_learning` | | Entertainment | `entertainment` | | Health and Wellness | `health_and_wellness` | | Literature and Publishing | `literature_and_publishing` | | Media and Communication | `media_and_communication` | | Miscellaneous | `miscellaneous` | ## Product States Products can be in different states: * **Draft** (`draft`): not visible to customers, still being edited * **Published** (`published`): available for purchase on your store * **Suspended** (`suspended`): suspended and not available for purchase The Public API returns your products **whatever their status**, drafts included. Check `status` and only show products whose status is `published` to buyers. ## Listing Products Retrieve the products of your store, newest first, with optional filtering: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/products?per_page=20&type=course" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/products?per_page=20&type=course', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); console.log(result.data); // Array of products ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/products', params={'per_page': 20, 'type': 'course'}, headers={'Authorization': 'Bearer sk_live_your_api_key'} ) products = response.json()['data'] ``` ### Query Parameters | Parameter | Type | Description | | - | - | - | | `per_page` | integer | Number of products per page (default: 10, max: 100) | | `cursor` | string | Pagination cursor from previous response | | `search` | string | Search by public ID, name, slug, category or type | | `category` | string | Filter by category (e.g., `technology`, `education_and_learning`) | | `type` | string | Filter by type (e.g., `course`, `license`, `bundle`) | ### Pagination The API uses cursor-based pagination for efficient data retrieval: ```javascript theme={null} let allProducts = []; let cursor = null; do { const url = cursor ? `https://api.chariow.com/v1/products?cursor=${cursor}` : 'https://api.chariow.com/v1/products'; const response = await fetch(url, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); allProducts.push(...result.data); cursor = result.pagination.next_cursor; } while (cursor); console.log(`Retrieved ${allProducts.length} products`); ``` ### Example Response ```json theme={null} { "data": [ { "id": "prd_abc123", "name": "Complete Web Development Course", "slug": "web-development-course", "description": "A comprehensive course covering modern web development...", "type": "course", "category": { "value": "education_and_learning", "label": "Education and Learning" }, "status": "published", "is_free": false, "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "current_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "sale_price": null, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": null, "tracking": { "currency": "USD", "value": 99 } }, "has_variant_pricing": false, "quantity": null, "settings": { "is_shipping_address_required": false }, "rating": { "total_ratings": { "value": 245, "formatted": "245", "short": "245", "short_plus": "245+" }, "thumbs_up_count": 236, "thumbs_up_percentage": "96%" }, "on_sale_until": null, "sales_count": { "value": 1250, "formatted": "1,250", "short": "1K", "short_plus": "1K+" }, "seo": null, "custom_cta_text": { "value": null, "label": null }, "fields": null, "store": null, "bundle": null, "coaching": null } ], "pagination": { "count": 20, "path": "https://api.chariow.com/v1/products", "per_page": 20, "next_cursor": "eyJpZCI6NTB9", "next_page_url": "https://api.chariow.com/v1/products?cursor=eyJpZCI6NTB9", "prev_cursor": null, "prev_page_url": null, "has_more_pages": true, "has_pages": true } } ``` ## Getting a Single Product Retrieve detailed information about a specific product by its public ID or slug: ```bash cURL (by ID) theme={null} curl -X GET "https://api.chariow.com/v1/products/prd_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```bash cURL (by slug) theme={null} curl -X GET "https://api.chariow.com/v1/products/web-development-course" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} // By public ID const response = await fetch('https://api.chariow.com/v1/products/prd_abc123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const product = (await response.json()).data; console.log(product.name, product.pricing); ``` ```python Python theme={null} import requests # By public ID response = requests.get( 'https://api.chariow.com/v1/products/prd_abc123', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) product = response.json()['data'] ``` ### Product Details The single product endpoint returns comprehensive information including: * **Pricing**: Current price, base price, effective price, sale price (if applicable), minimum price, suggested price, and discount percentage (`price_off`) * **Images**: Thumbnail and cover images via `pictures` * **Category**: Product category with value and label * **Variant Pricing**: Whether the product has variant pricing (`has_variant_pricing`) * **Ad tracking price**: The current price converted to USD via `pricing.tracking`, for ad trackers such as the Meta Pixel * **Ratings**: Number of ratings and share of positive ratings via `rating` * **Sales**: Exact sales count via `sales_count`, or `null` when the product hides it (new products hide it by default) * **Quantity**: Exact stock information (if product has limited quantity) * **Settings**: Product settings such as `is_shipping_address_required` * **Sale Expiration**: `on_sale_until` datetime for temporary sale pricing * **Custom CTA Text**: Custom call-to-action text via `custom_cta_text` * **Bundle**: Savings information for bundle products * **Coaching**: Session duration, format, time zone and buffer for coaching products via `coaching` * **Description**: `description` is HTML, sanitised by Chariow to strip unsafe markup The `fields`, `seo` and `store` keys are present but always `null` on the public API. ## Pricing Types Products can have different pricing models: A fixed price that customers pay once to access the product. This is the most common pricing type. ```json theme={null} { "pricing": { "type": "one_time", "price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "current_price": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "effective": { "value": 49, "formatted": "$49.00", "short": "49", "currency": "USD" }, "sale_price": null, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": null } } ``` Customers choose how much to pay, with an optional minimum and suggested price. Useful for donations, tip-ware, or customer-driven pricing. ```json theme={null} { "pricing": { "type": "what_you_want", "price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "current_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "effective": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "sale_price": null, "minimum_price": { "value": 5, "formatted": "$5.00", "short": "5", "currency": "USD" }, "suggested_price": { "value": 25, "formatted": "$25.00", "short": "25", "currency": "USD" }, "price_off": null } } ``` Products available at no cost, often used for lead generation, freebies, or sample content. ```json theme={null} { "pricing": { "type": "free", "price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "current_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "effective": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "sale_price": null, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": null }, "is_free": true } ``` Products can have temporary sale prices with an expiration date. The `current_price` reflects the active price. ```json theme={null} { "pricing": { "type": "one_time", "price": { "value": 149, "formatted": "$149.00", "short": "149", "currency": "USD" }, "current_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "sale_price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": "34%" }, "on_sale_until": "2025-02-28T23:59:59Z" } ``` ## Product Bundles Bundles combine multiple products at a discounted price. When retrieving a bundle product, you'll receive information about the total bundle value and savings: ```json theme={null} { "id": "prd_bundle123", "name": "Complete Developer Bundle", "slug": "developer-bundle", "type": "bundle", "pricing": { "type": "one_time", "price": { "value": 199, "formatted": "$199.00", "short": "199", "currency": "USD" }, "current_price": { "value": 199, "formatted": "$199.00", "short": "199", "currency": "USD" }, "effective": { "value": 199, "formatted": "$199.00", "short": "199", "currency": "USD" }, "sale_price": null, "minimum_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "suggested_price": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "price_off": null }, "bundle": { "value": { "value": 297, "formatted": "$297.00", "short": "297", "currency": "USD" }, "savings": { "amount": { "value": 98, "formatted": "$98.00", "short": "98", "currency": "USD" }, "percentage": { "value": 33, "formatted": "33%" } } } } ``` The `bundle.value` shows the total value if all products were purchased separately, whilst the `pricing.current_price` shows the discounted bundle price. The `bundle.savings` shows how much customers save by purchasing the bundle. ## Working with Product Data ### Filtering Products You can combine multiple filters to refine your product queries: ```javascript theme={null} // Get all free courses const response = await fetch( 'https://api.chariow.com/v1/products?type=course&category=education_and_learning', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } } ); // Search for products const searchResponse = await fetch( 'https://api.chariow.com/v1/products?search=web+development', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } } ); ``` ### Understanding Ratings Buyers rate a product with a thumbs up or down. Products include the number of ratings and the share of positive ones: ```json theme={null} { "rating": { "total_ratings": { "value": 245, "formatted": "245", "short": "245", "short_plus": "245+" }, "thumbs_up_count": 236, "thumbs_up_percentage": "96%" } } ``` * **total\_ratings**: Number of ratings received, with formatted and abbreviated versions * **thumbs\_up\_count**: Number of positive ratings * **thumbs\_up\_percentage**: Share of positive ratings, as a string (e.g., `96%`) ### Stock Quantity For products with limited stock, the `quantity` field provides the exact stock of the product (percentages are whole numbers): ```json theme={null} { "quantity": { "value": 100, "remaining": { "value": 35, "percent": 35 }, "sold": { "value": 65, "percent": 65 }, "total": 100 } } ``` Products without limited stock will have `quantity: null`. ### Price Formatting All price objects include four fields for flexible display: * **value**: Numeric amount (e.g., `99` for \$99.00) * **formatted**: Ready-to-display string (e.g., `$99.00`, `Β£99.00`, `€99.00`) * **short**: Abbreviated human-readable string using `forHumans` (e.g., `99`, `5K`, `1.25M`) * **currency**: ISO currency code (e.g., `USD`, `EUR`, `GBP`) ```javascript theme={null} // Using the formatted price const product = response.data; console.log(`Buy now for ${product.pricing.current_price.formatted}`); const price = product.pricing.current_price.value; if (price < 50) { console.log('Affordable option!'); } ``` ## Common Use Cases ### Building a Product Catalogue ```javascript theme={null} async function buildProductCatalogue(category) { const products = []; let cursor = null; do { const params = new URLSearchParams({ per_page: 50, category: category, ...(cursor && { cursor }) }); const response = await fetch( `https://api.chariow.com/v1/products?${params}`, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } } ); const result = await response.json(); products.push(...result.data.filter(product => product.status === 'published')); cursor = result.pagination.next_cursor; } while (cursor); return products; } // Get all technology products const techProducts = await buildProductCatalogue('technology'); ``` ### Displaying Sale Products ```javascript theme={null} async function getSaleProducts() { const response = await fetch('https://api.chariow.com/v1/products?per_page=100', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); // Filter products currently on sale return result.data.filter(product => product.pricing.sale_price !== null && product.on_sale_until && new Date(product.on_sale_until) > new Date() ); } ``` ### Finding Popular Products ```javascript theme={null} async function getPopularProducts(minPositiveShare = 90, minRatings = 50) { const response = await fetch('https://api.chariow.com/v1/products?per_page=100', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); return result.data .filter(p => p.status === 'published') .filter(p => parseFloat(p.rating.thumbs_up_percentage) >= minPositiveShare && p.rating.total_ratings.value >= minRatings) .sort((a, b) => parseFloat(b.rating.thumbs_up_percentage) - parseFloat(a.rating.thumbs_up_percentage)); } ``` ## Best Practices Always use cursor-based pagination instead of fetching all products at once. This ensures efficient data retrieval and prevents timeouts. Product data doesn't change frequently. Consider caching products locally and refreshing periodically to reduce API calls. Not all products have thumbnail or cover images. Always check for `null` values before displaying images. Use the `formatted` field from price objects for display purposes. This ensures proper currency formatting and symbols. When displaying sale prices, verify that `on_sale_until` is in the future to avoid showing expired sales. ## Next Steps View the List Products API reference View the Get Product API reference Learn how to create checkout sessions Learn about API authentication # Pulse Security Source: https://chariow.dev/en/guides/pulse-security Verify that a Pulse genuinely came from Chariow, and deduplicate retries safely Every Pulse Chariow sends is signed with a secret that belongs to that Pulse alone. Verifying that signature is the only way to know a request on your endpoint genuinely originates from Chariow β€” your endpoint URL is public, so anyone who discovers it can post to it. This page is the complete signing contract. Implement it once and you can trust every payload you receive. ## Request headers Each delivery carries these headers: | Header | Contents | | - | - | | `x-chariow-signature` | `sha256=` β€” the signature to verify | | `x-pulse-id` | The Pulse identifier, e.g. `pulse_abc123` | | `x-pulse-delivery-id` | The delivery identifier β€” **your idempotency key** | | `x-pulse-event` | The event name, e.g. `successful.sale` | | `Content-Type` | `application/json; charset=utf-8` | | `User-Agent` | `Pulse \| Chariow +https://chariow.com` | Every delivery carries all four `x-pulse-*` headers, including test events sent from the dashboard and `affiliate.joined` events. Test events are recorded as deliveries like any other, and their payload contains an extra `note` field. ## The signing secret Each Pulse has its own signing secret, prefixed `whsec_`, generated by Chariow when the Pulse is created. The signing secret is **not** your API key, and it is not derived from your API key, your store identifier, or any other integration credential. It is an independent value. Using anything else to compute the HMAC will never produce a matching signature. To retrieve it: **Automations β†’ Pulses β†’ select your Pulse β†’ Overview tab β†’ Signing secret**. It is masked by default; use *Reveal*, *Copy* and *Rotate* on that block. The secret is encrypted at rest and never appears in API listings or request logs β€” those expose only a masked form such as `whsec_β€’β€’β€’β€’a1b2`. The plaintext value is returned only on an explicit reveal. ### Rotating the secret Rotation takes effect immediately and cannot be undone: the previous secret stops working the moment you rotate. Update your endpoint configuration in the same window. Deliveries dispatched before the rotation keep the signature computed with the previous secret, so adopt the new secret before replaying old deliveries. ## Signature scheme | Property | Value | | - | - | | Algorithm | HMAC-SHA256 | | Header | `x-chariow-signature` | | Format | `sha256=<64 lowercase hex characters>` | | Signed data | The raw HTTP body bytes, exactly as received | | Key | The Pulse signing secret (`whsec_...`) | | Timestamp | None, by design | ``` signature = "sha256=" + hex( hmac_sha256( raw_request_body, pulse_secret ) ) ``` **Only the raw body is signed.** The HTTP method, the URL, the headers, `x-pulse-id`, `x-pulse-delivery-id` and any timestamp are all excluded from the computation. ### Body encoding The body is compact UTF-8 JSON: * no indentation whitespace and no newlines; * forward slashes are escaped β€” `https:\/\/example.com`; * non-ASCII characters are escaped as `\uXXXX`, so the transmitted body is ASCII in practice; * key order is the order in the transmitted body. Never re-serialise the parsed payload. `JSON.stringify(req.body)` or `json.dumps(payload)` will not reproduce these bytes β€” the escaped forward slashes alone are enough to break the digest. Capture the raw body **before** any JSON parsing. ### Comparing the signature Strip the `sha256=` prefix and compare against the bare hex digest, or rebuild `"sha256=" + digest` and compare the whole string. Either works as long as you are consistent. Always compare in constant time (`crypto.timingSafeEqual`, `hash_equals`, `hmac.compare_digest`) and check that both values have the same length first β€” `timingSafeEqual` throws on buffers of different sizes. The prefix identifies the algorithm so the scheme can evolve without breaking existing receivers. Treat any value that does not start with `sha256=` as a scheme you do not yet support. Reject any request without a valid `x-chariow-signature` header with a `401`. ## Verification examples ```javascript Node.js / Express theme={null} const crypto = require('crypto'); app.post('/webhooks/chariow', express.raw({ type: 'application/json' }), (req, res) => { const received = req.header('x-chariow-signature') ?? ''; const expected = 'sha256=' + crypto .createHmac('sha256', process.env.CHARIOW_PULSE_SECRET) .update(req.body) // raw Buffer, never a re-serialised object .digest('hex'); const a = Buffer.from(received); const b = Buffer.from(expected); if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) { return res.status(401).send('Invalid signature'); } const deliveryId = req.header('x-pulse-delivery-id'); if (alreadyProcessed(deliveryId)) { return res.status(200).send('OK'); } res.status(200).send('OK'); enqueue(deliveryId, JSON.parse(req.body.toString('utf8'))); } ); ``` ```php PHP theme={null} ## Idempotency and replay protection The signature carries no timestamp, and that is deliberate. It is computed once when the delivery is dispatched and reused unchanged by every retry. A time window would wrongly reject a legitimately delayed retry β€” the last attempt of a delivery can land nearly three hours after the first. Replay protection is handled by `x-pulse-delivery-id` instead. That identifier is stable across every attempt of the same delivery, which makes it a ready-made idempotency key: 1. Read `x-pulse-delivery-id`. 2. If you have already processed it, return `200` and stop. 3. Otherwise persist it, return `200`, and process asynchronously. Deduplicate on `x-pulse-delivery-id`, not on the entity identifier inside the payload. A single sale can legitimately produce several deliveries β€” one per subscribed Pulse, plus any manual replay you trigger yourself. A manually replayed delivery is a new delivery with its own `x-pulse-delivery-id`, so it will pass your idempotency check and be processed again. That is the intended behaviour: replay exists to let you reprocess an event your endpoint missed. ## Troubleshooting a signature mismatch | Symptom | Likely cause | | - | - | | No representation of the digest ever matches | Wrong secret β€” an API key or a store identifier instead of the Pulse `whsec_...` secret | | Matches sometimes, fails on payloads with URLs or accented characters | The payload was re-serialised instead of hashed raw; escaped forward slashes or `\uXXXX` sequences were lost | | Every signature fails since a recent change | The secret was rotated; the endpoint is still using the old value | | Comparison throws instead of returning false | `timingSafeEqual` on buffers of different lengths β€” the `sha256=` prefix was stripped on one side only | | Signature verifies, but you process the same event twice | Missing deduplication on `x-pulse-delivery-id` | Use the **Deliveries** tab on the Pulse detail page to replay a real delivery while you debug. It shows the exact payload sent and the exact response your endpoint returned, which is far more useful than a test event for validating verification end to end. ## Related resources Events, payloads, delivery history and retries Security and reliability recommendations # Pulses Source: https://chariow.dev/en/guides/pulses Receive real-time notifications about events in your Chariow store Pulses are webhook notifications that allow you to receive real-time HTTP POST requests when specific events occur in your Chariow store. Instead of constantly polling the API, Pulses push event data to your configured endpoint URL as soon as something happens, enabling you to build responsive integrations and automations. ## How Pulses Work An event happens in your store (e.g., a sale is completed). Chariow sends a signed HTTP POST request to your configured endpoint. Your server checks the `x-chariow-signature` header before trusting the payload. Your server deduplicates on `x-pulse-delivery-id` and processes the payload. Your server returns a 2xx status code to confirm receipt. Your endpoint URL is public, so anyone who discovers it can post to it. Always verify the signature before acting on a payload β€” see [Pulse Security](/en/guides/pulse-security). ## Request Headers Every delivery carries these headers: | Header | Contents | | - | - | | `x-chariow-signature` | `sha256=` β€” HMAC-SHA256 of the raw body | | `x-pulse-id` | The Pulse identifier, e.g. `pulse_abc123` | | `x-pulse-delivery-id` | The delivery identifier β€” your idempotency key | | `x-pulse-event` | The event name, e.g. `successful.sale` | | `Content-Type` | `application/json; charset=utf-8` | | `User-Agent` | `Pulse \| Chariow +https://chariow.com` | Full signing contract, verification snippets and troubleshooting: [Pulse Security](/en/guides/pulse-security). ## Setting Up Pulses You can configure Pulses in several ways: ### Via Store Dashboard 1. Go to **Automation** β†’ **Pulses** 2. Click **Add Pulse** 3. Enter your webhook endpoint URL (must be HTTPS) 4. Select the events you want to receive 5. Optionally select specific products (leave empty for all products) 6. Save your Pulse Your Pulse endpoint must be accessible via HTTPS. HTTP endpoints are not supported for security reasons. ## Pulse Events Pulses support the following events. When an event fires, the webhook payload contains an `event` field with the event value. ### Sale Events | Event Value | Label | Description | | - | - | - | | `successful.sale` | Successful Sale | Triggers when a sale is completed | | `abandoned.sale` | Abandoned Sale | Triggers when a sale is abandoned | | `failed.sale` | Failed Sale | Triggers when a sale fails | ### License Events | Event Value | Label | Description | | - | - | - | | `license.activated` | License Activated | Triggers when a license is activated | | `license.expired` | License Expired | Triggers when a license expires | | `license.issued` | License Issued | Triggers when a license is issued to a customer | | `license.nearing_expiry` | License Nearing Expiry | Triggers when a license is approaching its expiry date | | `license.revoked` | License Revoked | Triggers when a license is revoked | ### Affiliate Events | Event Value | Label | Description | | - | - | - | | `affiliate.joined` | Affiliate Joined | Triggers when a new affiliate joins your store | `affiliate.joined` is a store-wide event. It reaches every enabled Pulse subscribed to it, including a Pulse limited to specific products: the product filter only narrows sale and licence events. You can configure multiple events for a single Pulse URL. When any of the selected events occur, Chariow will send a webhook notification to your endpoint with the corresponding event value. ## Pulse Payload When a configured event occurs, Chariow sends an HTTP POST request to your webhook URL with event data in the request body. The exact payload structure depends on the event type. Pulse payloads contain comprehensive event data, including details about the entity (sale, license, etc.), customer information, product details, and store context. The payload structure varies by event type to provide relevant information for each event. ### Successful Sale Example When a successful sale occurs, Chariow sends a webhook with the `successful.sale` event: ```json theme={null} { "event": "successful.sale", "sale": { "id": "sal_xyz789abc", "amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "discount_amount": { "value": 0, "formatted": "$0.00", "short": "0", "currency": "USD" }, "settlement": { "amount": { "value": 89.10, "formatted": "$89.10", "short": "89", "currency": "USD" }, "due_at": "2025-01-22T10:30:00+00:00", "done_at": null, "service_fee": { "value": 4.95, "formatted": "$4.95", "short": "5", "currency": "USD" }, "payment_fee": { "value": 4.95, "formatted": "$4.95", "short": "5", "currency": "USD" }, "fee": { "value": 9.90, "formatted": "$9.90", "short": "10", "currency": "USD" } }, "status": "completed", "created_at": "2025-01-15T10:30:00+00:00", "custom_fields": null, "custom_metadata": {"order_ref": "ORD-123"}, "completed_at": "2025-01-15T10:32:00+00:00", "abandoned_at": null, "failed_at": null }, "product": { "id": "prd_def456", "name": "Premium Course", "url": "https://mystore.mychariow.com/premium-course", "metadata": null, "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "customer": { "id": "cus_abc123", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": "+12025550123", "country": "US" }, "affiliate": null, "store": { "id": "str_xyz789", "name": "My Digital Store", "url": "https://mystore.mychariow.com" }, "checkout": { "url": "https://mystore.mychariow.com/prd_def456/checkout?first_name=John&last_name=Doe&email=customer%40example.com&country=US&phone=%28202%29+555-0123&help=buy" } } ``` * `product.metadata` is the custom metadata set on the product, or `null`. * `affiliate` is `null` unless the sale came through an affiliate, in which case it holds the store affiliate `id` and the affiliate `code`. * `checkout.url` is a link back to the product checkout, prefilled with the customer's details (and the discount code, if one was used). It is handy for recovering `abandoned.sale` and `failed.sale` events. ### License Activated Example When a license is activated, Chariow sends a webhook with the `license.activated` event: ```json theme={null} { "event": "license.activated", "license": { "id": "lic_ghi789def", "key": "ABCD-1234-EFGH-5678", "status": "active", "source_type": "sale", "activation_count": 1, "max_activations": 5, "activated_at": "2025-01-15T10:35:00+00:00", "expires_at": "2026-01-15T10:35:00+00:00", "expired_at": null, "revoked_at": null, "created_at": "2025-01-15T10:30:00+00:00" }, "product": { "id": "prd_def456", "name": "Pro Software License", "url": "https://mystore.mychariow.com/pro-software", "metadata": null }, "customer": { "id": "cus_abc123", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": "+1234567890", "country": "US" }, "store": { "id": "str_xyz789", "name": "My Digital Store", "url": "https://mystore.mychariow.com" } } ``` ### License Nearing Expiry Example Chariow scans licenses daily and sends the `license.nearing_expiry` event once per license, as soon as it enters the seven-day window before its `expires_at` date. Use it to prompt a renewal before the customer loses access. `days_until_expiry` is only present on this event. It is rounded up, so a license lapsing in a few hours reports `1`. A license is announced once and only once, even if the scan runs again before it expires. ```json theme={null} { "event": "license.nearing_expiry", "days_until_expiry": 7, "license": { "id": "lic_ghi789def", "key": "ABCD-1234-EFGH-5678", "status": "active", "source_type": "sale", "activation_count": 1, "max_activations": 5, "activated_at": "2025-01-15T10:35:00+00:00", "expires_at": "2026-01-15T10:35:00+00:00", "expired_at": null, "revoked_at": null, "created_at": "2025-01-15T10:30:00+00:00" }, "product": { "id": "prd_def456", "name": "Pro Software License", "url": "https://mystore.mychariow.com/pro-software", "metadata": null }, "customer": { "id": "cus_abc123", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": "+1234567890", "country": "US" }, "store": { "id": "str_xyz789", "name": "My Digital Store", "url": "https://mystore.mychariow.com" } } ``` ### Affiliate Joined Example When a new affiliate joins your store, Chariow sends a webhook with the `affiliate.joined` event: Since October 2026, `affiliate.joined` is signed, carries `x-pulse-delivery-id` and `x-pulse-event`, follows the retry policy and appears in the **Deliveries** tab like every other event. Before that date it was sent unsigned, so remove any exception you added to skip signature verification for this event. ```json theme={null} { "event": "affiliate.joined", "affiliate": { "id": "saff_xyz789abc", "account": { "id": "aff_abc123def", "code": "CREATOR123", "pseudo": "creative_studio", "email": "creator@example.com", "first_name": "John", "last_name": "Doe", "name": "John Doe", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" }, "phone": { "number": 12025550123, "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "https://cdn.axazara.com/flags/svg/US.svg" } } }, "source": { "value": "invitation", "label": "Invitation", "description": "Added via store invitation" }, "status": "active", "joined_at": "2025-01-15T10:40:00+00:00" }, "store": { "id": "str_xyz789", "name": "My Digital Store", "url": "https://mystore.mychariow.com" } } ``` * `affiliate.source` is an object: `value` is `invitation` (added through a store invitation) or `network` (joined through the affiliate network). * `affiliate.account.phone` is `null` when the affiliate has no phone number. Otherwise `number` is the E.164 number as an integer, without the leading `+`. * `affiliate.account` is `null` if the affiliate account no longer exists. The exact payload structure may include additional fields depending on the event type and context. Always check the actual payload received at your endpoint for the complete data structure. ## Handling Pulses ### Basic Example (Node.js/Express) ```javascript theme={null} const express = require('express'); const app = express(); app.post('/webhooks/chariow', express.json(), (req, res) => { const payload = req.body; const event = payload.event; switch (event) { case 'successful.sale': handleSuccessfulSale(payload.sale, payload.product, payload.customer, payload.store); break; case 'abandoned.sale': handleAbandonedSale(payload.sale, payload.store); break; case 'failed.sale': handleFailedSale(payload.sale, payload.store); break; case 'license.activated': handleLicenseActivated(payload.license, payload.product, payload.customer); break; case 'license.expired': handleLicenseExpired(payload.license, payload.customer); break; case 'license.issued': handleLicenseIssued(payload.license, payload.product, payload.customer); break; case 'license.nearing_expiry': handleLicenseNearingExpiry(payload.license, payload.customer, payload.days_until_expiry); break; case 'license.revoked': handleLicenseRevoked(payload.license, payload.customer); break; case 'affiliate.joined': handleAffiliateJoined(payload.affiliate, payload.store); break; default: console.log(`Unhandled event type: ${event}`); } // Always return 200 to acknowledge receipt res.status(200).send('OK'); }); function handleSuccessfulSale(sale, product, customer, store) { console.log(`Sale completed: ${sale.id} in store ${store.name}`); // Add customer to CRM, send confirmation email, grant access, etc. } function handleLicenseActivated(license, product, customer) { console.log(`License activated: ${license.key} for ${customer.email}`); // Log activation, update internal records, notify customer, etc. } function handleLicenseNearingExpiry(license, customer, daysUntilExpiry) { console.log(`License ${license.key} expires in ${daysUntilExpiry} day(s)`); // Send a renewal reminder, create a renewal offer, flag the account, etc. } function handleAffiliateJoined(affiliate, store) { console.log(`New affiliate joined: ${affiliate.account.code} in store ${store.name}`); // Send welcome email, create affiliate dashboard access, notify team, etc. } app.listen(3000, () => console.log('Webhook server running on port 3000')); ``` ### PHP Example ```php theme={null} After the 5th failed attempt on a single delivery, **the Pulse is disabled automatically** and the store owner, admins and marketing team members receive an email. You must re-enable it from the dashboard before it fires again β€” and before you can replay its deliveries. Ensure your Pulse endpoint responds quickly (within 30 seconds). Long-running processes should be handled asynchronously. ## Delivery History and Replay Every attempt is recorded, so you can see whether Chariow ever called your endpoint and what it answered. Open **Automations β†’ Pulses β†’ select your Pulse β†’ Deliveries tab**. The table lists each delivery with: | Field | Meaning | | - | - | | `status` | `pending`, `succeeded` or `failed` | | `http_status_code` | The status code your endpoint returned | | `attempts` | How many attempts have been made so far | | `payload` | The exact body that was sent | | `response_body` | Your endpoint's response, truncated | | `is_replay` | Whether this delivery was triggered by a manual replay | `pending` means queued or mid-retry, not failed. A delivery only becomes `failed` once all 5 attempts are exhausted. Clicking a row opens the sent payload, the response and the delivery id. **Replay** re-sends a stored payload to the same endpoint without reprocessing the original sale, licence or affiliate event. This is useful when your endpoint was down, or while you are debugging signature verification. A replay is a new delivery with a new `x-pulse-delivery-id`, so it passes your idempotency check and will be processed again. That is intentional. ## Best Practices Return a 200 response immediately, then process the Pulse asynchronously to avoid timeouts: ```javascript theme={null} app.post('/webhooks/chariow', (req, res) => { // Acknowledge receipt immediately res.status(200).send('OK'); // Process asynchronously (e.g., queue job, background worker) queuePulseProcessing(req.body); }); ``` Due to retry logic, the same delivery may reach you more than once. Deduplicate on the `x-pulse-delivery-id` header, which is stable across every attempt of a delivery: ```javascript theme={null} const processedDeliveries = new Set(); async function processPulse(deliveryId, payload) { if (processedDeliveries.has(deliveryId)) { console.log('Duplicate delivery, skipping'); return; } processedDeliveries.add(deliveryId); // Process the pulse... } ``` Do not deduplicate on the entity id inside the payload: one sale legitimately produces one delivery per subscribed Pulse. Never act on a payload before checking `x-chariow-signature`. See [Pulse Security](/en/guides/pulse-security) for the full contract and ready-to-use snippets. Always use HTTPS for your Pulse endpoint to ensure data is encrypted in transit. Chariow will reject HTTP endpoints for security reasons. Check the **Deliveries** tab of your Pulse regularly. It shows the status code and response body of every attempt, so you can diagnose failures without adding logging on your side. For high-volume stores, consider creating separate Pulses for different products to make processing more efficient and organised. ## Testing Pulses Use the Pulse testing feature in your dashboard: 1. Go to **Automations** β†’ **Pulses** 2. Click on your Pulse 3. Click **Send test pulse** 4. Check your endpoint received the test payload A test goes through the same pipeline as a real event: it is signed, carries all four `x-pulse-*` headers (including `x-pulse-delivery-id`), is queued rather than sent instantly, and is recorded in the **Deliveries** tab with your endpoint's status code and response. A test is sent as a `successful.sale` event with sample data, not a real sale. Its identifiers are prefixed `test_` (for example `test_sale_...`), the `sale` object only carries `id`, `amount`, `status`, `custom_fields`, `created_at`, `completed_at` and `abandoned_at`, `custom_fields` is a list of `name`/`value` pairs, and the payload contains an extra `note` field. To validate your integration against a real payload, replay a delivery from the **Deliveries** tab instead. A test delivery follows the normal [retry policy](#retry-policy). If your endpoint fails all 5 attempts, the Pulse is disabled automatically, exactly as for a real event. For local development, use a service like [ngrok](https://ngrok.com) to expose your local server to the internet. ## Managing Pulses via API You can programmatically read your Pulses using the Chariow Public API. Your API key needs the `webhooks.read` scope. ### List All Pulses ```bash theme={null} curl -X GET "https://api.chariow.com/v1/pulses" \ -H "Authorization: Bearer YOUR_API_KEY" ``` #### Example List Response ```json theme={null} { "data": [ { "id": "pulse_abc123xyz789", "url": "https://example.com/webhooks/chariow", "is_enabled": true, "masked_secret": "whsec_β€’β€’β€’β€’a1b2", "source": { "value": "manual", "label": "Manual", "description": "Created manually by user" }, "triggers": [ { "value": "successful_sale", "label": "Successful Sale", "description": "Triggers when a sale is successful." } ], "products": [ { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" } }, "bundle": null, "metadata": null } ], "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "is_editable": true, "created_at": "2025-01-10T08:00:00+00:00", "updated_at": "2025-01-10T08:00:00+00:00" } ], "pagination": { "count": 1, "path": "https://api.chariow.com/v1/pulses", "per_page": 10, "next_cursor": null, "next_page_url": null, "prev_cursor": null, "prev_page_url": null, "has_more_pages": false, "has_pages": false } } ``` ### Get a Specific Pulse ```bash theme={null} curl -X GET "https://api.chariow.com/v1/pulses/pulse_abc123xyz789" \ -H "Authorization: Bearer YOUR_API_KEY" ``` The response wraps a single pulse object, with the same structure as each item in the list response, in a `data` key. ### Filter Pulses You can filter pulses by URL, pulse ID or trigger value using the search parameter: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/pulses?search=successful_sale" \ -H "Authorization: Bearer YOUR_API_KEY" ``` For complete API documentation, see the [List Pulses](/api-reference/pulses/list-pulses) and [Get Pulse](/api-reference/pulses/get-pulse) endpoints. ## Related Resources Verify signatures and deduplicate retries View detailed API documentation Get a specific pulse via API Learn about sale events Learn about license events Learn about affiliate events # SaaS License Integration Source: https://chariow.dev/en/guides/saas-license-integration Complete guide to implementing license-based paywalls in your SaaS application using Chariow API with AI coding tools This guide shows you how to use Chariow's License API to implement a paywall in your SaaS application. Whether you're building with Lovable, Cursor, Bolt, or any AI coding assistant, this guide provides everything you need including ready-to-use AI prompts. This guide assumes you have a Chariow store with a **License** type product created. If you haven't set one up yet, [create your license product](https://app.chariow.com) first. ## What is a License Paywall? A license paywall restricts access to your SaaS application (or specific features) until the user provides a valid license key. This is ideal for: * **Desktop applications**: Electron apps, native software, CLI tools * **Web applications**: SaaS platforms, admin dashboards, premium tools * **Mobile apps**: iOS/Android applications with premium features * **API access**: Gating API usage based on license validity ### How It Works Customer buys your license product on Chariow. A unique license key is automatically generated (e.g., `ABC-123-XYZ-789`). In your application, the customer enters their license key in a settings or activation screen. Your application calls the Chariow API to validate the license key and check its status. Based on the API response (`is_active`, `is_expired`), your app grants or denies access. For device-limited licenses, activate the license to track and limit device usage. ## API Endpoints You'll Need | Endpoint | Method | Purpose | | - | - | - | | `/v1/licenses/{key}` | GET | Validate a license key and check status | | `/v1/licenses/{key}/activate` | POST | Activate license on a device | Your API key (`sk_live_...`) must be kept **server-side only**. Never expose it in client-side code. ## Architecture Patterns ### Pattern 1: Server-Side Validation (Recommended) Your backend validates licenses and controls access. Best for web applications. Server-side license validation flow ### Pattern 2: Serverless/Edge Validation Validate licenses at the edge using serverless functions. Good for static sites. Serverless license validation flow ### Pattern 3: Desktop App with Periodic Validation Desktop apps validate on startup and periodically. Includes offline grace period. Desktop app license validation flow with local cache ## Implementation Guide ### Step 1: Create an API Route for License Validation Your backend should expose an endpoint that your frontend calls: ```javascript theme={null} // /api/validate-license.js (Next.js API route) export default async function handler(req, res) { const { licenseKey } = req.body; if (!licenseKey) { return res.status(400).json({ valid: false, error: 'License key required' }); } try { const response = await fetch( `https://api.chariow.com/v1/licenses/${encodeURIComponent(licenseKey)}`, { headers: { 'Authorization': `Bearer ${process.env.CHARIOW_API_KEY}` } } ); if (!response.ok) { return res.status(200).json({ valid: false, error: 'Invalid license key' }); } const { data } = await response.json(); // Check license validity if (!data.is_active) { return res.status(200).json({ valid: false, error: 'License is not active' }); } if (data.is_expired) { return res.status(200).json({ valid: false, error: 'License has expired' }); } // License is valid return res.status(200).json({ valid: true, license: { status: data.status, expiresAt: data.expires_at, activationsRemaining: data.activations?.remaining } }); } catch (error) { console.error('License validation error:', error); return res.status(500).json({ valid: false, error: 'Validation failed' }); } } ``` ### Step 2: Create the License Entry Component ```jsx theme={null} // components/LicenseGate.jsx import { useState, useEffect } from 'react'; export function LicenseGate({ children }) { const [isValidated, setIsValidated] = useState(false); const [isLoading, setIsLoading] = useState(true); const [licenseKey, setLicenseKey] = useState(''); const [error, setError] = useState(''); // Check for stored license on mount useEffect(() => { const storedKey = localStorage.getItem('license_key'); if (storedKey) { validateLicense(storedKey); } else { setIsLoading(false); } }, []); const validateLicense = async (key) => { setIsLoading(true); setError(''); try { const response = await fetch('/api/validate-license', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ licenseKey: key }) }); const data = await response.json(); if (data.valid) { localStorage.setItem('license_key', key); setIsValidated(true); } else { setError(data.error || 'Invalid license'); localStorage.removeItem('license_key'); } } catch (err) { setError('Failed to validate license'); } finally { setIsLoading(false); } }; const handleSubmit = (e) => { e.preventDefault(); validateLicense(licenseKey); }; if (isLoading) { return
Validating license...
; } if (isValidated) { return children; } return (

Enter Your License Key

Please enter your license key to access the application.

setLicenseKey(e.target.value)} placeholder="ABC-123-XYZ-789" />
{error &&

{error}

}

Don't have a license? Purchase one here

); } ``` ### Step 3: Wrap Your App with the License Gate ```jsx theme={null} // App.jsx import { LicenseGate } from './components/LicenseGate'; import { Dashboard } from './components/Dashboard'; function App() { return ( ); } ``` ## Device Activation (Optional) If your app tracks its own devices, skip activation entirely: set `requires_activation` to `false` in the product's licence settings and Chariow issues every licence already active, with its validity period starting at purchase. Your app then only ever calls `GET /v1/licenses/{licenseKey}` to validate. See [Licences that need no activation](/en/guides/licenses#licences-that-need-no-activation). If your license has limited activations and you want Chariow to count the seats, activate on the device: ```javascript theme={null} // /api/activate-license.js export default async function handler(req, res) { const { licenseKey, deviceId } = req.body; const response = await fetch( `https://api.chariow.com/v1/licenses/${encodeURIComponent(licenseKey)}/activate`, { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.CHARIOW_API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ device_identifier: deviceId }) } ); const data = await response.json(); if (!response.ok) { return res.status(400).json({ success: false, error: data.message }); } return res.status(200).json({ success: true, activationsRemaining: data.data.activations?.remaining }); } ``` ## AI Prompts for Implementation Use these prompts with Lovable, Cursor, Bolt, or any AI coding assistant to implement the license paywall quickly. ### Prompt 1: Basic License Paywall (React + Next.js) ```text theme={null} Create a license paywall system for my Next.js application with these requirements: 1. Create an API route at /api/validate-license that: - Accepts POST requests with { licenseKey: string } - Calls Chariow API: GET https://api.chariow.com/v1/licenses/{licenseKey} - Uses Bearer token authentication with CHARIOW_API_KEY environment variable - Returns { valid: true/false, error?: string, license?: object } - Check is_active and is_expired fields from the response 2. Create a LicenseGate component that: - Shows a license key input form when not validated - Stores valid license key in localStorage - Checks localStorage on mount to auto-validate returning users - Renders children only when license is valid - Shows loading state during validation - Displays error messages for invalid licenses 3. Style the license form with Tailwind CSS: - Centre the form on the page - Use clean, professional styling - Include a link to purchase a license Environment variable needed: CHARIOW_API_KEY (store API key) ``` ### Prompt 2: License Paywall with Device Activation ```text theme={null} Extend the license paywall system with device activation: 1. Generate a unique device identifier: - For web apps: combine user agent + screen resolution + timezone - Hash the result to create a consistent device ID - Store the device ID in localStorage 2. Create /api/activate-license endpoint: - Accepts POST with { licenseKey, deviceId } - Calls Chariow API: POST https://api.chariow.com/v1/licenses/{key}/activate - Body: { device_identifier: deviceId } - Handle "Activation limit reached" error gracefully 3. Update LicenseGate component: - After validating license, call activate endpoint - Show remaining activations count to user - Handle activation errors with user-friendly messages 4. Add a "Manage Devices" section showing: - Current activation count - Maximum activations allowed - Option to deactivate current device ``` ### Prompt 3: Feature-Based Licensing ```text theme={null} Implement feature-gated licensing where different license tiers unlock different features: 1. Create a useLicense hook that: - Validates license on app load - Returns { isValid, tier, features, expiresAt } - Tier is determined by the product name or metadata from Chariow 2. Create a FeatureGate component: - Accepts requiredTier prop (e.g., "pro", "enterprise") - Shows upgrade prompt if user's tier is insufficient - Renders children if tier requirement is met 3. Example usage: 4. Create an upgrade modal that: - Shows current vs required tier - Links to Chariow checkout for the upgrade product - Includes feature comparison ``` ### Prompt 4: Offline-Capable License Validation ```text theme={null} Add offline support to the license system: 1. Cache license validation result locally: - Store validation timestamp - Store license expiry date - Store full license object 2. Implement validation logic: - If online: validate with Chariow API - If offline: check cached validation (valid for 7 days) - If cache expired: show offline warning but allow limited access 3. Add periodic re-validation: - Re-validate every 24 hours when online - Update cache on successful validation - Handle network errors gracefully 4. Show license status indicator: - Green: validated online today - Yellow: using cached validation - Red: cache expired, needs connection ``` ### Prompt 5: Complete Electron App Implementation ```text theme={null} Create a license system for an Electron desktop app: 1. Main process license manager: - Store license in electron-store (encrypted) - Validate on app launch - Re-validate every 24 hours - Send validation status to renderer via IPC 2. Preload script: - Expose safe license APIs to renderer - licenseAPI.validate(key) - licenseAPI.getStatus() - licenseAPI.activate() 3. Renderer license UI: - License entry screen on first launch - License status in settings - "Manage Activations" option 4. Device identifier: - Use machine-id package for consistent device ID - Pass to Chariow activation endpoint 5. Offline handling: - Cache validation for 7 days - Show "Offline Mode" indicator - Block app after cache expires ``` ### Prompt 6: Supabase Integration ```text theme={null} Integrate license validation with Supabase authentication: 1. Create a Supabase edge function at /validate-license: - Verify user is authenticated - Store validated licenses in a 'user_licenses' table - Link license to user ID 2. Database schema: CREATE TABLE user_licenses ( id UUID PRIMARY KEY, user_id UUID REFERENCES auth.users, license_key TEXT NOT NULL, validated_at TIMESTAMP, expires_at TIMESTAMP, status TEXT ); 3. React hook useUserLicense: - Check if current user has valid license - Sync license status on login - Handle multi-device scenarios 4. Row Level Security: - Users can only see their own licenses - Enable realtime subscriptions for status updates ``` ## Security Best Practices Never expose your Chariow API key in client-side code. Always validate licenses through your backend. ### Do's * **Store API keys server-side** in environment variables * **Validate on the backend** before granting access * **Cache validation results** to reduce API calls * **Implement rate limiting** on your validation endpoint * **Use HTTPS** for all API communications * **Log validation attempts** for security auditing ### Don'ts * **Don't trust client-side validation alone** - it can be bypassed * **Don't store the full license object** in accessible localStorage * **Don't skip validation** for "trusted" users * **Don't hardcode license keys** in your application * **Don't expose detailed error messages** that could help attackers ## Testing Your Integration ### Test Scenarios | Scenario | Expected Behaviour | | - | - | | Valid, active license | Access granted | | Invalid license key | Show "Invalid license" error | | Expired license | Show "License expired" message with renewal link | | Revoked license | Show "License revoked" - contact support | | Network error | Show cached result or offline warning | | Activation limit reached | Show "Too many devices" with management options | ### Test License Keys During development, create test products in your Chariow store with: * Free test licenses for development * Short expiry periods to test expiration handling * Limited activations to test device limits ## Complete Example: Next.js App Router Here's a complete implementation using Next.js App Router: ```typescript app/api/license/validate/route.ts theme={null} import { NextResponse } from 'next/server'; export async function POST(request: Request) { const { licenseKey } = await request.json(); if (!licenseKey) { return NextResponse.json( { valid: false, error: 'License key required' }, { status: 400 } ); } try { const response = await fetch( `https://api.chariow.com/v1/licenses/${encodeURIComponent(licenseKey)}`, { headers: { 'Authorization': `Bearer ${process.env.CHARIOW_API_KEY}` } } ); if (!response.ok) { return NextResponse.json({ valid: false, error: 'Invalid license key' }); } const { data } = await response.json(); if (!data.is_active) { return NextResponse.json({ valid: false, error: 'License is not active' }); } if (data.is_expired) { return NextResponse.json({ valid: false, error: 'License has expired' }); } return NextResponse.json({ valid: true, license: { status: data.status, expiresAt: data.expires_at, activationsRemaining: data.activations?.remaining } }); } catch (error) { return NextResponse.json( { valid: false, error: 'Validation failed' }, { status: 500 } ); } } ``` ```typescript hooks/useLicense.ts theme={null} 'use client'; import { useState, useEffect, useCallback } from 'react'; interface LicenseState { isLoading: boolean; isValid: boolean; error: string | null; expiresAt: string | null; } export function useLicense() { const [state, setState] = useState({ isLoading: true, isValid: false, error: null, expiresAt: null }); const validate = useCallback(async (key: string): Promise => { setState(s => ({ ...s, isLoading: true, error: null })); try { const res = await fetch('/api/license/validate', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ licenseKey: key }) }); const data = await res.json(); if (data.valid) { localStorage.setItem('license_key', key); setState({ isLoading: false, isValid: true, error: null, expiresAt: data.license?.expiresAt }); return true; } else { localStorage.removeItem('license_key'); setState({ isLoading: false, isValid: false, error: data.error, expiresAt: null }); return false; } } catch { setState(s => ({ ...s, isLoading: false, error: 'Validation failed' })); return false; } }, []); const logout = useCallback(() => { localStorage.removeItem('license_key'); setState({ isLoading: false, isValid: false, error: null, expiresAt: null }); }, []); useEffect(() => { const storedKey = localStorage.getItem('license_key'); if (storedKey) { validate(storedKey); } else { setState(s => ({ ...s, isLoading: false })); } }, [validate]); return { ...state, validate, logout }; } ``` ```tsx components/LicenseGate.tsx theme={null} 'use client'; import { useState } from 'react'; import { useLicense } from '@/hooks/useLicense'; export function LicenseGate({ children }: { children: React.ReactNode }) { const { isLoading, isValid, error, validate } = useLicense(); const [keyInput, setKeyInput] = useState(''); if (isLoading) { return (

Validating license...

); } if (isValid) { return <>{children}; } return (

Enter Your License Key

Please enter your license key to access the application.

{ e.preventDefault(); validate(keyInput); }} className="space-y-4" > setKeyInput(e.target.value)} placeholder="ABC-123-XYZ-789" className="w-full px-4 py-2 border rounded-lg focus:ring-2 focus:ring-blue-500" />
{error && (

{error}

)}

Don't have a license?{' '} Purchase one here

); } ```
## Next Steps Learn more about license management View the complete License API reference Get notified when licenses are purchased Security and integration best practices # Sales Source: https://chariow.dev/en/guides/sales Learn how to retrieve and manage sales data via the Chariow API Sales represent purchase transactions in your store, whether completed, pending, abandoned, failed, or settled. Each sale contains comprehensive information about the product, customer, payment details, applied discounts and shipping information. ## Understanding Sales The Chariow Sales API provides programmatic access to all transaction data in your store. You can: * Retrieve a list of all sales with filtering options * Get detailed information about specific sales * Track payment status and settlement details * Access customer purchase history * Monitor download statistics * View applied discounts and marketing campaigns ## Sale Object The detailed sale object (returned by the single sale endpoint) contains comprehensive purchase information with the following structure: ```json theme={null} { "id": "sal_abc123xyz", "status": "completed", "channel": { "value": "store", "label": "Store", "description": "Sale made through the store checkout" }, "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "discount_amount": { "value": 19.80, "formatted": "$19.80", "short": "20", "currency": "USD" }, "settlement": { "amount": { "value": 75.24, "formatted": "$75.24", "short": "75", "currency": "USD" }, "due_at": "2025-02-01T00:00:00+00:00", "done_at": "2025-02-01T10:15:00+00:00", "service_fee": { "value": 3.96, "formatted": "$3.96", "short": "4", "currency": "USD" } }, "download": { "total": 3, "last_at": "2025-01-20T14:30:00+00:00" }, "invoice_download_url": "https://api.chariow.com/...signed-invoice-url...", "payment": { "status": "success", "transaction_id": "txn_xyz789", "gateway": "orqex", "method": { "name": "Orange Money Senegal", "icon_url": "https://assets.example.com/icons/orange_money.svg" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "fee": { "value": 2.37, "formatted": "$2.37", "short": "2", "currency": "USD" }, "fee_rate": "3%", "interchange": { "rate": "1.5%", "fee": { "value": 1.19, "formatted": "$1.19", "short": "1", "currency": "USD" } }, "exchange_rate": { "value": 1.0, "formatted": "$1.00", "short": "1", "currency": "USD" }, "failure_error": null }, "shipping": { "address": "123 Main Street", "city": "New York", "state": "NY", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" }, "zip": "10001" }, "context": { "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)", "ip_address": "203.0.113.42", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" }, "device_type": "desktop", "locale": "en_US" }, "custom_fields_values": null, "campaign": { "id": "cmp_pqr678", "name": "Black Friday Campaign" }, "rating": { "id": "rat_mno345", "is_thumbs_up": true, "comment": "Excellent product!", "created_at": "2025-01-18T09:00:00+00:00" }, "store": { "id": "str_xyz789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/xyz789/logo.png", "url": "https://mystore.mychariow.com" }, "product": { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" } }, "bundle": null, "metadata": null }, "customer": { "id": "cus_ghi789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "avatar_url": null }, "buyer": { "first_name": "John", "last_name": "Doe" }, "discount": { "id": "dis_jkl012", "name": "Save 20%", "code": "SAVE20" }, "is_access_revoked": false, "is_reconciled": true, "last_reconciled_at": "2025-02-01T10:15:00+00:00", "failed_at": null, "awaiting_payment_at": "2025-01-15T10:30:00+00:00", "abandoned_at": null, "completed_at": "2025-01-15T10:32:00+00:00", "created_at": "2025-01-15T10:30:00+00:00", "updated_at": "2025-01-15T10:32:00+00:00" } ``` The list endpoint returns a simplified version of the sale object, whilst the single sale endpoint returns the full detailed object shown above. See the [Listing Sales](#listing-sales) and [Getting a Single Sale](#getting-a-single-sale) sections for the differences. `buyer` keeps the name entered at purchase time, whereas `customer` reflects the customer's current profile. A `gift` object (`recipient`, `message`) is added for gift purchases. ## Sale Statuses Sales can have the following statuses throughout their lifecycle: | Status | Description | | - | - | | `initiated` | Sale created, payment not started yet | | `awaiting_payment` | Checkout initiated, waiting for payment confirmation | | `completed` | Payment successful, product access granted to customer | | `failed` | Payment failed or was declined | | `abandoned` | Customer abandoned the checkout process | | `settled` | Funds have been settled to the merchant account | `failed` and `abandoned` are not always final. When the payment gateway later reports that the buyer did pay (for example, a payment finished after the checkout timed out), the sale is reopened as `awaiting_payment`, its `failed_at` or `abandoned_at` is cleared, and it then moves to `completed`. Listen for sale events through [Pulses](/en/guides/pulses) rather than treating these statuses as definitive. ## Payment Statuses The payment status tracks the payment gateway transaction separately from the sale status: | Payment Status | Description | | - | - | | `initiated` | Payment process has started | | `pending` | Payment is being processed by the gateway | | `success` | Payment was successfully processed | | `failed` | Payment failed or was declined | | `cancelled` | Payment was cancelled by customer or system | ## Sales Channels Sales can originate from different channels: | Channel | Description | | - | - | | `store` | Direct sale through your store checkout | | `affiliate` | Sale made through an affiliate link | | `discover` | Sale from Chariow Discover marketplace | | `widget` | Sale through an embedded checkout widget | | `api` | Sale created via the Public API | ## Listing Sales Retrieve all sales for your store: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/sales" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/sales', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/sales', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) sales = response.json()['data'] ``` ### Query Parameters You can filter and paginate sales using the following parameters: | Parameter | Type | Description | | - | - | - | | `per_page` | integer | Number of sales per page (1 to 100, default 10) | | `cursor` | string | Cursor for pagination (from `next_cursor` or `prev_cursor`) | | `status` | string | Filter by sale status (`initiated`, `awaiting_payment`, `completed`, `failed`, `abandoned`, `settled`) | | `customer_id` | string | Filter by customer public ID (e.g., `cus_abc123xyz`) | | `search` | string | Search by sale ID or payment transaction ID | | `from` | string | Sales created on or after this date (format: `Y-m-d`, e.g., `2025-01-01`) | | `to` | string | Sales created on or before this date (format: `Y-m-d`, e.g., `2025-01-31`) | | `period` | string | Date range shortcut used instead of `from` and `to`: `today`, `yesterday`, `last7days`, `last30days`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear`, `lastYear` | `start_date` and `end_date` are not supported and are silently ignored, which returns sales of every date. Use `from` and `to`. ### Filtering by Status ```bash theme={null} # Get only completed sales curl -X GET "https://api.chariow.com/v1/sales?status=completed" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Filtering by Customer ```bash theme={null} # Get sales for a specific customer curl -X GET "https://api.chariow.com/v1/sales?customer_id=cus_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Filtering by Date Range ```bash theme={null} # Get sales from January 2025 curl -X GET "https://api.chariow.com/v1/sales?from=2025-01-01&to=2025-01-31" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Searching Sales ```bash theme={null} # Search by sale ID or payment transaction ID curl -X GET "https://api.chariow.com/v1/sales?search=sal_abc123xyz" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ### Pagination The API uses cursor-based pagination. Use the `next_cursor` from the response to fetch the next page: ```javascript theme={null} let cursor = null; let allSales = []; do { const url = cursor ? `https://api.chariow.com/v1/sales?cursor=${cursor}` : 'https://api.chariow.com/v1/sales'; const response = await fetch(url, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); allSales = [...allSales, ...result.data]; cursor = result.pagination.next_cursor; } while (cursor); ``` ### Example Response The list endpoint returns a simplified sale object per item: ```json theme={null} { "data": [ { "id": "sal_abc123xyz", "status": "completed", "tracking": { "event_id": "sal_abc123xyz", "currency": "USD", "value": 79.2 }, "original_amount": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "discount_amount": { "value": 19.80, "formatted": "$19.80", "short": "20", "currency": "USD" }, "payment": { "amount": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" }, "status": "success", "exchange_rate": { "value": 1.0, "formatted": "$1.00", "short": "1", "currency": "USD" }, "failure_error": null }, "shipping": { "address": "123 Main Street", "city": "New York", "state": "NY", "country": "US", "zip": "10001" }, "invoice_download_url": "https://api.chariow.com/...signed-invoice-url...", "created_at": "2025-01-15T10:30:00+00:00", "completed_at": "2025-01-15T10:32:00+00:00", "store": { "id": "str_ghi789", "name": "My Digital Store", "logo_url": "https://cdn.chariow.com/stores/ghi789/logo.png", "url": "https://mystore.mychariow.com" }, "product": { "id": "prd_def456", "name": "Premium Course", "type": "course", "pictures": { "thumbnail": "https://cdn.chariow.com/products/thumb.jpg", "cover": "https://cdn.chariow.com/products/cover.jpg" }, "category": { "value": "education_and_learning", "label": "Education and Learning" }, "pricing": { "type": "one_time", "price": { "value": 99, "formatted": "$99.00", "short": "99", "currency": "USD" }, "effective": { "value": 79.20, "formatted": "$79.20", "short": "79", "currency": "USD" } }, "bundle": null, "metadata": null }, "customer": { "id": "cus_xyz789", "name": "John Doe", "first_name": "John", "last_name": "Doe", "email": "customer@example.com", "phone": { "number": "+1 234 567 890", "country": { "name": "United States", "code": "US", "alpha_3_code": "USA", "dial_code": "+1", "currency": "USD", "flag": "πŸ‡ΊπŸ‡Έ" } }, "avatar_url": null }, "buyer": { "first_name": "John", "last_name": "Doe" }, "discount": { "id": "dis_jkl012", "name": "Save 20%", "code": "SAVE20" }, "rate": { "id": "rat_mno345", "is_thumbs_up": true, "comment": "Excellent product!", "created_at": "2025-01-18T09:00:00+00:00" } } ], "pagination": { "per_page": 10, "next_cursor": "eyJpZCI6NTB9", "prev_cursor": null, "has_more_pages": true } } ``` ## Getting a Single Sale Retrieve a specific sale by its public ID: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/sales/sal_abc123" \ -H "Authorization: Bearer sk_live_your_api_key" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/sales/sal_abc123', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }); const result = await response.json(); ``` ## Common Use Cases Calculate total revenue for a specific period: ```javascript theme={null} const response = await fetch( 'https://api.chariow.com/v1/sales?status=completed&from=2025-01-01&to=2025-01-31', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); const result = await response.json(); const totalRevenue = result.data.reduce( (sum, sale) => sum + sale.amount.value, 0 ); console.log(`Total revenue: ${totalRevenue}`); ``` Process orders that require physical shipping: ```javascript theme={null} // Get completed sales with shipping addresses const response = await fetch( 'https://api.chariow.com/v1/sales?status=completed', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); const result = await response.json(); const ordersToShip = result.data.filter( sale => sale.shipping && sale.shipping.address ); // Process each order ordersToShip.forEach(sale => { console.log(`Ship to: ${sale.shipping.address}, ${sale.shipping.city}`); }); ``` View a customer's complete purchase history: ```bash theme={null} curl -X GET "https://api.chariow.com/v1/sales?customer_id=cus_abc123xyz" \ -H "Authorization: Bearer sk_live_your_api_key" ``` This returns all sales for the specified customer, including: * Purchase dates and amounts * Products purchased * Applied discounts * Current access status Identify and process failed payments: ```javascript theme={null} const response = await fetch( 'https://api.chariow.com/v1/sales?status=failed', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); const result = await response.json(); // Review failed sales and payment error details result.data.forEach(sale => { if (sale.payment.failure_error) { console.log(`Failed sale ${sale.id}: ${sale.payment.failure_error.code} (${sale.payment.failure_error.customer_message})`); // Take action based on error code } }); ``` Analyse discount code usage and effectiveness: ```javascript theme={null} const response = await fetch( 'https://api.chariow.com/v1/sales?status=completed&from=2025-01-01', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' }} ); const result = await response.json(); // Group by discount code const discountStats = result.data .filter(sale => sale.discount) .reduce((acc, sale) => { const code = sale.discount.code; if (!acc[code]) { acc[code] = { uses: 0, revenue: 0, discountGiven: 0 }; } acc[code].uses++; acc[code].revenue += sale.amount.value; acc[code].discountGiven += sale.discount_amount.value; return acc; }, {}); console.log(discountStats); ``` ## Settlement Information For completed sales, the `settlement` object provides details about merchant payouts: ```json theme={null} { "settlement": { "amount": { "value": 75.24, "formatted": "$75.24", "short": "75", "currency": "USD" }, "due_at": "2025-02-01T00:00:00+00:00", "done_at": "2025-02-01T10:15:00+00:00", "service_fee": { "value": 3.96, "formatted": "$3.96", "short": "4", "currency": "USD" } } } ``` * `amount` - Net amount to be paid to merchant (after fees) * `due_at` - When settlement is scheduled * `done_at` - When settlement was completed (null if pending) * `service_fee` - Chariow platform service fee ## Download Tracking Monitor customer download activity: ```json theme={null} { "download": { "total": 3, "last_at": "2025-01-20T14:30:00+00:00" } } ``` This helps you: * Track product engagement * Identify customers who haven't accessed their purchase * Monitor for unusual download patterns ## Related Resources Learn how to create sales Get notified of new sales View the complete Sales API reference # Use Cases Source: https://chariow.dev/en/guides/use-cases Discover real-world integration scenarios for the Chariow API The Chariow API enables a wide range of integration scenarios for selling digital products. Here are five common use cases to help you get started. ## 1. Custom Storefront Integration Build a fully branded shopping experience on your own website while leveraging Chariow for payment processing and product delivery. ### Scenario You have an existing website or web application and want to sell digital products without redirecting customers to an external store. ### Implementation Fetch your product catalog using the [List Products](/api-reference/products/list-products) endpoint and display the ones whose `status` is `published` on your website. Create a custom checkout form to collect customer details (name, email, phone). Call the [Checkout API](/api-reference/checkout/init-checkout) with customer data and redirect to the payment URL. Use a custom `redirect_url` to bring customers back to your thank-you page, and set up [Pulses](/en/guides/pulses) for reliable sale notifications. ### Code Example ```javascript theme={null} // Fetch products for display const products = await fetch('https://api.chariow.com/v1/products', { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } }).then(res => res.json()); // When customer submits checkout form async function handleCheckout(productId, customerData) { const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ product_id: productId, email: customerData.email, first_name: customerData.firstName, last_name: customerData.lastName, phone: { number: customerData.phone, country_code: customerData.countryCode }, redirect_url: 'https://yoursite.com/thank-you?sale={sale_id}' }) }); const result = await response.json(); if (result.data.step === 'payment') { window.location.href = result.data.payment.checkout_url; } } ``` *** ## 2. Software License Management Sell software with automated license key generation, validation, and activation management. ### Scenario You develop desktop or mobile software and need to protect it with license keys, control the number of installations, and manage activations. ### Implementation Create license-type products in Chariow with activation limits configured. When your software starts, call the [Get License](/api-reference/licenses/get-license) endpoint to check if the license is valid (verify `is_active`, `is_expired`, and `can_activate` fields). On first run, call [Activate License](/api-reference/licenses/activate-license) with a unique machine identifier. Skip this step entirely if the product has `requires_activation` set to `false` β€” its licences arrive already active. See [Licences that need no activation](/en/guides/licenses#licences-that-need-no-activation). Allow users to revoke licenses when switching devices using [Revoke License](/api-reference/licenses/revoke-license). ### Code Example ```python theme={null} import requests import hashlib import platform def get_machine_id(): """Generate a unique machine identifier""" machine_info = f"{platform.node()}-{platform.machine()}-{platform.processor()}" return hashlib.sha256(machine_info.encode()).hexdigest()[:32] def get_license(license_key): """Read the license via the Get License endpoint""" response = requests.get( f'https://api.chariow.com/v1/licenses/{license_key}', headers={'Authorization': 'Bearer sk_live_your_api_key'} ) response.raise_for_status() return response.json()['data'] def activate_license(license_key): """Activate the license for this machine""" response = requests.post( f'https://api.chariow.com/v1/licenses/{license_key}/activate', headers={'Authorization': 'Bearer sk_live_your_api_key'}, json={'device_identifier': get_machine_id()} ) return response.json() # On application startup license_key = load_stored_license() license = get_license(license_key) if license['status'] == 'pending_activation': # First run on this machine: claim a seat. # Products with requires_activation set to false never reach this branch. activate_license(license_key) elif not license['is_active'] or license['is_expired']: show_license_invalid_dialog() ``` *** ## 3. E-commerce Platform Plugin Create a plugin or integration for e-commerce platforms (WordPress, Shopify, etc.) to sell Chariow products. ### Scenario You want to extend an existing e-commerce platform to sell digital products managed in Chariow, synchronizing products and processing orders. ### Implementation Periodically fetch products from Chariow and sync the published ones to your platform's database. Store Chariow product IDs alongside platform cart items. On checkout, create Chariow checkout sessions for each digital product. Listen to Chariow [Pulses](/en/guides/pulses) to mark orders as fulfilled in your platform. ### Code Example ```php theme={null} [ 'Authorization' => 'Bearer ' . get_option('chariow_api_key') ] ]); $products = json_decode(wp_remote_retrieve_body($response), true); foreach ($products['data'] as $product) { // The API also returns draft and suspended products if ($product['status'] !== 'published') { continue; } update_or_create_wc_product($product); } } // Process checkout for Chariow product function process_chariow_checkout($order_id) { $order = wc_get_order($order_id); foreach ($order->get_items() as $item) { $chariow_product_id = get_post_meta($item->get_product_id(), '_chariow_product_id', true); if ($chariow_product_id) { $response = wp_remote_post('https://api.chariow.com/v1/checkout', [ 'headers' => [ 'Authorization' => 'Bearer ' . get_option('chariow_api_key'), 'Content-Type' => 'application/json' ], 'body' => json_encode([ 'product_id' => $chariow_product_id, 'email' => $order->get_billing_email(), 'first_name' => $order->get_billing_first_name(), 'last_name' => $order->get_billing_last_name(), 'phone' => [ 'number' => preg_replace('/[^0-9]/', '', $order->get_billing_phone()), 'country_code' => $order->get_billing_country() ] ]) ]); $result = json_decode(wp_remote_retrieve_body($response), true); update_post_meta($order_id, '_chariow_sale_id', $result['data']['purchase']['id']); } } } ``` *** ## 4. Course Platform with Access Control Build an online learning platform where course access is controlled by Chariow purchases. ### Scenario You run an educational platform and want to sell courses, controlling access based on purchase status and managing enrollments. ### Implementation Set up course-type products in Chariow with your curriculum content. When users try to access course content, verify their purchase using the [Get Sale](/api-reference/sales/get-sale) endpoint. Use [Pulses](/en/guides/pulses) to automatically enroll users when purchases complete. Store course progress in your database, linked to the Chariow customer ID. ### Code Example ```javascript theme={null} // Express.js middleware for course access control async function verifyCourseAccess(req, res, next) { const { courseSlug } = req.params; const userEmail = req.user.email; // Find the sale for this user and course const salesResponse = await fetch( `https://api.chariow.com/v1/sales?product_slug=${courseSlug}&customer_email=${userEmail}`, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } } ); const sales = await salesResponse.json(); const validSale = sales.data.find(sale => sale.status === 'completed'); if (!validSale) { return res.status(403).json({ error: 'Access denied', message: 'Please purchase this course to access the content', purchase_url: `/checkout/${courseSlug}` }); } req.sale = validSale; next(); } // Pulse webhook handler for auto-enrollment app.post('/webhooks/chariow', async (req, res) => { const { event, data } = req.body; if (event === 'sale.completed') { const { customer, product } = data; // Auto-enroll user in course await db.enrollments.create({ user_email: customer.email, course_id: product.id, enrolled_at: new Date(), sale_id: data.id }); // Send welcome email await sendCourseWelcomeEmail(customer.email, product.name); } res.status(200).send('OK'); }); ``` *** ## 5. Affiliate and Campaign Tracking Track sales attribution across marketing campaigns and affiliate partners. ### Scenario You run marketing campaigns or have affiliate partners and need to track which sales come from which sources to calculate commissions or measure ROI. ### Implementation Generate unique campaign identifiers for each marketing channel or affiliate. Include the `campaign_id` parameter when initiating checkouts. Capture campaign data from sale Pulses to attribute conversions. Use the [List Sales](/api-reference/sales/list-sales) endpoint with campaign filters to generate attribution reports. ### Code Example ```javascript theme={null} // Track campaign from URL parameters function getCheckoutDataWithCampaign(productId, customerData) { const urlParams = new URLSearchParams(window.location.search); const campaignId = urlParams.get('ref') || urlParams.get('utm_campaign') || urlParams.get('affiliate'); const checkoutData = { product_id: productId, email: customerData.email, first_name: customerData.firstName, last_name: customerData.lastName, phone: { number: customerData.phone, country_code: customerData.countryCode } }; if (campaignId) { checkoutData.campaign_id = campaignId; } return checkoutData; } // Backend: Generate affiliate report async function generateAffiliateReport(affiliateId, startDate, endDate) { const response = await fetch( `https://api.chariow.com/v1/sales?campaign_id=${affiliateId}&from=${startDate}&to=${endDate}`, { headers: { 'Authorization': 'Bearer sk_live_your_api_key' } } ); const sales = await response.json(); const report = { affiliate_id: affiliateId, period: { start: startDate, end: endDate }, total_sales: sales.data.length, total_revenue: sales.data.reduce((sum, sale) => sum + sale.amount.value, 0), commission: 0 }; // Calculate 20% commission report.commission = report.total_revenue * 0.20; return report; } ``` *** ## Next Steps Learn checkout API best practices for production Deep dive into the checkout flow Set up webhooks for real-time notifications Explore the complete API documentation # Authentication Source: https://chariow.dev/en/introduction/authentication Learn how to authenticate your API requests to Chariow and choose the scopes each API key needs The Chariow API uses store API keys to authenticate requests. Each key belongs to one store and carries a set of **scopes** that decide which endpoints it can call. ## Creating an API Key Go to [app.chariow.com](https://app.chariow.com) and log in to your account. Click on **Settings** in the sidebar. Select **API Keys** from the settings menu. Click **Create API Key**, give it a descriptive name, choose its scopes, and copy the generated key. Copy your API key immediately after creation. For security reasons, the full key is only shown once. API keys start with `sk_`. Store them as opaque strings: do not parse them or rely on their length. ## Scopes Every public API endpoint requires one or more scopes. Grant each key only the scopes its integration needs: a key that only reads products cannot start a checkout or revoke a licence, even if it leaks. ### Available scopes | Scope | Label | Grants access to | | - | - | - | | `store.read` | Read store | Store name, currency, settings and public information. | | `products.read` | Read products | Products, prices and their published details. | | `sales.read` | Read sales | Sales, their status and amounts. | | `customers.read` | Read customers | Customer list and purchase history. | | `customers.pii.read` | Read customer contact details | Customer email addresses and phone numbers. Includes `customers.read`. | | `discounts.read` | Read discounts | Discount codes and their conditions. | | `licenses.read` | Read licences | Licence keys and their activations. | | `licenses.write` | Manage licences | Activate and revoke licence keys. Includes `licenses.read`. | | `affiliates.read` | Read affiliates | Affiliate profiles and codes. | | `affiliates.write` | Invite affiliates | Send affiliate invitations. Includes `affiliates.read`. | | `webhooks.read` | Read webhooks | Pulse webhooks configured on the store. | | `webhooks.write` | Manage webhooks | Create and delete the Make, Zapier and n8n connections. Includes `webhooks.read`. | | `checkout.write` | Create checkouts | Start a checkout for a product on behalf of a customer. | A write scope always includes its read scope, so granting `licenses.write` also grants `licenses.read`. ### Scopes required by each endpoint | Endpoint | Required scopes | | - | - | | `GET /v1/store` | `store.read` | | `GET /v1/products`, `GET /v1/products/{productId}` | `products.read` | | `POST /v1/checkout` | `checkout.write` | | `GET /v1/sales`, `GET /v1/sales/{saleId}` | `sales.read` | | `GET /v1/customers`, `GET /v1/customers/{customerId}` | `customers.read` **and** `customers.pii.read` | | `GET /v1/licenses`, `GET /v1/licenses/{licenseKey}`, `GET /v1/licenses/{licenseKey}/activations` | `licenses.read` | | `POST /v1/licenses/{licenseKey}/activate`, `POST /v1/licenses/{licenseKey}/revoke` | `licenses.write` | | `GET /v1/discounts`, `GET /v1/discounts/{discountId}` | `discounts.read` | | `GET /v1/pulses`, `GET /v1/pulses/{pulseId}` | `webhooks.read` | | `GET /v1/affiliates/{affiliateCode}` | `affiliates.read` | | `POST /v1/affiliates/invitations` | `affiliates.write` | The customer endpoints return contact details, so they need both customer scopes. Granting `customers.pii.read` alone is enough, because it includes `customers.read`. ### How scopes are assigned * **Choosing scopes**: pick the scopes when you create the key. If you do not pick any, the key receives every scope your team role allows. * **Changing scopes**: you can change the scopes of an existing key from **Settings** β†’ **API Keys** without regenerating it. Integrations using the key keep working with the new permissions. * **Team roles**: a key can never hold more than the role of the team member who creates it. For example, a member with the Support role cannot grant `licenses.write`, `checkout.write`, `affiliates.write` or `webhooks.write`. * **Role changes**: if the creator's role is downgraded, their keys lose the scopes the new role no longer allows. Promoting the creator does not add scopes to existing keys. * **Deactivated members**: when a team member loses access to the store, the API keys and MCP connections they created are deleted and stop working immediately. Reactivating the member does not restore them. * **Existing keys**: keys created before scopes were introduced received every scope their creator's role allowed at the time. * **New scopes**: scopes added to the catalogue later are never granted automatically to existing keys. Add them to a key yourself when an integration needs them. ## Making Authenticated Requests Include your API key in the `Authorization` header of every request: ```bash theme={null} Authorization: Bearer YOUR_API_KEY ``` ### Example Request ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/store', { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); ``` ```python Python theme={null} import requests headers = { 'Authorization': 'Bearer YOUR_API_KEY' } response = requests.get('https://api.chariow.com/v1/store', headers=headers) ``` ```php PHP theme={null} $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.chariow.com/v1/store'); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY' ]); ``` ## Key Security Best Practices Give each key only the scopes its integration needs. A reporting script needs `sales.read`, not `licenses.write`. Store API keys in environment variables, not in your codebase: ```bash theme={null} # .env file CHARIOW_API_KEY=your_api_key # Access in your code process.env.CHARIOW_API_KEY ``` Create separate API keys for development, staging, and production environments. This limits the impact if a key is compromised. Periodically create new keys and delete old ones. This limits the window of opportunity for compromised keys. Regularly review your API key usage in the dashboard. Look for unusual patterns that might indicate unauthorised access. Never expose your API key in client-side code (JavaScript running in browsers). All API calls should be made from your server. ## Authentication Errors If the key is missing or invalid, you'll receive a `401 Unauthorised` response: ```json theme={null} { "message": "API key is missing. Please provide a valid API key. Help: https://docs.chariow.com", "errors": [] } ``` | Message | Cause | Solution | | - | - | - | | `API key is missing. Please provide a valid API key. Help: https://docs.chariow.com` | No `Authorization: Bearer` header | Add the header to your request | | `Invalid API key. Please check again. Help: https://docs.chariow.com` | Key is malformed, was deleted, or its creator is no longer an active team member | Check the key, or create a new one in your dashboard | ## Scope Errors If the key is valid but lacks a scope the endpoint requires, you'll receive a `403 Forbidden` response that lists the missing scopes: ```http theme={null} HTTP/1.1 403 Forbidden WWW-Authenticate: Bearer error="insufficient_scope", scope="checkout.write" ``` ```json theme={null} { "message": "This credential is missing the required scope: checkout.write. Update its permissions in your dashboard.", "data": [], "errors": { "scopes": ["checkout.write"] } } ``` * `errors.scopes` lists every missing scope. Use it, rather than the `message`, in your code: the message is translated into the request language. * The `WWW-Authenticate` header carries the same scopes, separated by spaces. * To fix it, add the missing scopes to the key in **Settings** β†’ **API Keys**, or ask a team member whose role allows them. ## Rate Limiting API keys are subject to rate limiting to ensure fair usage: * **100 requests per minute** per API key for all endpoints except checkout * **100 requests per minute** per API key for `POST /v1/checkout`, counted separately When rate limited, you'll receive a `429 Too Many Requests` response. See [Rate Limits](/en/resources/rate-limits) for details. Need higher rate limits? Contact our support team at [support@chariow.com](mailto:support@chariow.com). ## Next Steps Explore the complete API documentation Learn more about rate limiting # Introduction Source: https://chariow.dev/en/introduction/overview Welcome to Chariow - The all-in-one platform for selling digital products ## What is Chariow? Chariow is a powerful e-commerce platform designed specifically for creators and businesses selling digital products. Whether you're selling courses, software licenses, downloadable files, or digital services, Chariow provides everything you need to manage your store, process payments, and deliver products to your customers. Get up and running with the Chariow API in minutes Learn how to authenticate your API requests Explore the complete API documentation Connect Chariow to AI assistants via Model Context Protocol ## Base URL All API requests should be made to: ``` https://api.chariow.com/v1 ``` ## Response Format All API responses are JSON: * A single resource is wrapped in `data`. * A list returns `data` (an array) and `pagination` at the top level. * An error returns `message` and `errors`. Validation (`422`), authentication (`401`), missing scope (`403`) and not found (`404`) errors also carry an empty `data` array. ### Successful Response ```json theme={null} { "data": { "id": "prd_abc123", "name": "Premium Course", "type": "course" } } ``` ### Error Response ```json theme={null} { "message": "The email field is required. (and 1 more error)", "data": [], "errors": { "email": ["The email field is required."], "product_id": ["The selected product id is invalid."] } } ``` ### Pagination List endpoints use cursor-based pagination: ```json theme={null} { "data": [...], "pagination": { "count": 10, "path": "https://api.chariow.com/v1/products", "per_page": 10, "next_cursor": "eyJpZCI6NTB9", "next_page_url": "https://api.chariow.com/v1/products?cursor=eyJpZCI6NTB9", "prev_cursor": null, "prev_page_url": null, "has_more_pages": true, "has_pages": true } } ``` `per_page` defaults to 10 and accepts up to 100. Pass `next_cursor` as the `cursor` query parameter to fetch the next page, and stop when `has_more_pages` is `false`: ``` GET /v1/products?cursor=eyJpZCI6NTB9&per_page=20 ``` ## Rate Limits The API implements rate limiting to ensure fair usage: | Endpoint Type | Limit | | - | - | | `POST /v1/checkout` | 100 requests/minute per API key | | All other API requests | 100 requests/minute per API key | Checkout has its own bucket, so a sync job reading sales or products never blocks your buyers from paying. Each response includes `X-RateLimit-Limit` and `X-RateLimit-Remaining`. When you exceed the limit, you receive a `429 Too Many Requests` response with a `Retry-After` header: ```json theme={null} { "message": "Too Many Attempts.", "errors": [] } ``` See [Rate Limits](/en/resources/rate-limits) for the headers and a retry strategy. ## Key Features Sell any type of digital product: * **Downloadable files** - PDFs, videos, music, software * **Online courses** - With chapters, lessons, and progress tracking * **Software licenses** - Automatic license key generation and activation * **Bundles** - Combine multiple products into one offering * **Services** - Book consultations or digital services Multiple pricing options to suit your business: * One-time payments * Pay-what-you-want pricing * Free products for lead generation * Discount codes and promotions Complete customer lifecycle management: * Customer profiles and purchase history * License key management * Automated email notifications * Customer portal access Build custom integrations with our comprehensive API: * RESTful API with JSON responses * Pulse notifications for real-time events * MCP integration for AI assistants * SDK support (coming soon) ## Use Cases Build and sell online courses with video hosting, progress tracking, and completion certificates. Distribute software with automatic license key generation, activation limits, and expiration management. Sell templates, design assets, and digital resources with instant delivery. Monetise ebooks, music, photography, and other creative works. ## Getting Help Browse our knowledge base Join our community Contact our support team # Quick Start Source: https://chariow.dev/en/introduction/quickstart Get started with the Chariow API in minutes This guide will help you make your first API request to Chariow in under 5 minutes. ## Prerequisites Before you begin, you'll need: A Chariow account with an active store An API key from your store settings ## Step 1: Get Your API Key Go to [app.chariow.com](https://app.chariow.com) and sign in to your account. Click on **Settings** β†’ **API Keys** in your store dashboard. Click **Create API Key**, give it a name (e.g., "Development"), choose its scopes, and copy the generated key. Your API key will only be shown once. Make sure to copy and store it securely. This guide calls three endpoints, so the key needs the `store.read`, `products.read` and `checkout.write` scopes. If you do not choose any scopes, the key receives every scope your team role allows. See [Authentication](/en/introduction/authentication#scopes). ## Step 2: Make Your First Request Let's verify your API key by fetching your store information: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer sk_live_your_api_key_here" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/store', { headers: { 'Authorization': 'Bearer sk_live_your_api_key_here' } }); const data = await response.json(); console.log(data); ``` ```python Python theme={null} import requests response = requests.get( 'https://api.chariow.com/v1/store', headers={'Authorization': 'Bearer sk_live_your_api_key_here'} ) print(response.json()) ``` ```php PHP theme={null} $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.chariow.com/v1/store'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer sk_live_your_api_key_here' ]); $response = curl_exec($ch); curl_close($ch); print_r(json_decode($response, true)); ``` You should receive a response like this: ```json Response theme={null} { "data": { "id": "store_abc123xyz", "name": "My Awesome Store", "description": "Selling digital products", "logo_url": "https://cdn.chariow.com/stores/logo.png", "url": "https://mystore.chariow.com", "status": "active" } } ``` ## Step 3: List Your Products Now let's fetch your published products: ```bash cURL theme={null} curl -X GET "https://api.chariow.com/v1/products" \ -H "Authorization: Bearer sk_live_your_api_key_here" ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/products', { headers: { 'Authorization': 'Bearer sk_live_your_api_key_here' } }); const data = await response.json(); console.log(data); ``` ## Step 4: Initiate a Checkout Create a checkout session to process a sale: ```bash cURL theme={null} curl -X POST "https://api.chariow.com/v1/checkout" \ -H "Authorization: Bearer sk_live_your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "product_id": "prd_abc123", "email": "customer@example.com", "first_name": "John", "last_name": "Doe", "phone": { "number": "1234567890", "country_code": "US" } }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.chariow.com/v1/checkout', { method: 'POST', headers: { 'Authorization': 'Bearer sk_live_your_api_key_here', 'Content-Type': 'application/json' }, body: JSON.stringify({ product_id: 'prd_abc123', email: 'customer@example.com', first_name: 'John', last_name: 'Doe', phone: { number: '1234567890', country_code: 'US' } }) }); const data = await response.json(); console.log(data); ``` ## What's Next? Learn more about API authentication Learn how to work with products Master the checkout flow Set up real-time notifications # MCP Overview Source: https://chariow.dev/en/mcp/overview Connect your Chariow store to AI assistants like Claude and ChatGPT The Chariow MCP server lets AI tools access live data from your store through the [Model Context Protocol](https://modelcontextprotocol.io) standard. Once connected, you can query sales, customers, products, and analytics using natural language. ## Why use Chariow MCP? One-click OAuth authentication. No API keys to manage. Read products, customers, sales, licences, discounts, analytics and more, within the limits of your team role. Data formatted for AI assistants to understand and use effectively. ## What can you do? | Use case | Example prompt | | - | - | | **Check sales** | "Show me today's completed sales" | | **Find customers** | "Find the customer with email [marie@example.com](mailto:marie@example.com)" | | **Analyse performance** | "What's my conversion rate this month?" | | **Manage licenses** | "How many activations are left on license ABC-123?" | | **Search everything** | "Search for 'premium' across my store" | ## How it works Chariow MCP connection flow 1. You connect your AI tool to `https://mcp.chariow.com/public` 2. OAuth authenticates you with your Chariow account 3. You choose the store to connect and approve access on the Chariow consent screen 4. The AI can now read your store data through up to 46 read-only tools. The tools it sees depend on your team role in that store ## Supported AI tools | Tool | Connection method | Setup guide | | - | - | - | | Claude Desktop | Custom connector | [View guide](/en/mcp/setup#claude) | | Claude.ai (Pro/Max) | Custom connector | [View guide](/en/mcp/setup#claude) | | ChatGPT | Connector | [View guide](/en/mcp/setup#chatgpt) | | Cursor | Remote MCP server | [View guide](/en/mcp/setup#cursor) | | Windsurf | Remote MCP server | [View guide](/en/mcp/setup#windsurf) | ## MCP endpoint Connect your AI tools to: ``` https://mcp.chariow.com/public ``` This endpoint uses the Streamable HTTP transport. The legacy HTTP+SSE transport is not supported. ## Get started Connect your AI tool in minutes See all 46 available tools # Security best practices Source: https://chariow.dev/en/mcp/security Understand data sharing and security when using Chariow MCP When you connect an AI tool to your Chariow store via MCP, you're granting that tool access to your store data. This page explains what data is shared and how to stay secure. ## What data is accessible? Once connected, the AI tool can read the data your team role allows in the store you chose on the consent screen. With full access, this includes: | Data type | What's included | | - | - | | **Store** | Name, description, logo, URL, settings, subscription status | | **Products** | Names, descriptions, pricing, images, categories, sales counts | | **Customers** | Names, emails, phone numbers, purchase history | | **Sales** | Amounts, payment details, shipping addresses, customer info | | **Discounts** | Codes, values, usage counts, restrictions | | **Licenses** | Keys, activation counts, status, expiry dates | | **Analytics** | Revenue, visits, conversion rates, traffic sources | | **Other** | Workflows, ratings, settlements, courses, coaching sessions, banners, popups, store pages, affiliates, integrations (without credentials) and team activity | Tools outside your role are neither listed nor callable. For example, a team member with the Support role cannot let an AI tool list team members or read analytics. See [Supported tools](/en/mcp/tools) for the permission each tool needs. **All MCP tools are read-only.** The AI cannot modify your store, create products, or process transactions. However, it can read everything your role allows in the connected store. ## Who can see your data? When you connect via MCP: 1. **Your AI tool** (Claude, ChatGPT, etc.) receives your store data to answer your questions 2. **The AI provider** may process and store this data according to their privacy policy 3. **Chariow** acts as the bridge: it receives the tool calls, never your conversation **Review your AI provider's privacy policy.** Each provider handles data differently. Chariow is not responsible for how third-party AI providers process, store, or use your data. ## Security recommendations ### Only connect trusted tools Only use MCP connections from AI providers you trust. Verify you're connecting to official tools: * Claude from Anthropic * ChatGPT from OpenAI * Cursor, Windsurf, or other reputable tools The Chariow consent screen marks the clients Chariow has reviewed as verified and shows a warning for every other client. Read the client name and redirect address before you approve, and deny any request you did not start yourself. ### Verify the MCP endpoint Always confirm you're connecting to the official Chariow endpoint: * `https://mcp.chariow.com/public` ### Be mindful of prompts AI assistants follow instructions, including those hidden in data. Avoid: * Pasting untrusted content into conversations * Asking the AI to process external URLs or files without review ### Review access regularly Periodically check your connected applications: 1. Go to your [Chariow Dashboard](https://app.chariow.com) 2. Navigate to **Settings** β†’ **API Keys** 3. Revoke any connections you no longer use ### Use separate stores for testing If you're experimenting with MCP integrations, consider using a test store rather than your production store with real customer data. ## What Chariow does * **OAuth authentication**: Secure authorisation flow with PKCE and no API keys stored in config files * **Read-only access**: Each connection receives only the read scopes your team role allows, and every tool is read-only * **Role enforcement**: Tools follow the permissions of the team member who approved the connection, and connections lose access when that member's role is downgraded * **Automatic revocation**: Connections unused for 30 days are revoked, and connections are deleted when the member who approved them loses access to the store * **Activity log**: Actions recorded in your team activity log show whether they came from the dashboard, the API or an MCP connection * **Rate limiting**: 60 requests per minute per connection prevents abuse * **HTTPS only**: All connections are encrypted ## What Chariow does not do * Receive or store your conversations with AI tools * Share your data with other users or third parties * Control how AI providers process your data Chariow logs the requests your AI tool sends to the MCP server, such as the tool called and its parameters, for security and troubleshooting. ## Revoking access To disconnect an AI tool immediately: 1. Go to **Settings** β†’ **API Keys** in your Chariow Dashboard 2. Find the MCP connection 3. Click **Revoke** The AI tool will lose access to your store data immediately. *** ## Next steps Connect your AI tool See available tools # Get started with MCP Source: https://chariow.dev/en/mcp/setup Connect your Chariow store to Claude, ChatGPT, Cursor, and other AI tools This guide explains how to connect your AI tool to your Chariow store using the Model Context Protocol. ## MCP endpoint All AI tools connect to the same endpoint: ``` https://mcp.chariow.com/public ``` This endpoint uses the Streamable HTTP transport. The legacy HTTP+SSE transport is not supported. *** ## Claude Claude supports MCP through custom connectors on both Claude Desktop and Claude.ai (Pro/Max plans). In Claude Desktop or Claude.ai, go to **Settings** β†’ **Connectors**. Click **Add custom connector** and enter: * **URL:** `https://mcp.chariow.com/public` Click **Add**. You'll be redirected to Chariow to authorise access to your store. Open a new conversation and ask Claude about your store. For example: "Show me my recent sales". Custom connectors require Claude Pro, Max, Team, or Enterprise. See [Claude's MCP documentation](https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp) for details. *** ## ChatGPT ChatGPT supports MCP connectors for accessing external tools. Go to **Settings** β†’ **Apps & Connectors** β†’ **Advanced settings** and enable developer mode. Navigate to **Settings** β†’ **Connectors** β†’ **Create** and enter: * **Connector name:** Chariow * **Description:** Access your Chariow store data * **Connector URL:** `https://mcp.chariow.com/public` Complete the OAuth flow to connect your Chariow account. Start a new chat, click **+**, select **More**, and choose Chariow from your available tools. ChatGPT will show tool-call confirmations. Write operations require approval unless you choose to remember your decision. *** ## Cursor Cursor connects to remote MCP servers through configuration files. Go to **Settings** β†’ **Features** β†’ **MCP**. Click **Add new MCP server** and enter the Chariow URL, or create a configuration file at `.cursor/mcp.json`: ```json theme={null} { "mcpServers": { "chariow": { "url": "https://mcp.chariow.com/public" } } } ``` When you first use a Chariow tool, you'll be prompted to authenticate via OAuth. See [Cursor's MCP documentation](https://cursor.com/docs/context/mcp) for more configuration options. *** ## Windsurf Windsurf supports remote MCP servers through its extensions settings. Go to **Settings** β†’ **Extensions** β†’ **MCP**. Add a new MCP server with: ```json theme={null} { "mcpServers": { "chariow": { "url": "https://mcp.chariow.com/public" } } } ``` Complete the OAuth flow when prompted to connect your Chariow account. *** ## Claude Code (CLI) For Claude Code, add the Chariow server using the CLI: ```bash theme={null} claude mcp add --transport http chariow https://mcp.chariow.com/public ``` You'll be prompted to authenticate via OAuth on first use. *** ## Other MCP clients Any MCP client that supports remote servers with OAuth can connect. The server follows the MCP authorisation specification, so most clients only need the endpoint URL and discover the rest automatically. | Item | Value | | - | - | | Transport | Streamable HTTP | | Protected resource metadata | `https://mcp.chariow.com/.well-known/oauth-protected-resource` | | Authorisation server metadata | `https://mcp.chariow.com/.well-known/oauth-authorization-server` | | Client registration | Dynamic (RFC 7591), public clients only (`token_endpoint_auth_method: none`) | | Grant type | `authorization_code` with PKCE (`S256` only) | | OAuth scope | `store:mcp` | Registration rules: * Any `https` redirect URI is accepted. * Loopback redirect URIs (`http://localhost`, `http://127.0.0.1`, `http://[::1]`) are accepted on any port, for native clients. * Custom schemes such as `cursor://` or `claude://` are accepted only for clients Chariow has verified. Plain `http` outside loopback, and URIs with credentials or a fragment, are rejected. * A registered client stays valid for 30 days. Registration is limited to 10 requests per minute and 100 per day per IP address. The consent screen shows clients Chariow has reviewed as verified, and warns about every other client. Check the client name and redirect address before you approve. The access token is a store API key dedicated to the connection. It carries the read scopes your team role allows, never write scopes. No refresh token is issued: when the connection is revoked or expires, the client must go through the authorisation flow again. *** ## Verify connection After setup, verify your connection is working: 1. Start a new conversation with your AI tool 2. Ask: **"Show me my Chariow store information"** 3. The AI should display your store name, URL, and settings Try these example prompts: * "List my recent sales" * "How many customers do I have?" * "What are my best-selling products?" *** ## Troubleshooting * Verify the URL is correct: `https://mcp.chariow.com/public` * Restart your AI tool completely * Try removing and re-adding the connector * Ensure you're logged into your Chariow account * Check that your store is active and that you are an active member of its team * Clear browser cookies and try again * If the client reports an invalid redirect URI, it uses a redirect address Chariow does not accept (see [Other MCP clients](#other-mcp-clients)) * Some tools are hidden by your team role: a tool outside your role is neither listed nor callable (see [Supported tools](/en/mcp/tools)) * Restart your AI tool * For file-based config, verify JSON syntax is valid * In ChatGPT, click **Refresh** in Connectors settings The MCP server allows 60 requests per minute per connection. Wait a moment before continuing. * Connections unused for 30 days are revoked automatically * Connections are deleted when the team member who approved them loses access to the store * Reconnecting the same client from the same account replaces the previous token In each case, remove the connector and add it again to authorise a new connection. *** ## Revoke access To disconnect an AI tool from your store: 1. Go to your [Chariow Dashboard](https://app.chariow.com) 2. Navigate to **Settings** β†’ **API Keys** 3. Find the MCP connection and click **Revoke** *** ## Next steps See all 46 available tools Learn about data sharing and security # Supported tools Source: https://chariow.dev/en/mcp/tools All MCP tools, resources and prompts for querying your Chariow store The Chariow MCP server provides 46 read-only tools for accessing your store data. All tools are idempotent and cannot modify your store. The tools an AI assistant can see depend on the role of the team member who approved the connection. A tool outside that role is neither listed nor callable, and returns "Tool not found" if the assistant calls it anyway. The **Requires** column shows the team permission each tool needs; "view" means view-only or full access. ## Tools reference ### Store and search | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `get_store` | Get the store profile, settings, social links and sales totals | Any team member | "Show me my store information" | | `global_search` | Search products, discounts, customers, pulses, sales and workflows at once | At least one of Products, Discounts, Customers, Pulses, Sales or Workflows (view); sections the role cannot view are left empty | "Search for 'premium' in my store" | ### Products | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_products` | List products with filters (search, status, category, type) | Products (view) | "List my published products" | | `get_product` | Get full details for a product | Products (view) | "Show me details for product prd\_abc123" | | `get_product_details` | Get one sub-entity of a product: FAQs, price variants, files, custom fields, bundle products, SEO or licence settings | Products (view) | "Show the FAQs of my ebook" | ### Customers | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_customers` | List customers with optional search | Customers (view) | "Find customers named Marie" | | `get_customer` | Get a customer profile by ID or email address | Customers (view) | "Show me customer [marie@example.com](mailto:marie@example.com)" | ### Sales | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_sales` | List sales with filters (status, customer, date range) | Sales (view) | "Show me today's completed sales" | | `get_sale` | Get complete details for a sale, including payment and shipping | Sales (view) | "Get details for sale sal\_xyz789" | ### Discounts | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_discounts` | List discount codes with optional filters | Discounts (view) | "List my active discount codes" | | `get_discount` | Get a discount configuration and usage stats | Discounts (view) | "How many times has SUMMER20 been used?" | ### Licences | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_licenses` | List issued licences with filters (status, customer, product) | Products (view) | "List all active licences" | | `get_license` | Get details for a licence key | Products (view) | "Check licence ABC-123-XYZ-789" | | `get_license_activations` | View the activation history of a licence | Products (view) | "Show activations for licence ABC-123" | ### Pulses (webhooks) | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_pulses` | List webhook configurations | Pulses (view) | "List my webhooks" | | `get_pulse` | Get a webhook and its trigger configuration | Pulses (view) | "Show me pulse pulse\_abc123" | ### Workflows | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_workflows` | List automation workflows | Workflows (view) | "List my workflows" | | `get_workflow` | Get a workflow with its triggers, actions and products | Workflows (view) | "Show me workflow wflow\_abc123" | | `list_workflow_runs` | List the runs of a workflow, or get one run | Workflows (view) | "Why did my last workflow run fail?" | ### Ratings and settlements | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `get_ratings` | List ratings, get one rating, or get aggregate stats | Ratings (view) | "What do customers say about my course?" | | `get_settlements` | List settlements, or get one settlement with its sales | Settlements (view) | "When is my next payout?" | ### Courses and coaching | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `get_course_content` | Get the chapters of a course, or the lessons of a chapter | Products (view) | "List the chapters of my course" | | `get_course_progress` | Get enrolments, one student's progress, or course analytics | Products (view) | "How many students finished my course?" | | `list_coaching_sessions` | List coaching sessions, or get one session | Products (view) | "What coaching sessions do I have this week?" | | `get_coaching_product_config` | Get the coaching settings and weekly availability of a coaching product | Products (view) | "When am I available for coaching?" | ### Marketing and store pages | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `get_banners` | List banners, or get one banner | Banners (view) | "Which banners are published?" | | `get_popups` | List popups, or get one popup | Popups (view) | "List my popups" | | `get_store_pages` | List store pages, or get the full content of one page type | Appearance settings (view) | "Show my terms of service" | ### Affiliate programme | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_affiliates` | List affiliates with performance metrics | Affiliates (view) | "Who are my best affiliates?" | | `get_affiliate` | Get an affiliate with performance stats | Affiliates (view) | "Show affiliate aff\_abc123" | | `list_affiliation_offers` | List products offered to affiliates | Affiliates (view) | "Which products can affiliates promote?" | | `list_affiliate_commissions` | List affiliate commissions | Affiliates (view) | "Which commissions are still pending?" | | `get_affiliate_analytics` | Get aggregate affiliate programme analytics | Analytics (view) | "How much did affiliates sell this month?" | ### Integrations and team | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `get_integrations` | List integrations, or get one integration. Credentials are never returned | Integrations (view) | "Which integrations are connected?" | | `list_team_members` | List team members or pending invitations | Team (full access) | "Who is on my team?" | | `list_team_member_activities` | List the team activity log, or get one activity | Team (full access) | "Who changed my product prices yesterday?" | ### Analytics | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `get_store_analytics` | Get a store performance overview (visits, sales, products, customers) | Analytics (view) | "Show me store analytics for this month" | | `get_sales_analytics` | Get revenue and sales analysis | Analytics (view) | "What's my revenue this month?" | | `get_customer_analytics` | Get customer insights and top customers | Analytics (view) | "Who are my top 5 customers?" | | `get_visits_analytics` | Get traffic analysis (sources, referrers, devices, locations) | Analytics (view) | "Where is my traffic coming from?" | | `get_conversion_rate_analytics` | Get conversion rates by device, country and product | Analytics (view) | "What's my conversion rate?" | ### Help and documentation | Tool | Description | Requires | Sample prompt | | - | - | - | - | | `list_doc_pages` | List the Chariow developer documentation pages | Any team member | "Which docs pages cover checkout?" | | `get_doc_page` | Get the full Markdown content of a documentation page | Any team member | "Explain how licence activation works" | | `list_help_center_articles` | List help centre articles (EN/FR) | Any team member | "Is there a help article about payouts?" | | `get_help_center_article` | Get the full content of a help centre article | Any team member | "Read me the article about custom domains" | | `read_skill` | Load a Chariow skill: a ready-made playbook for recurring questions (payments, integrations, sales lifecycle, growth, refunds) | Any team member | "Why are my sales failing?" | *** ## Tool details List tools use cursor-based pagination: each response includes `next_cursor`, `prev_cursor` and `has_more`. Pass `next_cursor` as `cursor` to get the next page. ### get\_store Get the store profile, settings, social links and sales totals. No parameters required. *** ### global\_search Search products, discounts, customers, pulses, sales and workflows at once. | Parameter | Type | Required | Description | | - | - | - | - | | `query` | string | Yes | Search term | | `limit` | integer | No | Results per entity type (1-10). Default: 5 | | `from` | string | No | Start date for date-ranged entities (YYYY-MM-DD) | | `to` | string | No | End date for date-ranged entities (YYYY-MM-DD) | *** ### list\_products List products with filters (search, status, category, type). | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name or slug | | `status` | string | No | Filter: `draft`, `published`, `archived` | | `category` | string | No | Filter by category | | `type` | string | No | Filter by product type (e.g. `downloadable`, `course`) | *** ### get\_product Get full details for a product. | Parameter | Type | Required | Description | | - | - | - | - | | `product_id` | string | Yes | Product ID (`prd_xxx`) or slug | *** ### get\_product\_details Get one sub-entity of a product: FAQs, price variants, files, custom fields, bundle products, SEO or licence settings. | Parameter | Type | Required | Description | | - | - | - | - | | `product_id` | string | Yes | Product ID (`prd_xxx`) or slug | | `include` | string | Yes | `faqs`, `price_variants`, `files`, `custom_fields`, `bundle_products`, `seo_settings` or `license_settings` | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | *** ### list\_customers List customers with optional search. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name or email | *** ### get\_customer Get a customer profile by ID or email address. | Parameter | Type | Required | Description | | - | - | - | - | | `customer_id` | string | Yes | Customer ID (`cus_xxx`) or email address (case-insensitive) | *** ### list\_sales List sales with filters (status, customer, date range). | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 10 | | `cursor` | string | No | Pagination cursor from the previous response | | `status` | string | No | Filter by sale status (e.g. `completed`, `failed`) | | `customer_id` | string | No | Filter by customer ID | | `start_date` | string | No | From date (YYYY-MM-DD) | | `end_date` | string | No | To date (YYYY-MM-DD) | *** ### get\_sale Get complete details for a sale, including payment and shipping. | Parameter | Type | Required | Description | | - | - | - | - | | `sale_id` | string | Yes | Sale ID (`sal_xxx`) | *** ### list\_discounts List discount codes with optional filters. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `status` | string | No | Filter: `active`, `expired`, `disabled` | | `search` | string | No | Search by code or name | *** ### get\_discount Get a discount configuration and usage stats. | Parameter | Type | Required | Description | | - | - | - | - | | `discount_id` | string | Yes | Discount ID | *** ### list\_licenses List issued licences with filters (status, customer, product). | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `status` | string | No | Filter: `active`, `expired`, `revoked` | | `customer_id` | string | No | Filter by customer ID | | `product_id` | string | No | Filter by product ID | *** ### get\_license Get details for a licence key. | Parameter | Type | Required | Description | | - | - | - | - | | `license_key` | string | Yes | Licence key | *** ### get\_license\_activations View the activation history of a licence. | Parameter | Type | Required | Description | | - | - | - | - | | `license_key` | string | Yes | Licence key | *** ### list\_pulses List webhook configurations. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by URL or trigger | *** ### get\_pulse Get a webhook and its trigger configuration. | Parameter | Type | Required | Description | | - | - | - | - | | `pulse_id` | string | Yes | Pulse ID | *** ### list\_workflows List automation workflows. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name or trigger type | *** ### get\_workflow Get a workflow with its triggers, actions and products. | Parameter | Type | Required | Description | | - | - | - | - | | `workflow_id` | string | Yes | Workflow ID (`wflow_xxx`) | *** ### list\_workflow\_runs List the runs of a workflow, or get one run. | Parameter | Type | Required | Description | | - | - | - | - | | `workflow_id` | string | Yes | Workflow ID (`wflow_xxx`) | | `run_id` | string | No | Run ID (`wfrun_xxx`) to get a single run | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `status` | string | No | Filter: `pending`, `running`, `completed`, `failed` | | `start_date` | string | No | From date (YYYY-MM-DD) | | `end_date` | string | No | To date (YYYY-MM-DD) | *** ### get\_ratings List ratings, get one rating, or get aggregate stats. | Parameter | Type | Required | Description | | - | - | - | - | | `rating_id` | string | No | Rating ID (`slr_xxx`) to get a single rating | | `summary_only` | boolean | No | Return only aggregate statistics | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search in comments | | `product_id` | string | No | Filter by product ID | | `is_thumbs_up` | boolean | No | `true` for positive, `false` for negative ratings | | `from` | string | No | From date (YYYY-MM-DD) | | `to` | string | No | To date (YYYY-MM-DD) | *** ### get\_settlements List settlements, or get one settlement with its sales. | Parameter | Type | Required | Description | | - | - | - | - | | `settlement_id` | string | No | Settlement ID (`stl_xxx`) to get one settlement with its sales | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search settlements | | `status` | string | No | Filter: `pending`, `paid` | | `start_date` | string | No | From date (YYYY-MM-DD) | | `end_date` | string | No | To date (YYYY-MM-DD) | *** ### get\_course\_content Get the chapters of a course, or the lessons of a chapter. | Parameter | Type | Required | Description | | - | - | - | - | | `product_id` | string | Yes | Course product ID (`prd_xxx`) | | `chapter_id` | string | No | Chapter ID (`chp_xxx`) to list its lessons | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by title or description | *** ### get\_course\_progress Get enrolments, one student's progress, or course analytics. | Parameter | Type | Required | Description | | - | - | - | - | | `product_id` | string | Yes | Course product ID (`prd_xxx`) | | `customer_id` | string | No | Customer ID for one student's detailed progress | | `summary_only` | boolean | No | Return only aggregate analytics | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search enrolments by student name or email | | `status` | string | No | Filter: `not_started`, `in_progress`, `completed` | *** ### list\_coaching\_sessions List coaching sessions, or get one session. | Parameter | Type | Required | Description | | - | - | - | - | | `session_id` | string | No | Session ID to get a single session | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search in session notes | | `status` | string | No | Filter: `pending`, `confirmed`, `completed`, `cancelled`, `no_show` | | `product_id` | string | No | Filter by product ID | | `customer_id` | string | No | Filter by customer ID | | `from` | string | No | From date (YYYY-MM-DD) | | `to` | string | No | To date (YYYY-MM-DD) | | `upcoming` | boolean | No | Only upcoming sessions | | `past` | boolean | No | Only past sessions | *** ### get\_coaching\_product\_config Get the coaching settings and weekly availability of a coaching product. | Parameter | Type | Required | Description | | - | - | - | - | | `product_id` | string | Yes | Coaching product ID (`prd_xxx`) | *** ### get\_banners List banners, or get one banner. | Parameter | Type | Required | Description | | - | - | - | - | | `banner_id` | string | No | Banner ID to get a single banner | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name | | `status` | string | No | Filter: `draft`, `published` | *** ### get\_popups List popups, or get one popup. | Parameter | Type | Required | Description | | - | - | - | - | | `popup_id` | string | No | Popup ID to get a single popup | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name | | `status` | string | No | Filter: `draft`, `published` | *** ### get\_store\_pages List store pages, or get the full content of one page type. | Parameter | Type | Required | Description | | - | - | - | - | | `page_type` | string | No | Page type to get its full content (e.g. `terms_of_service`, `privacy_policy`) | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | *** ### list\_affiliates List affiliates with performance metrics. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name or email | | `status` | string | No | Filter: `active`, `suspended` | *** ### get\_affiliate Get an affiliate with performance stats. | Parameter | Type | Required | Description | | - | - | - | - | | `affiliate_id` | string | Yes | Affiliate ID | *** ### list\_affiliation\_offers List products offered to affiliates. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `status` | string | No | Filter: `active`, `paused`, `removed` | *** ### list\_affiliate\_commissions List affiliate commissions. | Parameter | Type | Required | Description | | - | - | - | - | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search commissions | | `status` | string | No | Filter: `pending`, `settled` | | `affiliate_id` | string | No | Filter by affiliate ID | | `start_date` | string | No | From date (YYYY-MM-DD) | | `end_date` | string | No | To date (YYYY-MM-DD) | *** ### get\_affiliate\_analytics Get aggregate affiliate programme analytics. | Parameter | Type | Required | Description | | - | - | - | - | | `start_date` | string | Yes | Start date (YYYY-MM-DD) | | `end_date` | string | Yes | End date (YYYY-MM-DD) | *** ### get\_integrations List integrations, or get one integration. Credentials are never returned. | Parameter | Type | Required | Description | | - | - | - | - | | `integration_id` | string | No | Integration ID (`int_xxx`) to get a single integration | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by provider or account name | *** ### list\_team\_members List team members or pending invitations. | Parameter | Type | Required | Description | | - | - | - | - | | `type` | string | No | Set to `invitations` to list pending invitations | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | | `search` | string | No | Search by name or email (members), email or role (invitations) | | `status` | string | No | Filter members by status (`active`) | *** ### list\_team\_member\_activities List the team activity log, or get one activity. | Parameter | Type | Required | Description | | - | - | - | - | | `activity_id` | string | No | Activity ID to get a single activity | | `team_member_id` | string | No | Filter by team member ID (`mem_xxx`) | | `action` | string | No | Filter by action (e.g. `product_updated`) | | `search` | string | No | Search across action, IP address and user agent | | `per_page` | integer | No | Results per page (1-100). Default: 20 | | `cursor` | string | No | Pagination cursor from the previous response | *** ### get\_store\_analytics Get a store performance overview (visits, sales, products, customers). | Parameter | Type | Required | Description | | - | - | - | - | | `from` | string | Yes | Start date (YYYY-MM-DD) | | `to` | string | Yes | End date (YYYY-MM-DD) | | `sections` | array | No | Sections to include: `visits`, `sales`, `products`, `customers`. Default: every section | *** ### get\_sales\_analytics Get revenue and sales analysis. | Parameter | Type | Required | Description | | - | - | - | - | | `from` | string | Yes | Start date (YYYY-MM-DD) | | `to` | string | Yes | End date (YYYY-MM-DD) | | `sections` | array | No | Sections to include: `summary`, `daily_trend`, `by_country`, `by_product`, `peak_purchase_days`, `peak_purchase_hours`. Default: `summary` only | *** ### get\_customer\_analytics Get customer insights and top customers. | Parameter | Type | Required | Description | | - | - | - | - | | `from` | string | Yes | Start date (YYYY-MM-DD) | | `to` | string | Yes | End date (YYYY-MM-DD) | | `top_customers_limit` | integer | No | Number of top customers when `top_customers` is requested. Default: 10 | | `sections` | array | No | Sections to include: `summary`, `by_country`, `daily_trend`, `top_customers`. Default: `summary` only | *** ### get\_visits\_analytics Get traffic analysis (sources, referrers, devices, locations). | Parameter | Type | Required | Description | | - | - | - | - | | `from` | string | Yes | Start date (YYYY-MM-DD) | | `to` | string | Yes | End date (YYYY-MM-DD) | | `sections` | array | No | Sections to include: `summary`, `daily_trend`, `by_product`, `referrers`, `locations`, `devices`, `mediums`, `sources`. Default: `summary` only | *** ### get\_conversion\_rate\_analytics Get conversion rates by device, country and product. | Parameter | Type | Required | Description | | - | - | - | - | | `from` | string | Yes | Start date (YYYY-MM-DD) | | `to` | string | Yes | End date (YYYY-MM-DD) | | `sections` | array | No | Sections to include: `summary`, `by_device`, `by_country`, `by_product`. Default: `summary` only | *** ### list\_doc\_pages List the Chariow developer documentation pages. | Parameter | Type | Required | Description | | - | - | - | - | | `section` | string | No | Filter by section: `introduction`, `api-reference`, `guides`, `mcp`, `n8n`, `resources` | *** ### get\_doc\_page Get the full Markdown content of a documentation page. | Parameter | Type | Required | Description | | - | - | - | - | | `slug` | string | Yes | Page slug from `list_doc_pages` (e.g. `guides-checkout`) | *** ### list\_help\_center\_articles List help centre articles (EN/FR). No parameters required. *** ### get\_help\_center\_article Get the full content of a help centre article. | Parameter | Type | Required | Description | | - | - | - | - | | `article_id` | string | Yes | Article ID from `list_help_center_articles` | | `collection_id` | string | Yes | Collection ID from `list_help_center_articles` | | `language` | string | No | `en` or `fr`. Default: `en` | *** ### read\_skill Load a Chariow skill: a ready-made playbook for recurring questions (payments, integrations, sales lifecycle, growth, refunds). | Parameter | Type | Required | Description | | - | - | - | - | | `name` | string | Yes | Skill slug (e.g. `payments-and-checkout`, `sales-diagnostic`) | *** ## Resources Resources provide reference data the AI assistant can read for context. They are available to every connection. | URI | Content | | - | - | | `chariow://resources/currencies` | Supported currencies (codes, symbols, names) | | `chariow://resources/countries` | Supported countries (codes, names, flags, dial codes) | | `chariow://resources/payment-methods` | Available payment methods | | `chariow://resources/product-categories` | Product category taxonomy | | `chariow://resources/product-types` | Product types | | `chariow://resources/platform` | About Chariow, its audience and benefits | | `chariow://resources/features` | Platform features by category | | `chariow://resources/help` | Help centre, developer docs and API links | | `chariow://resources/api-docs` | Index of the developer documentation pages and their slugs | | `chariow://docs/{slug}` | Full Markdown content of a documentation page | *** ## Prompts | Prompt | Description | Requires | Arguments | | - | - | - | - | | `analyse_product` | Analyse a product's description, pricing and custom checkout fields, and recommend conversion improvements | Products (view) | `product_id` (required) | *** ## Rate limits Each MCP connection can send up to **60 requests per minute**. Requests that do not carry a valid connection token are limited to 10 per minute per IP address. If you hit the limit, wait a moment before continuing. *** ## Next steps Connect your AI tool Learn about data sharing # n8n Integration Source: https://chariow.dev/en/n8n/overview Automate your Chariow store workflows with the official n8n community node The Chariow n8n integration lets you connect your store to hundreds of other apps and automate workflows: from syncing sales to a CRM, to sending licence keys via email, to triggering Slack notifications on new orders. The Chariow n8n node is currently available for **self-hosted n8n instances only**. It is not yet listed on the n8n community nodes registry. See the [setup guide](/en/n8n/setup) for installation instructions. ## Why use Chariow with n8n? Build multi-step automations triggered by store events, with no code required. Access products, sales, customers, licences, discounts, affiliates, and more. React to sales, licence changes, and affiliate events in real time. *** ## Available nodes The integration provides two n8n nodes: | Node | Type | Description | | - | - | - | | **Chariow** | Action | Perform operations on your store resources (get, list, create, activate, revoke, invite). | | **Chariow Trigger** | Trigger | Start workflows automatically when events occur in your store. | *** ## Chariow node resources The **Chariow** action node supports the following resources and operations: | Resource | Operations | | - | - | | **Affiliate** | Get, Send Invitations | | **Checkout** | Create | | **Customer** | Get, Get Many | | **Discount** | Get, Get Many | | **Licence** | Get, Get Many, Get Activations, Activate, Revoke | | **Product** | Get, Get Many | | **Pulse** | Get, Get Many | | **Sale** | Get, Get Many | | **Store** | Get Info | *** ## Trigger events The **Chariow Trigger** node listens for these webhook events. You pick a category, then one or more events, and can limit the trigger to specific products. | Category | Event | Pulse event | Description | | - | - | - | - | | Sale | **Successful** | `successful_sale` | Fires when a sale is successfully completed. | | Sale | **Abandoned** | `abandoned_sale` | Fires when a buyer abandons a checkout. | | Sale | **Failed** | `failed_sale` | Fires when a payment fails. | | License | **Issued** | `license_issued` | Fires when a new licence key is issued. | | License | **Activated** | `license_activated` | Fires when a licence is activated on a device. | | License | **Revoked** | `license_revoked` | Fires when a licence is revoked. | | License | **Expired** | `license_expired` | Fires when a licence reaches its expiry date. | | Affiliate | **Joined** | `affiliate_joined` | Fires when an affiliate joins your programme. | *** ## Required API key scopes The n8n credential uses a store API key, and each operation needs the matching [scope](/en/introduction/authentication#scopes). A missing scope makes the node fail with a `403` error that names the scope. | Node, resource or operation | Required scope | | - | - | | Credential test, **Store** | `store.read` | | **Product** | `products.read` | | **Sale** | `sales.read` | | **Customer** | `customers.pii.read` (includes `customers.read`) | | **Discount** | `discounts.read` | | **Pulse** | `webhooks.read` | | **Licence** Get, Get Many, Get Activations | `licenses.read` | | **Licence** Activate, Revoke | `licenses.write` | | **Affiliate** Get | `affiliates.read` | | **Affiliate** Send Invitations | `affiliates.write` | | **Checkout** Create | `checkout.write` | | **Chariow Trigger** | `webhooks.write` | The **Chariow Trigger** node registers a webhook on your store when the workflow is activated and removes it when the workflow is deactivated, which is why it needs `webhooks.write`. *** ## AI tool support Both the **Chariow** and **Chariow Trigger** nodes are compatible with n8n's AI Agent functionality. You can use them as tools within an AI Agent node to let your AI workflows query store data or react to store events. *** ## Get started Install the node on your self-hosted n8n instance Generate an API key for your store # n8n Setup Source: https://chariow.dev/en/n8n/setup Install and configure the Chariow node on your self-hosted n8n instance This guide walks you through installing the Chariow community node on a self-hosted n8n instance and connecting it to your store. ## Prerequisites Before you begin, make sure you have: * A **self-hosted n8n instance** (v1.0 or later) * A **Chariow API key** (starts with `sk_`): generate one from **Settings** β†’ **API Keys** in your [Chariow Dashboard](https://app.chariow.com), with the [scopes your workflows need](/en/n8n/overview#required-api-key-scopes). The credential test needs at least `store.read` * **Node.js >= 18.10** on the machine running n8n *** ## Installation The Chariow node is not yet available through the n8n Community Nodes UI. You must install it manually using one of the methods below. ### npm (recommended) Run the following command in your n8n user directory: ```bash theme={null} cd ~/.n8n && npm install @chariow/n8n-nodes-chariow ``` Then restart n8n for the node to appear. ### Docker If you run n8n in Docker, set the `N8N_CUSTOM_EXTENSIONS` environment variable to install the package on startup: ```yaml theme={null} # docker-compose.yml services: n8n: image: n8nio/n8n environment: - N8N_CUSTOM_EXTENSIONS=@chariow/n8n-nodes-chariow # ... your other config ``` Restart the container after updating the configuration. Community Nodes UI support is planned. Once available, you will be able to install directly from **Settings** β†’ **Community Nodes** inside n8n. *** ## Configure credentials In n8n, go to **Settings** β†’ **Credentials** β†’ **Add Credential**. Search for **Chariow API** and select it. Paste your Chariow API key (starts with `sk_`) into the **API Key** field. Click **Save**. n8n will test the connection automatically. A green tick confirms your key is valid. *** ## Verify installation Click **New Workflow** in n8n. Click **+** to add a node and search for **Chariow**. You should see two nodes: * **Chariow**: for performing actions (get, list, create) * **Chariow Trigger**: for starting workflows from store events *** ## Troubleshooting * Make sure you installed the package in the correct directory (`~/.n8n` for npm installs) * Restart n8n completely after installation * Check the n8n logs for any installation errors: `docker logs n8n` or check your process output * Verify the package is installed: `ls ~/.n8n/node_modules/@chariow` * Confirm your API key starts with `sk_` and is copied in full * Check that your store is active in the Chariow dashboard * The test calls `GET /v1/store`: make sure the key has the `store.read` scope * Ensure your n8n instance can reach `https://api.chariow.com` (no firewall or proxy blocking) The API key lacks the scope this operation needs. The error lists the missing scopes: add them to the key in **Settings** β†’ **API Keys**. See [Required API key scopes](/en/n8n/overview#required-api-key-scopes). * Verify the `N8N_CUSTOM_EXTENSIONS` environment variable is set correctly * Rebuild and restart the container: `docker compose down && docker compose up -d` * Check container logs for npm install errors: `docker logs ` *** ## Next steps See all resources and operations Browse the 8 available trigger events # Error Handling Source: https://chariow.dev/en/resources/errors Understanding and handling API errors The Chariow API uses conventional HTTP response codes to indicate the success or failure of requests. ## Response Format All API responses follow a consistent format: ```json theme={null} { "message": "Success message or error description", "data": {}, "errors": [] } ``` Error responses always carry `message` and `errors`. Some of them, such as authentication and rate limit errors, omit the `data` field. ## HTTP Status Codes | Code | Description | | - | - | | `200` | Success - Request completed successfully | | `201` | Created - Resource created successfully | | `400` | Bad Request - Invalid request parameters | | `401` | Unauthorised - Invalid or missing API key | | `403` | Forbidden - The API key lacks a scope the endpoint requires | | `404` | Not Found - Resource doesn't exist | | `422` | Unprocessable Entity - Validation failed | | `429` | Too Many Requests - Rate limit exceeded | | `500` | Internal Server Error - Something went wrong | ## Common Errors ### Authentication Errors (401) ```json theme={null} { "message": "API key is missing. Please provide a valid API key. Help: https://docs.chariow.com", "errors": [] } ``` | Message | Cause | | - | - | | `API key is missing. Please provide a valid API key. Help: https://docs.chariow.com` | Missing `Authorization: Bearer` header | | `Invalid API key. Please check again. Help: https://docs.chariow.com` | Malformed or deleted key, or a key whose creator is no longer an active team member | **Solution:** ```bash theme={null} # Ensure you include the Authorization header curl -X GET "https://api.chariow.com/v1/store" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ### Missing Scope (403) The API key is valid but lacks a scope the endpoint requires: ```http theme={null} HTTP/1.1 403 Forbidden WWW-Authenticate: Bearer error="insufficient_scope", scope="checkout.write" ``` ```json theme={null} { "message": "This credential is missing the required scope: checkout.write. Update its permissions in your dashboard.", "data": [], "errors": { "scopes": ["checkout.write"] } } ``` **Causes:** * The key was created without the scope the endpoint requires * The role of the team member who created the key was downgraded, which removed the scope **Solution:** Add the scopes listed in `errors.scopes` to the key in **Settings** β†’ **API Keys**. Read `errors.scopes` rather than `message` in your code, because the message is translated into the request language. See [Authentication](/en/introduction/authentication#scopes) for the scope each endpoint requires. ### Resource Not Found (404) ```json theme={null} { "message": "No query results for model [App\\Models\\Product].", "data": [], "errors": [] } ``` **Causes:** * Invalid resource ID * Resource belongs to a different store * Resource has been deleted * Product is not published (for public endpoints) ### Validation Errors (422) ```json theme={null} { "message": "The email field is required. (and 1 more error)", "data": [], "errors": { "email": ["The email field is required."], "product_id": ["The selected product_id is invalid."] } } ``` **Causes:** * Missing required fields * Invalid field format * Business rule violations ### Rate Limit Exceeded (429) ```json theme={null} { "message": "Too Many Attempts.", "errors": [] } ``` **Solution:** Wait for the number of seconds given in the `Retry-After` header and retry. See [Rate Limits](/en/resources/rate-limits) for details. ## Handling Errors ### JavaScript Example ```javascript theme={null} async function makeRequest(endpoint, options = {}) { const response = await fetch(`https://api.chariow.com/v1${endpoint}`, { ...options, headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json', ...options.headers } }); const data = await response.json(); if (!response.ok) { switch (response.status) { case 401: throw new AuthenticationError(data.message); case 403: throw new MissingScopeError(data.message, data.errors.scopes); case 404: throw new NotFoundError(data.message); case 422: throw new ValidationError(data.message, data.errors); case 429: throw new RateLimitError(data.message); default: throw new ApiError(data.message, response.status); } } return data; } // Usage try { const product = await makeRequest('/products/prd_abc123'); console.log(product); } catch (error) { if (error instanceof NotFoundError) { console.log('Product not found'); } else if (error instanceof ValidationError) { console.log('Validation failed:', error.errors); } else { console.error('API error:', error.message); } } ``` ### PHP Example ```php theme={null} = 400) { throw new Exception($result['message'], $httpCode); } return $result; } // Usage try { $product = makeRequest('/products/prd_abc123'); print_r($product); } catch (Exception $e) { if ($e->getCode() === 404) { echo "Product not found\n"; } else { echo "API error: " . $e->getMessage() . "\n"; } } ``` ## Error Codes Reference ### Checkout Errors | Message | Cause | Solution | | - | - | - | | `Product not found. Please verify the product ID and ensure it is published.` | Invalid product ID or unpublished | Use a valid, published product ID | | `Already purchased` | Customer owns this product | Redirect to their purchase | | `Product unavailable` | Out of stock or quantity limit | Check product availability | | `Invalid discount code` | Code doesn't exist or expired | Verify the discount code | ### License Errors | Message | Cause | Solution | | - | - | - | | `License key not found.` | Invalid license key | Verify the license key | | `Activation limit reached` | All activations are used | Show user their activations | | `License has expired` | Past expiration date | Prompt for renewal | | `License has been revoked` | Manually revoked | Contact support | | `License has already been revoked` | Revoking a licence that is already revoked | No action needed | ## Best Practices Don't assume success - always check the HTTP status code before processing the response. Log error responses for debugging and monitoring purposes. Translate API errors into user-friendly messages for your customers. For 5xx errors and rate limits, implement automatic retry with exponential backoff. # Rate Limits Source: https://chariow.dev/en/resources/rate-limits Understand API rate limiting and how to handle it The Chariow API implements rate limiting to ensure fair usage and maintain service quality for all users. ## Default Limits | Requests | Limit | Counted per | | - | - | - | | All public API endpoints except checkout | 100 requests per minute | API key | | `POST /v1/checkout` | 100 requests per minute | API key, in a separate counter | | Requests without a well-formed API key | 100 requests per minute | IP address | Each API key has its own counters, so one integration cannot slow down another behind the same IP address. Checkout has its own counter so that an integration syncing sales or products can never use up the key's budget and stop buyers from paying. A key can therefore send up to 100 checkout requests and 100 other requests in the same minute. Every request counts towards the limit, including requests rejected with `401` or `403`. The [MCP server](/en/mcp/overview) has its own limits: 60 requests per minute per MCP connection. See [MCP tools](/en/mcp/tools#rate-limits). ## Rate Limit Headers Every rate-limited response includes headers indicating your current status: ```http theme={null} X-RateLimit-Limit: 100 X-RateLimit-Remaining: 98 ``` When you exceed the limit, the `429` response adds two more headers: ```http theme={null} HTTP/1.1 429 Too Many Requests Retry-After: 42 X-RateLimit-Limit: 100 X-RateLimit-Remaining: 0 X-RateLimit-Reset: 1760000000 ``` | Header | Description | | - | - | | `X-RateLimit-Limit` | Maximum requests allowed in the window | | `X-RateLimit-Remaining` | Requests remaining in the current window | | `Retry-After` | Seconds to wait before retrying (only on `429`) | | `X-RateLimit-Reset` | Unix timestamp when the limit resets (only on `429`) | ## Rate Limit Exceeded When you exceed the rate limit, you'll receive a `429 Too Many Requests` response: ```json theme={null} { "message": "Too Many Attempts.", "errors": [] } ``` Wait for the number of seconds given in the `Retry-After` header before sending the next request. ## Handling Rate Limits ### Exponential Backoff Implement exponential backoff to gracefully handle rate limits, and never retry before `Retry-After` has elapsed: ```javascript theme={null} async function fetchWithRetry(url, options, maxRetries = 3) { for (let attempt = 0; attempt < maxRetries; attempt++) { const response = await fetch(url, options); if (response.status === 429) { const retryAfter = Number(response.headers.get('Retry-After')) || 60; const delay = Math.max(retryAfter * 1000, Math.pow(2, attempt) * 1000); console.log(`Rate limited. Retrying in ${delay}ms...`); await new Promise(resolve => setTimeout(resolve, delay)); continue; } return response; } throw new Error('Max retries exceeded'); } ``` ### Request Batching Batch multiple operations to reduce request count: ```javascript theme={null} // Instead of making 100 individual requests for (const customerId of customerIds) { await getCustomer(customerId); // 100 requests } // Use pagination to get multiple at once const customers = await listCustomers({ per_page: 100 }); // 1 request ``` ### Caching Cache responses to avoid unnecessary requests: ```javascript theme={null} const cache = new Map(); const CACHE_TTL = 60000; // 1 minute async function getCachedCustomer(customerId) { const cached = cache.get(customerId); if (cached && Date.now() - cached.timestamp < CACHE_TTL) { return cached.data; } const response = await fetch(`/v1/customers/${customerId}`, { headers: { 'Authorization': `Bearer ${apiKey}` } }); const data = await response.json(); cache.set(customerId, { data, timestamp: Date.now() }); return data; } ``` ## Increasing Limits If you need higher rate limits: 1. **Optimise Usage** - Review your implementation: pagination, caching and webhooks remove most polling 2. **Contact Support** - Explain your use case and expected volume Contact [support@chariow.com](mailto:support@chariow.com) to discuss higher rate limits for your use case. ## Best Practices Track rate limit headers to understand your usage patterns and adjust accordingly. Instead of polling for changes, use webhooks to receive real-time notifications. Queue requests and process them at a controlled rate to avoid bursts. Cache data that doesn't change frequently to reduce API calls.