Create Plan
Creates a reusable pricing plan with optional per-country pricing and a trial phase ladder.
curl --request POST \
--url https://api-sandbox.y.uno/v1/plans \
--header 'Content-Type: application/json' \
--header 'private-secret-key: <api-key>' \
--header 'public-api-key: <api-key>' \
--data '
{
"name": "Streaming Pro",
"description": "Access to Pro features, billed monthly",
"merchant_reference": "streaming-pro-monthly",
"base_amount": {
"currency": "USD",
"value": 20
},
"frequency": {
"type": "MONTH",
"value": 1
},
"country_prices": [
{
"country": "US",
"amount": {
"currency": "USD",
"value": 20
}
},
{
"country": "BR",
"amount": {
"currency": "BRL",
"value": 99.9
}
}
],
"allowed_payment_methods": [
"CARD",
"PIX"
],
"metadata": [
{
"key": "campaign",
"value": "app_store"
}
],
"phases": [
{
"order": 1,
"name": "Intro",
"type": "TRIAL",
"duration": {
"type": "MONTH",
"value": 3
},
"frequency": {
"type": "MONTH",
"value": 1
},
"amount": {
"currency": "USD",
"value": 9.99
}
},
{
"order": 2,
"name": "Regular",
"type": "REGULAR"
}
]
}
'import requests
url = "https://api-sandbox.y.uno/v1/plans"
payload = {
"name": "Streaming Pro",
"description": "Access to Pro features, billed monthly",
"merchant_reference": "streaming-pro-monthly",
"base_amount": {
"currency": "USD",
"value": 20
},
"frequency": {
"type": "MONTH",
"value": 1
},
"country_prices": [
{
"country": "US",
"amount": {
"currency": "USD",
"value": 20
}
},
{
"country": "BR",
"amount": {
"currency": "BRL",
"value": 99.9
}
}
],
"allowed_payment_methods": ["CARD", "PIX"],
"metadata": [
{
"key": "campaign",
"value": "app_store"
}
],
"phases": [
{
"order": 1,
"name": "Intro",
"type": "TRIAL",
"duration": {
"type": "MONTH",
"value": 3
},
"frequency": {
"type": "MONTH",
"value": 1
},
"amount": {
"currency": "USD",
"value": 9.99
}
},
{
"order": 2,
"name": "Regular",
"type": "REGULAR"
}
]
}
headers = {
"public-api-key": "<api-key>",
"private-secret-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'public-api-key': '<api-key>',
'private-secret-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Streaming Pro',
description: 'Access to Pro features, billed monthly',
merchant_reference: 'streaming-pro-monthly',
base_amount: {currency: 'USD', value: 20},
frequency: {type: 'MONTH', value: 1},
country_prices: [
{country: 'US', amount: {currency: 'USD', value: 20}},
{country: 'BR', amount: {currency: 'BRL', value: 99.9}}
],
allowed_payment_methods: ['CARD', 'PIX'],
metadata: [{key: 'campaign', value: 'app_store'}],
phases: [
{
order: 1,
name: 'Intro',
type: 'TRIAL',
duration: {type: 'MONTH', value: 3},
frequency: {type: 'MONTH', value: 1},
amount: {currency: 'USD', value: 9.99}
},
{order: 2, name: 'Regular', type: 'REGULAR'}
]
})
};
fetch('https://api-sandbox.y.uno/v1/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_URL => "https://api-sandbox.y.uno/v1/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' => 'Streaming Pro',
'description' => 'Access to Pro features, billed monthly',
'merchant_reference' => 'streaming-pro-monthly',
'base_amount' => [
'currency' => 'USD',
'value' => 20
],
'frequency' => [
'type' => 'MONTH',
'value' => 1
],
'country_prices' => [
[
'country' => 'US',
'amount' => [
'currency' => 'USD',
'value' => 20
]
],
[
'country' => 'BR',
'amount' => [
'currency' => 'BRL',
'value' => 99.9
]
]
],
'allowed_payment_methods' => [
'CARD',
'PIX'
],
'metadata' => [
[
'key' => 'campaign',
'value' => 'app_store'
]
],
'phases' => [
[
'order' => 1,
'name' => 'Intro',
'type' => 'TRIAL',
'duration' => [
'type' => 'MONTH',
'value' => 3
],
'frequency' => [
'type' => 'MONTH',
'value' => 1
],
'amount' => [
'currency' => 'USD',
'value' => 9.99
]
],
[
'order' => 2,
'name' => 'Regular',
'type' => 'REGULAR'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"private-secret-key: <api-key>",
"public-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-sandbox.y.uno/v1/plans"
payload := strings.NewReader("{\n \"name\": \"Streaming Pro\",\n \"description\": \"Access to Pro features, billed monthly\",\n \"merchant_reference\": \"streaming-pro-monthly\",\n \"base_amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"country_prices\": [\n {\n \"country\": \"US\",\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n }\n },\n {\n \"country\": \"BR\",\n \"amount\": {\n \"currency\": \"BRL\",\n \"value\": 99.9\n }\n }\n ],\n \"allowed_payment_methods\": [\n \"CARD\",\n \"PIX\"\n ],\n \"metadata\": [\n {\n \"key\": \"campaign\",\n \"value\": \"app_store\"\n }\n ],\n \"phases\": [\n {\n \"order\": 1,\n \"name\": \"Intro\",\n \"type\": \"TRIAL\",\n \"duration\": {\n \"type\": \"MONTH\",\n \"value\": 3\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 9.99\n }\n },\n {\n \"order\": 2,\n \"name\": \"Regular\",\n \"type\": \"REGULAR\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("public-api-key", "<api-key>")
req.Header.Add("private-secret-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-sandbox.y.uno/v1/plans")
.header("public-api-key", "<api-key>")
.header("private-secret-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Streaming Pro\",\n \"description\": \"Access to Pro features, billed monthly\",\n \"merchant_reference\": \"streaming-pro-monthly\",\n \"base_amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"country_prices\": [\n {\n \"country\": \"US\",\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n }\n },\n {\n \"country\": \"BR\",\n \"amount\": {\n \"currency\": \"BRL\",\n \"value\": 99.9\n }\n }\n ],\n \"allowed_payment_methods\": [\n \"CARD\",\n \"PIX\"\n ],\n \"metadata\": [\n {\n \"key\": \"campaign\",\n \"value\": \"app_store\"\n }\n ],\n \"phases\": [\n {\n \"order\": 1,\n \"name\": \"Intro\",\n \"type\": \"TRIAL\",\n \"duration\": {\n \"type\": \"MONTH\",\n \"value\": 3\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 9.99\n }\n },\n {\n \"order\": 2,\n \"name\": \"Regular\",\n \"type\": \"REGULAR\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/plans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["public-api-key"] = '<api-key>'
request["private-secret-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Streaming Pro\",\n \"description\": \"Access to Pro features, billed monthly\",\n \"merchant_reference\": \"streaming-pro-monthly\",\n \"base_amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"country_prices\": [\n {\n \"country\": \"US\",\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n }\n },\n {\n \"country\": \"BR\",\n \"amount\": {\n \"currency\": \"BRL\",\n \"value\": 99.9\n }\n }\n ],\n \"allowed_payment_methods\": [\n \"CARD\",\n \"PIX\"\n ],\n \"metadata\": [\n {\n \"key\": \"campaign\",\n \"value\": \"app_store\"\n }\n ],\n \"phases\": [\n {\n \"order\": 1,\n \"name\": \"Intro\",\n \"type\": \"TRIAL\",\n \"duration\": {\n \"type\": \"MONTH\",\n \"value\": 3\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 9.99\n }\n },\n {\n \"order\": 2,\n \"name\": \"Regular\",\n \"type\": \"REGULAR\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "00000000-0000-4000-8000-000000000001",
"account_id": "00000000-0000-4000-8000-000000000002",
"name": "Streaming Pro",
"description": "Access to Pro features, billed monthly",
"merchant_reference": "streaming-pro-monthly",
"status": "ACTIVE",
"base_amount": {
"currency": "USD",
"value": 20
},
"frequency": {
"type": "MONTH",
"value": 1
},
"country_prices": [
{
"country": "US",
"amount": {
"currency": "USD",
"value": 20
}
},
{
"country": "BR",
"amount": {
"currency": "BRL",
"value": 99.9
}
}
],
"allowed_payment_methods": [
"CARD",
"PIX"
],
"metadata": [
{
"key": "campaign",
"value": "app_store"
}
],
"phases": [],
"created_at": "2024-01-15T10:30:00.000000Z",
"updated_at": "2024-01-15T10:30:00.000000Z"
}"{\n Refer to the HTTP Response Codes section for more details: 'https://docs.y.uno/reference/response-codes'\n}"Authorizations
Body
The plan name (MAX 255; MIN 3).
The default price used for any country without an explicit entry in country_prices.
Show child attributes
Show child attributes
The billing frequency for the plan. Subscriptions created from this plan inherit it.
Show child attributes
Show child attributes
The plan description. No length limit is currently enforced.
Your own identifier for the plan. No length limit is currently enforced.
Optional explicit per-country prices. A country not listed falls back to base_amount.
Show child attributes
Show child attributes
Payment method types accepted for subscriptions on this plan.
Key-value pairs attached to the plan. Independent of any metadata set on a subscription created from it.
Show child attributes
Show child attributes
Optional leading ladder (for example, a trial) before the plan's regular price. Omit for a flat plan. The last entry must be the terminal REGULAR phase with no duration.
Show child attributes
Show child attributes
Response
200
"ACTIVE"
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
curl --request POST \
--url https://api-sandbox.y.uno/v1/plans \
--header 'Content-Type: application/json' \
--header 'private-secret-key: <api-key>' \
--header 'public-api-key: <api-key>' \
--data '
{
"name": "Streaming Pro",
"description": "Access to Pro features, billed monthly",
"merchant_reference": "streaming-pro-monthly",
"base_amount": {
"currency": "USD",
"value": 20
},
"frequency": {
"type": "MONTH",
"value": 1
},
"country_prices": [
{
"country": "US",
"amount": {
"currency": "USD",
"value": 20
}
},
{
"country": "BR",
"amount": {
"currency": "BRL",
"value": 99.9
}
}
],
"allowed_payment_methods": [
"CARD",
"PIX"
],
"metadata": [
{
"key": "campaign",
"value": "app_store"
}
],
"phases": [
{
"order": 1,
"name": "Intro",
"type": "TRIAL",
"duration": {
"type": "MONTH",
"value": 3
},
"frequency": {
"type": "MONTH",
"value": 1
},
"amount": {
"currency": "USD",
"value": 9.99
}
},
{
"order": 2,
"name": "Regular",
"type": "REGULAR"
}
]
}
'import requests
url = "https://api-sandbox.y.uno/v1/plans"
payload = {
"name": "Streaming Pro",
"description": "Access to Pro features, billed monthly",
"merchant_reference": "streaming-pro-monthly",
"base_amount": {
"currency": "USD",
"value": 20
},
"frequency": {
"type": "MONTH",
"value": 1
},
"country_prices": [
{
"country": "US",
"amount": {
"currency": "USD",
"value": 20
}
},
{
"country": "BR",
"amount": {
"currency": "BRL",
"value": 99.9
}
}
],
"allowed_payment_methods": ["CARD", "PIX"],
"metadata": [
{
"key": "campaign",
"value": "app_store"
}
],
"phases": [
{
"order": 1,
"name": "Intro",
"type": "TRIAL",
"duration": {
"type": "MONTH",
"value": 3
},
"frequency": {
"type": "MONTH",
"value": 1
},
"amount": {
"currency": "USD",
"value": 9.99
}
},
{
"order": 2,
"name": "Regular",
"type": "REGULAR"
}
]
}
headers = {
"public-api-key": "<api-key>",
"private-secret-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'public-api-key': '<api-key>',
'private-secret-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Streaming Pro',
description: 'Access to Pro features, billed monthly',
merchant_reference: 'streaming-pro-monthly',
base_amount: {currency: 'USD', value: 20},
frequency: {type: 'MONTH', value: 1},
country_prices: [
{country: 'US', amount: {currency: 'USD', value: 20}},
{country: 'BR', amount: {currency: 'BRL', value: 99.9}}
],
allowed_payment_methods: ['CARD', 'PIX'],
metadata: [{key: 'campaign', value: 'app_store'}],
phases: [
{
order: 1,
name: 'Intro',
type: 'TRIAL',
duration: {type: 'MONTH', value: 3},
frequency: {type: 'MONTH', value: 1},
amount: {currency: 'USD', value: 9.99}
},
{order: 2, name: 'Regular', type: 'REGULAR'}
]
})
};
fetch('https://api-sandbox.y.uno/v1/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_URL => "https://api-sandbox.y.uno/v1/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' => 'Streaming Pro',
'description' => 'Access to Pro features, billed monthly',
'merchant_reference' => 'streaming-pro-monthly',
'base_amount' => [
'currency' => 'USD',
'value' => 20
],
'frequency' => [
'type' => 'MONTH',
'value' => 1
],
'country_prices' => [
[
'country' => 'US',
'amount' => [
'currency' => 'USD',
'value' => 20
]
],
[
'country' => 'BR',
'amount' => [
'currency' => 'BRL',
'value' => 99.9
]
]
],
'allowed_payment_methods' => [
'CARD',
'PIX'
],
'metadata' => [
[
'key' => 'campaign',
'value' => 'app_store'
]
],
'phases' => [
[
'order' => 1,
'name' => 'Intro',
'type' => 'TRIAL',
'duration' => [
'type' => 'MONTH',
'value' => 3
],
'frequency' => [
'type' => 'MONTH',
'value' => 1
],
'amount' => [
'currency' => 'USD',
'value' => 9.99
]
],
[
'order' => 2,
'name' => 'Regular',
'type' => 'REGULAR'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"private-secret-key: <api-key>",
"public-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-sandbox.y.uno/v1/plans"
payload := strings.NewReader("{\n \"name\": \"Streaming Pro\",\n \"description\": \"Access to Pro features, billed monthly\",\n \"merchant_reference\": \"streaming-pro-monthly\",\n \"base_amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"country_prices\": [\n {\n \"country\": \"US\",\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n }\n },\n {\n \"country\": \"BR\",\n \"amount\": {\n \"currency\": \"BRL\",\n \"value\": 99.9\n }\n }\n ],\n \"allowed_payment_methods\": [\n \"CARD\",\n \"PIX\"\n ],\n \"metadata\": [\n {\n \"key\": \"campaign\",\n \"value\": \"app_store\"\n }\n ],\n \"phases\": [\n {\n \"order\": 1,\n \"name\": \"Intro\",\n \"type\": \"TRIAL\",\n \"duration\": {\n \"type\": \"MONTH\",\n \"value\": 3\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 9.99\n }\n },\n {\n \"order\": 2,\n \"name\": \"Regular\",\n \"type\": \"REGULAR\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("public-api-key", "<api-key>")
req.Header.Add("private-secret-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-sandbox.y.uno/v1/plans")
.header("public-api-key", "<api-key>")
.header("private-secret-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Streaming Pro\",\n \"description\": \"Access to Pro features, billed monthly\",\n \"merchant_reference\": \"streaming-pro-monthly\",\n \"base_amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"country_prices\": [\n {\n \"country\": \"US\",\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n }\n },\n {\n \"country\": \"BR\",\n \"amount\": {\n \"currency\": \"BRL\",\n \"value\": 99.9\n }\n }\n ],\n \"allowed_payment_methods\": [\n \"CARD\",\n \"PIX\"\n ],\n \"metadata\": [\n {\n \"key\": \"campaign\",\n \"value\": \"app_store\"\n }\n ],\n \"phases\": [\n {\n \"order\": 1,\n \"name\": \"Intro\",\n \"type\": \"TRIAL\",\n \"duration\": {\n \"type\": \"MONTH\",\n \"value\": 3\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 9.99\n }\n },\n {\n \"order\": 2,\n \"name\": \"Regular\",\n \"type\": \"REGULAR\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/plans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["public-api-key"] = '<api-key>'
request["private-secret-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Streaming Pro\",\n \"description\": \"Access to Pro features, billed monthly\",\n \"merchant_reference\": \"streaming-pro-monthly\",\n \"base_amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"country_prices\": [\n {\n \"country\": \"US\",\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 20\n }\n },\n {\n \"country\": \"BR\",\n \"amount\": {\n \"currency\": \"BRL\",\n \"value\": 99.9\n }\n }\n ],\n \"allowed_payment_methods\": [\n \"CARD\",\n \"PIX\"\n ],\n \"metadata\": [\n {\n \"key\": \"campaign\",\n \"value\": \"app_store\"\n }\n ],\n \"phases\": [\n {\n \"order\": 1,\n \"name\": \"Intro\",\n \"type\": \"TRIAL\",\n \"duration\": {\n \"type\": \"MONTH\",\n \"value\": 3\n },\n \"frequency\": {\n \"type\": \"MONTH\",\n \"value\": 1\n },\n \"amount\": {\n \"currency\": \"USD\",\n \"value\": 9.99\n }\n },\n {\n \"order\": 2,\n \"name\": \"Regular\",\n \"type\": \"REGULAR\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "00000000-0000-4000-8000-000000000001",
"account_id": "00000000-0000-4000-8000-000000000002",
"name": "Streaming Pro",
"description": "Access to Pro features, billed monthly",
"merchant_reference": "streaming-pro-monthly",
"status": "ACTIVE",
"base_amount": {
"currency": "USD",
"value": 20
},
"frequency": {
"type": "MONTH",
"value": 1
},
"country_prices": [
{
"country": "US",
"amount": {
"currency": "USD",
"value": 20
}
},
{
"country": "BR",
"amount": {
"currency": "BRL",
"value": 99.9
}
}
],
"allowed_payment_methods": [
"CARD",
"PIX"
],
"metadata": [
{
"key": "campaign",
"value": "app_store"
}
],
"phases": [],
"created_at": "2024-01-15T10:30:00.000000Z",
"updated_at": "2024-01-15T10:30:00.000000Z"
}"{\n Refer to the HTTP Response Codes section for more details: 'https://docs.y.uno/reference/response-codes'\n}"