Airwallex logo
Airwallex logo

Prices via API

This tutorial will guide you through the steps to create and manage prices via Billing APIs.

Create a price

Call Create a price API with the following required fields:

  • currency: Specify currency for the price.
  • product_id: ID of the Product object created with Create a Product API.
  • pricing_model: Defaults to PER_UNIT. See Pricing models.
  • billing_type: Defaults to IN_ADVANCE. See Billing types.
  • recurring: Set this object to null for one-time charges.
    • recurring.period_unit: Indicates how often you want to charge your customers for a product or service. Can be one of DAY, WEEK, MONTH,YEAR.
    • recurring.period: Optional. Determines the interval gap based on period_unit. For example, for a bi-monthly billing cycle, specify period= 2 where period_unit=MONTH.
  • active: By default, this field is set to true, which means the price is available for new purchases. You can set it to false to deactivate the price.

The example code below shows how to create a one-time price using the PER_UNIT pricing model for the product.

Shell
1curl --location --request POST 'https://api-demo.airwallex.com/api/v1/prices/create'
2--header 'Content-Type: application/json'
3--header 'Authorization: <your_bearer_token>'
4--data '{
5 "active": true,
6 "billing_type": "IN_ADVANCE",
7 "currency": "USD",
8 "pricing_model": "PER_UNIT",
9 "unit_amount": 10,
10 "description": "One-off charge price",
11 "product_id": "prd_hkdmfsd9mhax0w2uakw",
12 "request_id": "4cdbcc33-2688-4341-be3e-e3993e480960"
13}'

The example code below shows how to create a monthly price using the FLAT pricing model and apply charges on a per-month basis.

Shell
1curl --location --request POST 'https://api-demo.airwallex.com/api/v1/prices/create'
2--header 'Content-Type: application/json'
3--header 'Authorization: <your_bearer_token>'
4--data '{
5 "active": true,
6 "billing_type": "IN_ADVANCE",
7 "flat_amount": 20,
8 "currency": "USD",
9 "pricing_model": "FLAT",
10 "recurring": {
11 "period": 1,
12 "period_unit": "MONTH"
13 },
14 "description": "Monthly flat subscription fee",
15 "product_id": "prd_hkdmfsd9mhax0kg5zyc",
16 "request_id": "04f0a972-f558-4327-944f-18e7e538cee0"
17}'

Deactivate a price

You can retire prices you no longer wish to use by setting the active field to false in Update a price API request.

Deactivating a price means it can no longer be selected when creating new subscriptions or invoices. Note that it will not affect existing subscriptions or invoices that have used this price.

Shell
1curl --request POST
2--url 'https://api-demo.airwallex.com/api/v1/prices/pri_hkpd7fedfgb004apkvs/update'
3--header 'Content-Type: application/json'
4--header 'Authorization: Bearer <your_bearer_token>'
5--data '{
6 "active": false
7}'

Manage prices

After creating a price object, you can perform the following actions:

Was this page helpful?