Skip to main content
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 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:
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.
1

Initiate Checkout

Call the /checkout endpoint with product ID and customer details
2

Handle Response

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
3

Process Payment

Customer completes payment on the secure hosted payment page, using the methods available in their country
4

Receive Webhook

Get notified of sale status changes via webhooks (recommended)
5

Deliver Product

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:

Request Parameters

Shipping Address Fields

When the product has “Require shipping address” enabled, you must send a shipping object in your checkout request:
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

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:
The purchase object is truncated here; it has the same shape as a sale returned by 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:
A paid product also completes immediately when a discount brings the amount to zero.

Already Purchased

If the customer already owns the product:
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:
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:
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:
The response will show the discounted amount:

Custom Fields

If your product has custom fields configured, you can collect and validate them during checkout:
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:
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:

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:
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):
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:
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: 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

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:

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 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:

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

Sales Guide

Learn how to retrieve and manage sales

Pulses

Set up notifications for completed sales

Checkout API

View the complete Checkout API reference