Create Subscription
curl --request POST \
--url https://api.creptapay.com/v1/subscriptions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"plan": "6712f0a1b9c4e2d3f4a5b6c7",
"customer_id": "<string>",
"collection_mode": "invoice",
"trial_days": 123,
"metadata": {}
}
'import requests
url = "https://api.creptapay.com/v1/subscriptions"
payload = {
"plan": "6712f0a1b9c4e2d3f4a5b6c7",
"customer_id": "<string>",
"collection_mode": "invoice",
"trial_days": 123,
"metadata": {}
}
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({
plan: '6712f0a1b9c4e2d3f4a5b6c7',
customer_id: '<string>',
collection_mode: 'invoice',
trial_days: 123,
metadata: {}
})
};
fetch('https://api.creptapay.com/v1/subscriptions', 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.creptapay.com/v1/subscriptions",
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([
'plan' => '6712f0a1b9c4e2d3f4a5b6c7',
'customer_id' => '<string>',
'collection_mode' => 'invoice',
'trial_days' => 123,
'metadata' => [
]
]),
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.creptapay.com/v1/subscriptions"
payload := strings.NewReader("{\n \"plan\": \"6712f0a1b9c4e2d3f4a5b6c7\",\n \"customer_id\": \"<string>\",\n \"collection_mode\": \"invoice\",\n \"trial_days\": 123,\n \"metadata\": {}\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.creptapay.com/v1/subscriptions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"plan\": \"6712f0a1b9c4e2d3f4a5b6c7\",\n \"customer_id\": \"<string>\",\n \"collection_mode\": \"invoice\",\n \"trial_days\": 123,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.creptapay.com/v1/subscriptions")
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 \"plan\": \"6712f0a1b9c4e2d3f4a5b6c7\",\n \"customer_id\": \"<string>\",\n \"collection_mode\": \"invoice\",\n \"trial_days\": 123,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"message": "Successfully created subscription",
"data": {
"id": "6713a2b4c8d5e3f2a1b9c4e2",
"reference": "SUB-K3F9A2QP",
"status": "trialing",
"collection_mode": "invoice",
"checkout_url": "https://pay.creptapay.com/SUB-K3F9A2QP",
"amount_due": {
"amount": 49,
"currency": "USD"
},
"terms": {
"amount": 49,
"currency": "USD",
"interval": "month",
"interval_count": 1,
"grace_days": 7,
"allowed_currencies": [
"USDC"
],
"captured_at": "2026-01-15T09:22:11.000Z"
},
"on_legacy_terms": false,
"plan": {
"id": "6712f0a1b9c4e2d3f4a5b6c7",
"name": "Pro monthly",
"amount": 49,
"currency": "USD",
"interval": "month",
"interval_count": 1,
"grace_days": 7
},
"customer": {
"id": "60d0fe4f5311236168a109c9",
"name": "Chidera Okonkwo",
"email": "chidera@example.com"
},
"current_period_start": null,
"current_period_end": null,
"next_billing_at": "2026-01-29T09:22:11.000Z",
"grace_ends_at": null,
"trial_ends_at": "2026-01-29T09:22:11.000Z",
"cancel_at_period_end": false,
"canceled_at": null,
"cancel_reason": null,
"latest_payment": null,
"payments_count": 0,
"failed_attempts": 0,
"last_failure_reason": null,
"metadata": null,
"createdAt": "2026-01-15T09:22:11.000Z",
"updatedAt": "2026-02-15T09:22:14.000Z"
}
}{
"message": "A grace period can't be longer than 30 days",
"data": null
}{
"message": "Invalid API key",
"data": null
}Subscriptions
Create Subscription
Subscribe a customer to a plan. The plan’s terms are copied onto the subscription, so later plan edits never change what this subscriber pays. Requires a secret key.
POST
/
subscriptions
Create Subscription
curl --request POST \
--url https://api.creptapay.com/v1/subscriptions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"plan": "6712f0a1b9c4e2d3f4a5b6c7",
"customer_id": "<string>",
"collection_mode": "invoice",
"trial_days": 123,
"metadata": {}
}
'import requests
url = "https://api.creptapay.com/v1/subscriptions"
payload = {
"plan": "6712f0a1b9c4e2d3f4a5b6c7",
"customer_id": "<string>",
"collection_mode": "invoice",
"trial_days": 123,
"metadata": {}
}
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({
plan: '6712f0a1b9c4e2d3f4a5b6c7',
customer_id: '<string>',
collection_mode: 'invoice',
trial_days: 123,
metadata: {}
})
};
fetch('https://api.creptapay.com/v1/subscriptions', 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.creptapay.com/v1/subscriptions",
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([
'plan' => '6712f0a1b9c4e2d3f4a5b6c7',
'customer_id' => '<string>',
'collection_mode' => 'invoice',
'trial_days' => 123,
'metadata' => [
]
]),
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.creptapay.com/v1/subscriptions"
payload := strings.NewReader("{\n \"plan\": \"6712f0a1b9c4e2d3f4a5b6c7\",\n \"customer_id\": \"<string>\",\n \"collection_mode\": \"invoice\",\n \"trial_days\": 123,\n \"metadata\": {}\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.creptapay.com/v1/subscriptions")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"plan\": \"6712f0a1b9c4e2d3f4a5b6c7\",\n \"customer_id\": \"<string>\",\n \"collection_mode\": \"invoice\",\n \"trial_days\": 123,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.creptapay.com/v1/subscriptions")
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 \"plan\": \"6712f0a1b9c4e2d3f4a5b6c7\",\n \"customer_id\": \"<string>\",\n \"collection_mode\": \"invoice\",\n \"trial_days\": 123,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"message": "Successfully created subscription",
"data": {
"id": "6713a2b4c8d5e3f2a1b9c4e2",
"reference": "SUB-K3F9A2QP",
"status": "trialing",
"collection_mode": "invoice",
"checkout_url": "https://pay.creptapay.com/SUB-K3F9A2QP",
"amount_due": {
"amount": 49,
"currency": "USD"
},
"terms": {
"amount": 49,
"currency": "USD",
"interval": "month",
"interval_count": 1,
"grace_days": 7,
"allowed_currencies": [
"USDC"
],
"captured_at": "2026-01-15T09:22:11.000Z"
},
"on_legacy_terms": false,
"plan": {
"id": "6712f0a1b9c4e2d3f4a5b6c7",
"name": "Pro monthly",
"amount": 49,
"currency": "USD",
"interval": "month",
"interval_count": 1,
"grace_days": 7
},
"customer": {
"id": "60d0fe4f5311236168a109c9",
"name": "Chidera Okonkwo",
"email": "chidera@example.com"
},
"current_period_start": null,
"current_period_end": null,
"next_billing_at": "2026-01-29T09:22:11.000Z",
"grace_ends_at": null,
"trial_ends_at": "2026-01-29T09:22:11.000Z",
"cancel_at_period_end": false,
"canceled_at": null,
"cancel_reason": null,
"latest_payment": null,
"payments_count": 0,
"failed_attempts": 0,
"last_failure_reason": null,
"metadata": null,
"createdAt": "2026-01-15T09:22:11.000Z",
"updatedAt": "2026-02-15T09:22:14.000Z"
}
}{
"message": "A grace period can't be longer than 30 days",
"data": null
}{
"message": "Invalid API key",
"data": null
}Subscribe a customer to a plan.
The plan’s price, cadence and grace period are copied onto the subscription at
this moment. Editing the plan afterwards never changes what this subscriber
pays — see Subscriptions.
Request authentication
This endpoint requires a Secret Key (sk_...) passed in either the
x-api-key header or as a Bearer token in the Authorization header.
Request parameters
Body
application/json