Generate checkout links to offset with the API

Find out how to create API keys and use the API to generate checkout links with set amounts or CO2 emission values.

Preparation

Create an API key

Open the developer menu in the dashboard and navigate to API Keys. Now click on Add new API keys.

Important: Save the secret key and never pass it on to third parties!

Make an API Request

Now use the endpoint /orders/link/carbon to create a checkout link with a fixed amount of CO2 emissions or use the endpoint /orders/link/price to create a checkout link with a fixed amount in the desired currency.

Good to know: You can also use our PHP Library or Node.js Library to interact with the API.

Options

Currency

Use the header parameter X-CURRENCY to select the currency in which the result of the API and the checkout link should be returned. There are over 100 currencies to choose from.

Language

Use the X-LOCALE header parameter to select the language in which the result of the API and the checkout link should be returned.

Success & Cancel URLs

Use the success_url & cancel_url parameters to select where the user of the checkout link should be redirected after a successful and canceled payment.

Order Count

Adjust the order_count parameter to get up to 3 checkout links with one API call.

Example

In this example, we calculate the emissions of a trip from Berlin to Munich and use the result to create a checkout link.

Checkout link with 500kg CO2e

POST/v2/orders/link/carbon

1
2
3
4
5
{
    "kgCO2e": 500,
    "success_url": "https://your-business.com/success",
    "cancel_url": "https://your-business.com/cancel"
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
    "payment_link": "https://klimapi.com/checkout/1c137daf-d3d7-42ad-8d7c-6429e8840957",
    "payment_link_id": "00000000-0000-0000-0000-000000000000",
    "certificate_url": null,
    "certificate_pdf": null,
    "order_id": "CA-0000-00000000",
    "price": 11.3,
    "currency": "EUR",
    "kgCO2e": 500,
    "payment_received": false,
    "project": {
        "id": "00000000-0000-0000-0000-000000000000",
        "title": "Example Project",
        "summary": "Example Summary",
        "status": "Active",
        "category_id": 3,
        "certification_authority_id": 2,
        "country": "Example Country",
        "description": null,
        "goals": null,
        "images": [
            "https://cdn.klimapi.com/projects/00000000-0000-0000-0000-000000000000_1.jpeg",
            "https://cdn.klimapi.com/projects/00000000-0000-0000-0000-000000000000_2.jpeg"
        ],
        "benefits": [
            7,
            8,
            13
        ]
    }
}

Checkout link for 10 Euro

POST/v2/orders/link/price

1
2
3
4
5
6
{
    "price_amount": 10,
    "change_allowed": true,
    "success_url": "https://your-business.com/success",
    "cancel_url": "https://your-business.com/cancel"
}

Response

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
    "payment_link": "https://klimapi.com/checkout/1c137daf-d3d7-42ad-8d7c-6429e8840957",
    "payment_link_id": "00000000-0000-0000-0000-000000000000",
    "certificate_url": null,
    "certificate_pdf": null,
    "order_id": "CA-0000-00000000",
    "price": 10,
    "currency": "EUR",
    "kgCO2e": 448,
    "payment_received": false,
    "project": {
        "id": "00000000-0000-0000-0000-000000000000",
        "title": "Example Project",
        "summary": "Example Summary",
        "status": "Active",
        "category_id": 3,
        "certification_authority_id": 2,
        "country": "Example Country",
        "description": null,
        "goals": null,
        "images": [
            "https://cdn.klimapi.com/projects/00000000-0000-0000-0000-000000000000_1.jpeg",
            "https://cdn.klimapi.com/projects/00000000-0000-0000-0000-000000000000_2.jpeg"
        ],
        "benefits": [
            7,
            8,
            13
        ]
    }
}

No credit card required - Create an account now

Create an account and start calculating and offsetting the CO2 emissions directly via our API. Do you still have questions or need a customized offer? Use the chat or make an appointment directly with our sales team.