---
agentTools:
  projectIndex: https://docs.chargeafter.com/llms.txt
---

# Creating a Charge

> 📘 Prerequisites
>
> The private API key provided to you by ChargeAfter

Upon receiving a valid confirmation token, the merchant’s server can commit a charge via ChargeAfter’s Charges API.

> 🚧 Cart Validation Rules
>
> To avoid validation errors, it is important to understand how ChargeAfter validates a cart, see Cart Validation Rules.

If this request succeeds, a new charge is created and the financing payment is initiated.

```curl Sandbox
curl --location --request POST 'https://api-sandbox.ca-dev.co/v2/post-sale/charges' \
--header 'Authorization: Bearer <private api key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "confirmationToken": "<confirmation token>",
    "merchantOrderId": "<order id>"
}'
```
```curl Production
curl --location --request POST 'https://api.chargeafter.com/v2/post-sale/charges' \
--header 'Authorization: Bearer <private api key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "confirmationToken": "<confirmation token>",
    "merchantOrderId": "<order id>"
}'
```

> ❗️ Keep your private API key private!
>
> The request to create a charge uses the private API key. Requests using the private API key must be sent from your server. If any of these requests are sent from the browser, the private key will be compromised.

# Continuing from the Apply flow

If a merchant is to create a charge after completing an Apply flow, it is recommended to invoke the continuation flow needs with a `continuationToken` to improve the user experience. However, a charge can be created without the continuation flow if an `accountToken` has been received.

The `continuationToken` will have been received in the onComplete callback at the end of the Apply flow. It can be used to launch the Checkout flow up to one hour after the Apply flow has completed.

The base implementation for the continuation flow is as follows:

```Text JavaScript
ChargeAfter.payments.present('checkout', {
  sessionToken: '{CONTINUATION_TOKEN}',
});
```

If the merchant has the `applicationId` for the consumer (which is sent in the onApplicationCreated callback and the onComplete callback), then there is also the option to retrieve the `sessionToken` by calling the `GET /v2/checkout/applications/{applicationId}/token` [endpoint](https://docs.chargeafter.com/reference/get_v2-checkout-applications-applicationid-token).

> 📘 What's Next?
>
> * Add a promotional widget to your product page to fully capitalize on your promotional financing options and increase conversion.
> * Add the option to apply using the Apply UI from anywhere in the website.
> * Monitor, control and analyze the merchant’s financing activity via the Merchant Dashboard.