curl --request POST \
--url https://{defaultHost}/v1/prices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"price": {
"name": "Test Price",
"amount": 2900,
"product_id": "6908abe6-3999-43fa-a80c-0396e2c9e5c8"
}
}
'import requests
url = "https://{defaultHost}/v1/prices"
payload = { "price": {
"name": "Test Price",
"amount": 2900,
"product_id": "6908abe6-3999-43fa-a80c-0396e2c9e5c8"
} }
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({
price: {
name: 'Test Price',
amount: 2900,
product_id: '6908abe6-3999-43fa-a80c-0396e2c9e5c8'
}
})
};
fetch('https://{defaultHost}/v1/prices', 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://{defaultHost}/v1/prices",
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([
'price' => [
'name' => 'Test Price',
'amount' => 2900,
'product_id' => '6908abe6-3999-43fa-a80c-0396e2c9e5c8'
]
]),
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://{defaultHost}/v1/prices"
payload := strings.NewReader("{\n \"price\": {\n \"name\": \"Test Price\",\n \"amount\": 2900,\n \"product_id\": \"6908abe6-3999-43fa-a80c-0396e2c9e5c8\"\n }\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://{defaultHost}/v1/prices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"price\": {\n \"name\": \"Test Price\",\n \"amount\": 2900,\n \"product_id\": \"6908abe6-3999-43fa-a80c-0396e2c9e5c8\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/prices")
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 \"price\": {\n \"name\": \"Test Price\",\n \"amount\": 2900,\n \"product_id\": \"6908abe6-3999-43fa-a80c-0396e2c9e5c8\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "6338b2ab-4698-4be4-8931-864dbcc18d63",
"object": "price",
"ad_hoc": false,
"ad_hoc_max_amount": null,
"ad_hoc_min_amount": 0,
"amount": 2900,
"archived": false,
"archived_at": null,
"currency": "usd",
"current_version": true,
"full_amount": 2900,
"license_activation_limit": null,
"metadata": {},
"name": "Test Price",
"position": 0,
"portal_subscription_update_enabled": true,
"proration_method": "unused_amount_paid",
"restart_subscription_on_completed": false,
"revoke_after_days": null,
"revoke_purchases_on_completed": false,
"recurring_interval": null,
"recurring_interval_count": null,
"recurring_period_count": null,
"scratch_amount": null,
"setup_fee_amount": 0,
"setup_fee_enabled": false,
"setup_fee_trial_enabled": true,
"setup_fee_name": null,
"trial_duration_days": null,
"current_swap": null,
"product": "6908abe6-3999-43fa-a80c-0396e2c9e5c8",
"renewal_price": null,
"discarded_at": null,
"created_at": 1796063955,
"updated_at": 1796063955
}Create
Creates a new price.
curl --request POST \
--url https://{defaultHost}/v1/prices \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"price": {
"name": "Test Price",
"amount": 2900,
"product_id": "6908abe6-3999-43fa-a80c-0396e2c9e5c8"
}
}
'import requests
url = "https://{defaultHost}/v1/prices"
payload = { "price": {
"name": "Test Price",
"amount": 2900,
"product_id": "6908abe6-3999-43fa-a80c-0396e2c9e5c8"
} }
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({
price: {
name: 'Test Price',
amount: 2900,
product_id: '6908abe6-3999-43fa-a80c-0396e2c9e5c8'
}
})
};
fetch('https://{defaultHost}/v1/prices', 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://{defaultHost}/v1/prices",
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([
'price' => [
'name' => 'Test Price',
'amount' => 2900,
'product_id' => '6908abe6-3999-43fa-a80c-0396e2c9e5c8'
]
]),
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://{defaultHost}/v1/prices"
payload := strings.NewReader("{\n \"price\": {\n \"name\": \"Test Price\",\n \"amount\": 2900,\n \"product_id\": \"6908abe6-3999-43fa-a80c-0396e2c9e5c8\"\n }\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://{defaultHost}/v1/prices")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"price\": {\n \"name\": \"Test Price\",\n \"amount\": 2900,\n \"product_id\": \"6908abe6-3999-43fa-a80c-0396e2c9e5c8\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{defaultHost}/v1/prices")
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 \"price\": {\n \"name\": \"Test Price\",\n \"amount\": 2900,\n \"product_id\": \"6908abe6-3999-43fa-a80c-0396e2c9e5c8\"\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "6338b2ab-4698-4be4-8931-864dbcc18d63",
"object": "price",
"ad_hoc": false,
"ad_hoc_max_amount": null,
"ad_hoc_min_amount": 0,
"amount": 2900,
"archived": false,
"archived_at": null,
"currency": "usd",
"current_version": true,
"full_amount": 2900,
"license_activation_limit": null,
"metadata": {},
"name": "Test Price",
"position": 0,
"portal_subscription_update_enabled": true,
"proration_method": "unused_amount_paid",
"restart_subscription_on_completed": false,
"revoke_after_days": null,
"revoke_purchases_on_completed": false,
"recurring_interval": null,
"recurring_interval_count": null,
"recurring_period_count": null,
"scratch_amount": null,
"setup_fee_amount": 0,
"setup_fee_enabled": false,
"setup_fee_trial_enabled": true,
"setup_fee_name": null,
"trial_duration_days": null,
"current_swap": null,
"product": "6908abe6-3999-43fa-a80c-0396e2c9e5c8",
"renewal_price": null,
"discarded_at": null,
"created_at": 1796063955,
"updated_at": 1796063955
}Authorizations
Response
Success
How a subscription switching to this price is credited for the unused part of its current period. unused_amount_paid credits the unused part of what was paid for the previous period, unused_renewal_price credits the unused part of the previous plan's renewal price, price_difference credits the previous plan's full renewal price so only the price difference is charged, and none gives no credit. The two price-based methods never reduce the charge below zero (for fixed-payment prices, below the total of all payments).
unused_amount_paid, unused_renewal_price, price_difference, none The number of intervals (specified in the recurring_interval attribute) between subscription billings. For example, recurring_interval=month and recurring_interval_count=3 bills every 3 months. The total duration of a billing cycle is not allowed to exceed 1 year. Only applicable during creation.
The full amount to be charged across all periods, represented as a whole integer. For prices without a recurring_period_count defined this is the same as amount. For finite prices, this is equal to amount * recurring_period_count. For example, a price that has an amount of $25 and is set to recur over 4 periods, will have a full_amount of $100.
The current swap for this price.
Expandable – The associated swap ID.
Expandable – The associated product ID.
If present, subscriptions will be updated to this price when they renew.
Expandable – The associated price ID.
Was this page helpful?