curl --request POST \
--url http://localhost:7701/api/v1/subscriptions/plans \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'x-client-id: <x-client-id>' \
--data '
{
"name": "Basic Monthly",
"amount": 2990,
"interval": "monthly",
"description": "Access to all basic features.",
"currency": "BRL",
"interval_count": 1,
"trial_period_days": 7,
"billing_day": 5,
"min_card_months": 3
}
'import requests
url = "http://localhost:7701/api/v1/subscriptions/plans"
payload = {
"name": "Basic Monthly",
"amount": 2990,
"interval": "monthly",
"description": "Access to all basic features.",
"currency": "BRL",
"interval_count": 1,
"trial_period_days": 7,
"billing_day": 5,
"min_card_months": 3
}
headers = {
"x-client-id": "<x-client-id>",
"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-client-id': '<x-client-id>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Basic Monthly',
amount: 2990,
interval: 'monthly',
description: 'Access to all basic features.',
currency: 'BRL',
interval_count: 1,
trial_period_days: 7,
billing_day: 5,
min_card_months: 3
})
};
fetch('http://localhost:7701/api/v1/subscriptions/plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "7701",
CURLOPT_URL => "http://localhost:7701/api/v1/subscriptions/plans",
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([
'name' => 'Basic Monthly',
'amount' => 2990,
'interval' => 'monthly',
'description' => 'Access to all basic features.',
'currency' => 'BRL',
'interval_count' => 1,
'trial_period_days' => 7,
'billing_day' => 5,
'min_card_months' => 3
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"x-client-id: <x-client-id>"
],
]);
$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 := "http://localhost:7701/api/v1/subscriptions/plans"
payload := strings.NewReader("{\n \"name\": \"Basic Monthly\",\n \"amount\": 2990,\n \"interval\": \"monthly\",\n \"description\": \"Access to all basic features.\",\n \"currency\": \"BRL\",\n \"interval_count\": 1,\n \"trial_period_days\": 7,\n \"billing_day\": 5,\n \"min_card_months\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<x-client-id>")
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("http://localhost:7701/api/v1/subscriptions/plans")
.header("x-client-id", "<x-client-id>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Basic Monthly\",\n \"amount\": 2990,\n \"interval\": \"monthly\",\n \"description\": \"Access to all basic features.\",\n \"currency\": \"BRL\",\n \"interval_count\": 1,\n \"trial_period_days\": 7,\n \"billing_day\": 5,\n \"min_card_months\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:7701/api/v1/subscriptions/plans")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-client-id"] = '<x-client-id>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Basic Monthly\",\n \"amount\": 2990,\n \"interval\": \"monthly\",\n \"description\": \"Access to all basic features.\",\n \"currency\": \"BRL\",\n \"interval_count\": 1,\n \"trial_period_days\": 7,\n \"billing_day\": 5,\n \"min_card_months\": 3\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Basic Monthly",
"description": "<string>",
"amount": 2990,
"currency": "BRL",
"interval": "monthly",
"interval_count": 1,
"trial_period_days": 7,
"billing_day": 5,
"min_card_months": 3,
"is_active": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}Create a subscription plan
Creates a reusable billing plan. Subscriptions are attached to a plan and inherit its interval, amount, and trial settings.
curl --request POST \
--url http://localhost:7701/api/v1/subscriptions/plans \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--header 'x-client-id: <x-client-id>' \
--data '
{
"name": "Basic Monthly",
"amount": 2990,
"interval": "monthly",
"description": "Access to all basic features.",
"currency": "BRL",
"interval_count": 1,
"trial_period_days": 7,
"billing_day": 5,
"min_card_months": 3
}
'import requests
url = "http://localhost:7701/api/v1/subscriptions/plans"
payload = {
"name": "Basic Monthly",
"amount": 2990,
"interval": "monthly",
"description": "Access to all basic features.",
"currency": "BRL",
"interval_count": 1,
"trial_period_days": 7,
"billing_day": 5,
"min_card_months": 3
}
headers = {
"x-client-id": "<x-client-id>",
"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-client-id': '<x-client-id>',
'X-API-Key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Basic Monthly',
amount: 2990,
interval: 'monthly',
description: 'Access to all basic features.',
currency: 'BRL',
interval_count: 1,
trial_period_days: 7,
billing_day: 5,
min_card_months: 3
})
};
fetch('http://localhost:7701/api/v1/subscriptions/plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "7701",
CURLOPT_URL => "http://localhost:7701/api/v1/subscriptions/plans",
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([
'name' => 'Basic Monthly',
'amount' => 2990,
'interval' => 'monthly',
'description' => 'Access to all basic features.',
'currency' => 'BRL',
'interval_count' => 1,
'trial_period_days' => 7,
'billing_day' => 5,
'min_card_months' => 3
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>",
"x-client-id: <x-client-id>"
],
]);
$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 := "http://localhost:7701/api/v1/subscriptions/plans"
payload := strings.NewReader("{\n \"name\": \"Basic Monthly\",\n \"amount\": 2990,\n \"interval\": \"monthly\",\n \"description\": \"Access to all basic features.\",\n \"currency\": \"BRL\",\n \"interval_count\": 1,\n \"trial_period_days\": 7,\n \"billing_day\": 5,\n \"min_card_months\": 3\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<x-client-id>")
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("http://localhost:7701/api/v1/subscriptions/plans")
.header("x-client-id", "<x-client-id>")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Basic Monthly\",\n \"amount\": 2990,\n \"interval\": \"monthly\",\n \"description\": \"Access to all basic features.\",\n \"currency\": \"BRL\",\n \"interval_count\": 1,\n \"trial_period_days\": 7,\n \"billing_day\": 5,\n \"min_card_months\": 3\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:7701/api/v1/subscriptions/plans")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["x-client-id"] = '<x-client-id>'
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Basic Monthly\",\n \"amount\": 2990,\n \"interval\": \"monthly\",\n \"description\": \"Access to all basic features.\",\n \"currency\": \"BRL\",\n \"interval_count\": 1,\n \"trial_period_days\": 7,\n \"billing_day\": 5,\n \"min_card_months\": 3\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "Basic Monthly",
"description": "<string>",
"amount": 2990,
"currency": "BRL",
"interval": "monthly",
"interval_count": 1,
"trial_period_days": 7,
"billing_day": 5,
"min_card_months": 3,
"is_active": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}Authorizations
Company API key. Send in the X-API-Key header.
Headers
Client identifier for the company in the request.
"client_abc123"
Body
Display name for the plan (max 255 chars).
"Basic Monthly"
Plan price in cents (e.g. 2990 = R$29,90).
2990
Billing frequency.
weekly, monthly, yearly "monthly"
Optional description (max 1000 chars).
"Access to all basic features."
3-letter ISO currency code. Defaults to BRL.
"BRL"
Number of intervals between charges (e.g. 3 + monthly = every 3 months). Min 1, max 365.
1
Free trial days before first charge (1–365).
7
Day of the month to charge (1–28). Defaults to the subscription creation day.
5
Minimum months the card must be valid at subscription creation (1–120). Null or absent = no restriction.
3
Response
Plan created
Show child attributes
Show child attributes