Skip to main content

Documentation Index

Fetch the complete documentation index at: https://polar.sh/docs/llms.txt

Use this file to discover all available pages before exploring further.

Currently, customizing the products order in checkout is only supported via the APIs.

Create Organization Access Token and Product IDs

1

Create a New Token

Create a new organization token by following our Organization Access Tokens guide.
2

Save your Access Token

After creating your access token, you will be able to view it. Please copy and save your access token.
3

Go to the Products Catalogue

In the Polar dashboard sidebar, navigate to Products > Catalogue for your organization. You can also go directly to https://polar.sh/dashboard/${org_slug}/products.
4

Access the product IDs for checkout

Retrieve the Product IDs for the items you wish to include in checkout by clicking on the ⋮ (More options) menu next to chosen products and selecting Copy Product ID.
These IDs will be required in the next step to create a checkout.
1

Create a Checkout Link using the API

Open your terminal and paste the following curl command to make an API call for creating a checkout link. Be sure to replace:
  • <YOUR_ACCESS_TOKEN> with your actual access token.
Make sure your token has the checkout_links:write scope enabled to use Create Checkout Link API.
  • <PRODUCT_ID_1>, <PRODUCT_ID_2>, etc., with the product IDs in the order you want them to appear in the checkout.
Terminal
curl --request POST \
    --url https://api.polar.sh/v1/checkout-links/ \
    --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{
    "products": [
        "<Product_ID_1>",
        "<Product_ID_2>"
    ]
}'
Find all the available parameters along with the description in the Create Checkout Link API.
2

Open the Checkout Link URL

The curl command returns a JSON. Access the checkout link URL from the “url” key of the JSON and open it.
{
    "...": "...",
    "...": "...",
    "url": "https://buy.polar.sh/polar_cl_..."
}
It looks like below:
3

Change the order of products

If you want to change the order and make Product 2 appear before Product 1, place Product 2’s ID first, followed by Product 1’s ID in the API call.
Terminal
curl --request POST \
    --url https://api.polar.sh/v1/checkouts/ \
    --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{
    "products": [
        "<Product_ID_2>",
        "<Product_ID_1>"
    ]
}'
The checkout looks like below:

Reordering Products In Checkout Session API

1

Create a Checkout Session using the API

Open your terminal and paste the following curl command to make an API call for creating a checkout session. Be sure to replace:
  • <YOUR_ACCESS_TOKEN> with your actual access token.
Make sure your token has the checkouts:write scope enabled to use Create Checkout Session API.
  • <PRODUCT_ID_1>, <PRODUCT_ID_2>, etc., with the product IDs in the order you want them to appear in the checkout.
Terminal
curl --request POST \
    --url https://api.polar.sh/v1/checkouts/ \
    --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{
    "products": [
        "<Product_ID_1>",
        "<Product_ID_2>"
    ]
}'
Find all the available parameters along with the description in the Create Checkout Session API.
2

Open the Checkout Session URL

The curl command returns a JSON. Access the checkout session URL from the “url” key of the JSON and open it.
{
    "...": "...",
    "url": "https://buy.polar.sh/polar_c_...", 
    "...": "..."
}
It looks like below:
3

Change the order of products

If you want to change the order and make Product 2 appear before Product 1, place Product 2’s ID first, followed by Product 1’s ID in the API call.
Terminal
curl --request POST \
    --url https://api.polar.sh/v1/checkouts/ \
    --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
    --header 'Content-Type: application/json' \
    --data '{
    "products": [
        "<Product_ID_2>",
        "<Product_ID_1>"
    ]
}'
The checkout looks like below: