Skip to main content
POST
/
v1
/
checkouts
Creates a new checkout session.
curl --request POST \
  --url https://api.creem.io/v1/checkouts \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '
{
  "product_id": "prod_1234567890",
  "request_id": "<string>",
  "units": 1,
  "custom_price": 1500,
  "discount_code": "SUMMER2024",
  "customer": {
    "id": "cust_1234567890",
    "email": "user@example.com"
  },
  "custom_fields": [
    {
      "type": "text",
      "key": "companyName",
      "label": "Company Name",
      "optional": true,
      "text": {
        "max_length": 200,
        "min_length": 1
      },
      "checkbox": {
        "label": "I agree to the [terms and conditions](https://example.com/terms)"
      }
    }
  ],
  "custom_field": [
    {
      "type": "text",
      "key": "companyName",
      "label": "Company Name",
      "optional": true,
      "text": {
        "max_length": 200,
        "min_length": 1
      },
      "checkbox": {
        "label": "I agree to the [terms and conditions](https://example.com/terms)"
      }
    }
  ],
  "success_url": "<string>",
  "metadata": {
    "userId": "user_123",
    "visitCount": 42,
    "lastVisit": "2023-04-01"
  }
}
'
import requests

url = "https://api.creem.io/v1/checkouts"

payload = {
"product_id": "prod_1234567890",
"request_id": "<string>",
"units": 1,
"custom_price": 1500,
"discount_code": "SUMMER2024",
"customer": {
"id": "cust_1234567890",
"email": "user@example.com"
},
"custom_fields": [
{
"type": "text",
"key": "companyName",
"label": "Company Name",
"optional": True,
"text": {
"max_length": 200,
"min_length": 1
},
"checkbox": { "label": "I agree to the [terms and conditions](https://example.com/terms)" }
}
],
"custom_field": [
{
"type": "text",
"key": "companyName",
"label": "Company Name",
"optional": True,
"text": {
"max_length": 200,
"min_length": 1
},
"checkbox": { "label": "I agree to the [terms and conditions](https://example.com/terms)" }
}
],
"success_url": "<string>",
"metadata": {
"userId": "user_123",
"visitCount": 42,
"lastVisit": "2023-04-01"
}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
product_id: 'prod_1234567890',
request_id: '<string>',
units: 1,
custom_price: 1500,
discount_code: 'SUMMER2024',
customer: {id: 'cust_1234567890', email: 'user@example.com'},
custom_fields: [
{
type: 'text',
key: 'companyName',
label: 'Company Name',
optional: true,
text: {max_length: 200, min_length: 1},
checkbox: {label: 'I agree to the [terms and conditions](https://example.com/terms)'}
}
],
custom_field: [
{
type: 'text',
key: 'companyName',
label: 'Company Name',
optional: true,
text: {max_length: 200, min_length: 1},
checkbox: {label: 'I agree to the [terms and conditions](https://example.com/terms)'}
}
],
success_url: '<string>',
metadata: {userId: 'user_123', visitCount: 42, lastVisit: '2023-04-01'}
})
};

fetch('https://api.creem.io/v1/checkouts', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.creem.io/v1/checkouts",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'product_id' => 'prod_1234567890',
'request_id' => '<string>',
'units' => 1,
'custom_price' => 1500,
'discount_code' => 'SUMMER2024',
'customer' => [
'id' => 'cust_1234567890',
'email' => 'user@example.com'
],
'custom_fields' => [
[
'type' => 'text',
'key' => 'companyName',
'label' => 'Company Name',
'optional' => true,
'text' => [
'max_length' => 200,
'min_length' => 1
],
'checkbox' => [
'label' => 'I agree to the [terms and conditions](https://example.com/terms)'
]
]
],
'custom_field' => [
[
'type' => 'text',
'key' => 'companyName',
'label' => 'Company Name',
'optional' => true,
'text' => [
'max_length' => 200,
'min_length' => 1
],
'checkbox' => [
'label' => 'I agree to the [terms and conditions](https://example.com/terms)'
]
]
],
'success_url' => '<string>',
'metadata' => [
'userId' => 'user_123',
'visitCount' => 42,
'lastVisit' => '2023-04-01'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.creem.io/v1/checkouts"

payload := strings.NewReader("{\n \"product_id\": \"prod_1234567890\",\n \"request_id\": \"<string>\",\n \"units\": 1,\n \"custom_price\": 1500,\n \"discount_code\": \"SUMMER2024\",\n \"customer\": {\n \"id\": \"cust_1234567890\",\n \"email\": \"user@example.com\"\n },\n \"custom_fields\": [\n {\n \"type\": \"text\",\n \"key\": \"companyName\",\n \"label\": \"Company Name\",\n \"optional\": true,\n \"text\": {\n \"max_length\": 200,\n \"min_length\": 1\n },\n \"checkbox\": {\n \"label\": \"I agree to the [terms and conditions](https://example.com/terms)\"\n }\n }\n ],\n \"custom_field\": [\n {\n \"type\": \"text\",\n \"key\": \"companyName\",\n \"label\": \"Company Name\",\n \"optional\": true,\n \"text\": {\n \"max_length\": 200,\n \"min_length\": 1\n },\n \"checkbox\": {\n \"label\": \"I agree to the [terms and conditions](https://example.com/terms)\"\n }\n }\n ],\n \"success_url\": \"<string>\",\n \"metadata\": {\n \"userId\": \"user_123\",\n \"visitCount\": 42,\n \"lastVisit\": \"2023-04-01\"\n }\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.creem.io/v1/checkouts")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"product_id\": \"prod_1234567890\",\n \"request_id\": \"<string>\",\n \"units\": 1,\n \"custom_price\": 1500,\n \"discount_code\": \"SUMMER2024\",\n \"customer\": {\n \"id\": \"cust_1234567890\",\n \"email\": \"user@example.com\"\n },\n \"custom_fields\": [\n {\n \"type\": \"text\",\n \"key\": \"companyName\",\n \"label\": \"Company Name\",\n \"optional\": true,\n \"text\": {\n \"max_length\": 200,\n \"min_length\": 1\n },\n \"checkbox\": {\n \"label\": \"I agree to the [terms and conditions](https://example.com/terms)\"\n }\n }\n ],\n \"custom_field\": [\n {\n \"type\": \"text\",\n \"key\": \"companyName\",\n \"label\": \"Company Name\",\n \"optional\": true,\n \"text\": {\n \"max_length\": 200,\n \"min_length\": 1\n },\n \"checkbox\": {\n \"label\": \"I agree to the [terms and conditions](https://example.com/terms)\"\n }\n }\n ],\n \"success_url\": \"<string>\",\n \"metadata\": {\n \"userId\": \"user_123\",\n \"visitCount\": 42,\n \"lastVisit\": \"2023-04-01\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.creem.io/v1/checkouts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"product_id\": \"prod_1234567890\",\n \"request_id\": \"<string>\",\n \"units\": 1,\n \"custom_price\": 1500,\n \"discount_code\": \"SUMMER2024\",\n \"customer\": {\n \"id\": \"cust_1234567890\",\n \"email\": \"user@example.com\"\n },\n \"custom_fields\": [\n {\n \"type\": \"text\",\n \"key\": \"companyName\",\n \"label\": \"Company Name\",\n \"optional\": true,\n \"text\": {\n \"max_length\": 200,\n \"min_length\": 1\n },\n \"checkbox\": {\n \"label\": \"I agree to the [terms and conditions](https://example.com/terms)\"\n }\n }\n ],\n \"custom_field\": [\n {\n \"type\": \"text\",\n \"key\": \"companyName\",\n \"label\": \"Company Name\",\n \"optional\": true,\n \"text\": {\n \"max_length\": 200,\n \"min_length\": 1\n },\n \"checkbox\": {\n \"label\": \"I agree to the [terms and conditions](https://example.com/terms)\"\n }\n }\n ],\n \"success_url\": \"<string>\",\n \"metadata\": {\n \"userId\": \"user_123\",\n \"visitCount\": 42,\n \"lastVisit\": \"2023-04-01\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "<string>",
  "object": "<string>",
  "status": "completed",
  "product": "<string>",
  "request_id": "<string>",
  "units": 1,
  "custom_price": 1500,
  "order": {
    "id": "<string>",
    "object": "<string>",
    "product": "<string>",
    "amount": 2000,
    "currency": "USD",
    "status": "pending",
    "type": "recurring",
    "created_at": "2023-09-13T00:00:00Z",
    "updated_at": "2023-09-13T00:00:00Z",
    "customer": "<string>",
    "transaction": "tx_1234567890",
    "discount": "dis_1234567890",
    "sub_total": 1800,
    "tax_amount": 200,
    "discount_amount": 100,
    "amount_due": 1900,
    "amount_paid": 1900,
    "fx_amount": 15,
    "fx_currency": "EUR",
    "fx_rate": 1.2,
    "affiliate": "<string>"
  },
  "subscription": "<string>",
  "customer": "<string>",
  "custom_fields": [
    {
      "key": "<string>",
      "label": "<string>",
      "optional": true,
      "text": {
        "max_length": 123,
        "minimum_length": 123,
        "value": "<string>"
      },
      "checkbox": {
        "label": "<string>",
        "value": true
      }
    }
  ],
  "checkout_url": "<string>",
  "success_url": "https://example.com/return",
  "license_keys": [
    {
      "id": "<string>",
      "object": "<string>",
      "product_id": "prod_abc123",
      "status": "active",
      "key": "ABC123-XYZ456-XYZ456-XYZ456",
      "activation": 5,
      "created_at": "2023-09-13T00:00:00Z",
      "activation_limit": 1,
      "expires_at": "2023-09-13T00:00:00Z",
      "instance": {
        "id": "<string>",
        "object": "license-instance",
        "name": "My Customer License Instance",
        "status": "active",
        "created_at": "2023-09-13T00:00:00Z"
      }
    }
  ],
  "feature": [
    {
      "id": "feat_abc123",
      "description": "Get access to the full course materials.",
      "type": "licenseKey",
      "private_note": "Thank you for your purchase! Here is your access code: XYZ123",
      "file": {
        "files": [
          {
            "id": "file_abc123",
            "file_name": "ebook.pdf",
            "url": "https://storage.creem.io/files/ebook.pdf",
            "type": "application/pdf",
            "size": 1024000
          }
        ]
      },
      "license_key": {
        "id": "<string>",
        "object": "<string>",
        "product_id": "prod_abc123",
        "status": "active",
        "key": "ABC123-XYZ456-XYZ456-XYZ456",
        "activation": 5,
        "created_at": "2023-09-13T00:00:00Z",
        "activation_limit": 1,
        "expires_at": "2023-09-13T00:00:00Z",
        "instance": {
          "id": "<string>",
          "object": "license-instance",
          "name": "My Customer License Instance",
          "status": "active",
          "created_at": "2023-09-13T00:00:00Z"
        }
      },
      "customer_credits": {
        "amount": "100",
        "unit_label": "tokens"
      },
      "license": {
        "id": "<string>",
        "object": "<string>",
        "product_id": "prod_abc123",
        "status": "active",
        "key": "ABC123-XYZ456-XYZ456-XYZ456",
        "activation": 5,
        "created_at": "2023-09-13T00:00:00Z",
        "activation_limit": 1,
        "expires_at": "2023-09-13T00:00:00Z",
        "instance": {
          "id": "<string>",
          "object": "license-instance",
          "name": "My Customer License Instance",
          "status": "active",
          "created_at": "2023-09-13T00:00:00Z"
        }
      }
    }
  ],
  "metadata": {
    "userId": "user_123",
    "visitCount": 42,
    "lastVisit": "2023-04-01"
  },
  "discount": {
    "id": "dis_3e6Z6TzvHKdsjEgXnGDEp0",
    "discountCode": "HOLIDAY2024",
    "name": "<string>",
    "amount": 123,
    "durationInMonths": 123
  }
}

Authorizations

x-api-key
string
header
required

API key for authentication. You can find your API key in the Creem dashboard under Settings > API Keys.

Body

application/json

Create checkout request payload

product_id
string
required

The ID of the product associated with the checkout session.

Example:

"prod_1234567890"

request_id
string

Identify and track each checkout request.

units
number

The number of units for the order.

Example:

1

custom_price
integer

Override the unit price of the product for this checkout session, in cents (e.g. 1500 = $15.00). The product currency is used, and the amount is per unit: with units: 3 and custom_price: 1500 the customer pays 4500. Must be between 100 (one whole unit of the currency) and 99999999. Only supported for one-time payment products. Use this for dynamic pricing models such as pay-what-you-want, donations, or amounts calculated by your application.

Example:

1500

discount_code
string

Prefill the checkout session with a discount code.

Example:

"SUMMER2024"

customer
object

Customer data for checkout session. This will prefill the customer info on the checkout page.

custom_fields
object[]

Collect additional information from your customer using custom fields. Up to 3 fields are supported.

custom_field
object[]
deprecated

DEPRECATED: Use custom_fields instead. Collect additional information from your customer using custom fields. Up to 3 fields are supported.

success_url
string

The URL to which the user will be redirected after the checkout process is completed.

metadata
object

Metadata for the checkout in the form of key-value pairs

Example:
{
"userId": "user_123",
"visitCount": 42,
"lastVisit": "2023-04-01"
}

Response

Successfully created a checkout session

id
string
required

Unique identifier for the object.

mode
enum<string>
required

String representing the environment.

Available options:
test,
prod,
sandbox
object
string
required

String representing the object's type. Objects of the same type share the same value.

status
enum<string>
required

Status of the checkout.

Available options:
pending,
processing,
completed,
expired
Example:

"completed"

product
required

The product associated with the checkout session.

request_id
string

Identify and track each checkout request.

units
number
default:1

The number of units for the of the product.

custom_price
integer

The per-unit price override (in cents, product currency) this checkout was created with. Only present when the checkout was created with a custom_price. One-time payment products only.

Example:

1500

order
object

The order associated with the checkout session.

subscription

The subscription associated with the checkout session.

customer

The customer associated with the checkout session.

custom_fields
object[]

Additional information collected from your customer during the checkout process.

checkout_url
string

The URL to which the customer will be redirected to complete the payment.

success_url
string | null

The URL to which the user will be redirected after the checkout process is completed.

Example:

"https://example.com/return"

license_keys
object[]

License keys issued for the order.

feature
object[]
deprecated

DEPRECATED: Use license_keys instead. Features issued for the order.

metadata
object

Metadata for the checkout in the form of key-value pairs

Example:
{
"userId": "user_123",
"visitCount": 42,
"lastVisit": "2023-04-01"
}
discount
object

The discount applied to the checkout, if any.