> ## 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.

# How to Customize Products Order in Checkouts

> Learn how to customize the order in which products appear in checkouts.

<Info>
  Currently, customizing the products order in checkout is only supported via the APIs.
</Info>

## Create Organization Access Token and Product IDs

<Steps>
  <Step title="Create a New Token">
    Create a new organization token by following our [Organization Access Tokens](https://polar.sh/docs/integrate/oat) guide.
  </Step>

  <Step title="Save your Access Token">
    After creating your access token, you will be able to view it. Please copy and save your access token.

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/access-token.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=4d5b14416665214c4191b03aef3e7948" data-path="assets/guides/customize-products-order-in-checkouts/access-token.png" />
  </Step>

  <Step title="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`.

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/products-catalogue.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=1a593ae8c7c476b62f5cdde8730e3efe" data-path="assets/guides/customize-products-order-in-checkouts/products-catalogue.png" />
  </Step>

  <Step title="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.

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/product-id.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=9a39f0e5d6371a9fec7ed25d455db1f5" data-path="assets/guides/customize-products-order-in-checkouts/product-id.png" />
  </Step>
</Steps>

## Reordering Products In Checkout Links API

<Steps>
  <Step title="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.

    <Note>
      Make sure your token has the **`checkout_links:write`** scope enabled to use [Create Checkout Link API](/api-reference/checkout-links/create).
    </Note>

    * \<PRODUCT\_ID\_1>, \<PRODUCT\_ID\_2>, etc., with the product IDs in the order you want them to appear in the checkout.

    ```bash Terminal theme={null}
    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](https://polar.sh/docs/api-reference/checkout-links/create).
  </Step>

  <Step title="Open the Checkout Link URL">
    The curl command returns a JSON. Access the checkout link URL from the <code>"url"</code> key of the JSON and open it.

    ```json theme={null}
    {
        "...": "...",
        "...": "...",
        "url": "https://buy.polar.sh/polar_cl_..." // [!code ++]
    }
    ```

    It looks like below:

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/p1-p2.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=19f442e4c663437294322cbe56e64b42" data-path="assets/guides/customize-products-order-in-checkouts/p1-p2.png" />
  </Step>

  <Step title="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.

    ```bash Terminal theme={null}
    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:

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/p2-p1.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=1fc8c36350cebf7ba2780291982255d5" data-path="assets/guides/customize-products-order-in-checkouts/p2-p1.png" />
  </Step>
</Steps>

## Reordering Products In Checkout Session API

<Steps>
  <Step title="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.

    <Note>
      Make sure your token has the **`checkouts:write`** scope enabled to use [Create Checkout Session API](/api-reference/checkouts/create-session).
    </Note>

    * \<PRODUCT\_ID\_1>, \<PRODUCT\_ID\_2>, etc., with the product IDs in the order you want them to appear in the checkout.

    ```bash Terminal theme={null}
    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](https://polar.sh/docs/api-reference/checkouts/create-session).
  </Step>

  <Step title="Open the Checkout Session URL">
    The curl command returns a JSON. Access the checkout session URL from the <code>"url"</code> key of the JSON and open it.

    ```json theme={null}
    {
        "...": "...",
        "url": "https://buy.polar.sh/polar_c_...", // [!code ++]
        "...": "..."
    }
    ```

    It looks like below:

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/p1-p2.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=19f442e4c663437294322cbe56e64b42" data-path="assets/guides/customize-products-order-in-checkouts/p1-p2.png" />
  </Step>

  <Step title="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.

    ```bash Terminal theme={null}
    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:

    <img height="200" src="https://mintcdn.com/polar/WdO7SaZ4QOb9_Uo-/assets/guides/customize-products-order-in-checkouts/p2-p1.png?fit=max&auto=format&n=WdO7SaZ4QOb9_Uo-&q=85&s=1fc8c36350cebf7ba2780291982255d5" data-path="assets/guides/customize-products-order-in-checkouts/p2-p1.png" />
  </Step>
</Steps>
