Skip to main content
POST
/
v1
/
subscriptions
Create a subscription
curl --request POST \
  --url https://api.useplinth.com/v1/subscriptions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customer_id": "cus_01JABC...",
  "plan_id": "pln_01JABC...",
  "default_payment_method_id": "tok_test_visa",
  "preferred_rail": "card",
  "quantity": 1,
  "metadata": {}
}
'
import requests

url = "https://api.useplinth.com/v1/subscriptions"

payload = {
    "customer_id": "cus_01JABC...",
    "plan_id": "pln_01JABC...",
    "default_payment_method_id": "tok_test_visa",
    "preferred_rail": "card",
    "quantity": 1,
    "metadata": {}
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    customer_id: 'cus_01JABC...',
    plan_id: 'pln_01JABC...',
    default_payment_method_id: 'tok_test_visa',
    preferred_rail: 'card',
    quantity: 1,
    metadata: {}
  })
};

fetch('https://api.useplinth.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.useplinth.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([
    'customer_id' => 'cus_01JABC...',
    'plan_id' => 'pln_01JABC...',
    'default_payment_method_id' => 'tok_test_visa',
    'preferred_rail' => 'card',
    'quantity' => 1,
    'metadata' => [
        
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$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.useplinth.com/v1/subscriptions"

	payload := strings.NewReader("{\n  \"customer_id\": \"cus_01JABC...\",\n  \"plan_id\": \"pln_01JABC...\",\n  \"default_payment_method_id\": \"tok_test_visa\",\n  \"preferred_rail\": \"card\",\n  \"quantity\": 1,\n  \"metadata\": {}\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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.useplinth.com/v1/subscriptions")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customer_id\": \"cus_01JABC...\",\n  \"plan_id\": \"pln_01JABC...\",\n  \"default_payment_method_id\": \"tok_test_visa\",\n  \"preferred_rail\": \"card\",\n  \"quantity\": 1,\n  \"metadata\": {}\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.useplinth.com/v1/subscriptions")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"customer_id\": \"cus_01JABC...\",\n  \"plan_id\": \"pln_01JABC...\",\n  \"default_payment_method_id\": \"tok_test_visa\",\n  \"preferred_rail\": \"card\",\n  \"quantity\": 1,\n  \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "object": "subscription",
  "id": "sub_01JABC...",
  "state": "active",
  "current_period_start": "2026-06-01T00:00:00Z",
  "current_period_end": "2026-07-01T00:00:00Z",
  "trial_end_at": null,
  "next_bill_at": "2026-07-01T00:00:00Z"
}

Authorizations

Authorization
string
header
required

Use sk_test_ keys for sandbox. Use sk_live_ keys for production. Obtain your key from the dashboard.

Body

application/json
customer_id
string
required
Example:

"cus_01JABC..."

plan_id
string
required
Example:

"pln_01JABC..."

default_payment_method_id
string

Card token from Nomba. Required for card-rail subscriptions.

Example:

"tok_test_visa"

preferred_rail
enum<string>
default:card
Available options:
card,
transfer,
direct_debit
Example:

"card"

quantity
integer
default:1
Example:

1

metadata
object

Response

201 - application/json

Subscription created

object
enum<string>
Available options:
subscription
id
string
Example:

"sub_01JABC..."

state
enum<string>
Available options:
incomplete,
active,
trialing,
past_due,
grace,
delinquent,
paused,
canceled
Example:

"active"

current_period_start
string<date-time>
current_period_end
string<date-time>
trial_end_at
string<date-time> | null
next_bill_at
string<date-time>
cancel_at_period_end
boolean

True when the subscription is set to cancel at period end (still active until then).

Example:

false

canceled_at
string<date-time> | null
has_card
boolean

Whether a card token is on file. Transfer-funded subs have none.

Example:

true

scheduled_change
object | null

A pending period-end plan change (e.g. a scheduled downgrade).