curl --request POST \
--url https://api.paygentic.io/v0/plans/{id}/versions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"addPrices": [
"<string>"
],
"removePrices": [
"<string>"
],
"replacePrices": [
{
"replacesPriceId": "<string>",
"withPriceId": "<string>"
}
]
}
'import requests
url = "https://api.paygentic.io/v0/plans/{id}/versions"
payload = {
"addPrices": ["<string>"],
"removePrices": ["<string>"],
"replacePrices": [
{
"replacesPriceId": "<string>",
"withPriceId": "<string>"
}
]
}
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({
addPrices: ['<string>'],
removePrices: ['<string>'],
replacePrices: [{replacesPriceId: '<string>', withPriceId: '<string>'}]
})
};
fetch('https://api.paygentic.io/v0/plans/{id}/versions', 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.paygentic.io/v0/plans/{id}/versions",
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([
'addPrices' => [
'<string>'
],
'removePrices' => [
'<string>'
],
'replacePrices' => [
[
'replacesPriceId' => '<string>',
'withPriceId' => '<string>'
]
]
]),
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.paygentic.io/v0/plans/{id}/versions"
payload := strings.NewReader("{\n \"addPrices\": [\n \"<string>\"\n ],\n \"removePrices\": [\n \"<string>\"\n ],\n \"replacePrices\": [\n {\n \"replacesPriceId\": \"<string>\",\n \"withPriceId\": \"<string>\"\n }\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://api.paygentic.io/v0/plans/{id}/versions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"addPrices\": [\n \"<string>\"\n ],\n \"removePrices\": [\n \"<string>\"\n ],\n \"replacePrices\": [\n {\n \"replacesPriceId\": \"<string>\",\n \"withPriceId\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paygentic.io/v0/plans/{id}/versions")
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 \"addPrices\": [\n \"<string>\"\n ],\n \"removePrices\": [\n \"<string>\"\n ],\n \"replacePrices\": [\n {\n \"replacesPriceId\": \"<string>\",\n \"withPriceId\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "plan_version",
"versionNumber": 2,
"status": "published",
"isDefault": true,
"subscriptionCount": 1,
"updatedAt": "2023-11-07T05:31:56Z",
"prices": [
{
"id": "<string>",
"object": "price",
"merchantId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"invoiceDisplayName": "<string>",
"model": "standard",
"paymentTerm": "in_arrears",
"properties": {},
"updatedAt": "2023-11-07T05:31:56Z",
"quantity": 1,
"priceDeleted": true,
"billableMetricId": "<string>",
"feeId": "<string>",
"billingCadence": "<string>",
"currency": "<string>",
"description": "<string>",
"unitAmount": "<string>",
"features": [
{
"id": "<string>",
"featureId": "<string>",
"entitlementTemplate": {},
"feature": {
"key": "<string>",
"name": "<string>",
"type": "metered"
}
}
],
"grantDiscountEnabled": false,
"isObligation": false
}
],
"publishedAt": "2023-11-07T05:31:56Z",
"basedOnVersionId": "<string>"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}Mint a plan version
Mint a new plan version from a price diff and make it the version the plan bills from, in one step. The diff references existing prices by id: create prices beforehand with POST /prices, then add, remove, or replace them here. To return to an earlier price set, make that version the default with a PATCH on the version.
curl --request POST \
--url https://api.paygentic.io/v0/plans/{id}/versions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"addPrices": [
"<string>"
],
"removePrices": [
"<string>"
],
"replacePrices": [
{
"replacesPriceId": "<string>",
"withPriceId": "<string>"
}
]
}
'import requests
url = "https://api.paygentic.io/v0/plans/{id}/versions"
payload = {
"addPrices": ["<string>"],
"removePrices": ["<string>"],
"replacePrices": [
{
"replacesPriceId": "<string>",
"withPriceId": "<string>"
}
]
}
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({
addPrices: ['<string>'],
removePrices: ['<string>'],
replacePrices: [{replacesPriceId: '<string>', withPriceId: '<string>'}]
})
};
fetch('https://api.paygentic.io/v0/plans/{id}/versions', 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.paygentic.io/v0/plans/{id}/versions",
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([
'addPrices' => [
'<string>'
],
'removePrices' => [
'<string>'
],
'replacePrices' => [
[
'replacesPriceId' => '<string>',
'withPriceId' => '<string>'
]
]
]),
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.paygentic.io/v0/plans/{id}/versions"
payload := strings.NewReader("{\n \"addPrices\": [\n \"<string>\"\n ],\n \"removePrices\": [\n \"<string>\"\n ],\n \"replacePrices\": [\n {\n \"replacesPriceId\": \"<string>\",\n \"withPriceId\": \"<string>\"\n }\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://api.paygentic.io/v0/plans/{id}/versions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"addPrices\": [\n \"<string>\"\n ],\n \"removePrices\": [\n \"<string>\"\n ],\n \"replacePrices\": [\n {\n \"replacesPriceId\": \"<string>\",\n \"withPriceId\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.paygentic.io/v0/plans/{id}/versions")
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 \"addPrices\": [\n \"<string>\"\n ],\n \"removePrices\": [\n \"<string>\"\n ],\n \"replacePrices\": [\n {\n \"replacesPriceId\": \"<string>\",\n \"withPriceId\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"object": "plan_version",
"versionNumber": 2,
"status": "published",
"isDefault": true,
"subscriptionCount": 1,
"updatedAt": "2023-11-07T05:31:56Z",
"prices": [
{
"id": "<string>",
"object": "price",
"merchantId": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"invoiceDisplayName": "<string>",
"model": "standard",
"paymentTerm": "in_arrears",
"properties": {},
"updatedAt": "2023-11-07T05:31:56Z",
"quantity": 1,
"priceDeleted": true,
"billableMetricId": "<string>",
"feeId": "<string>",
"billingCadence": "<string>",
"currency": "<string>",
"description": "<string>",
"unitAmount": "<string>",
"features": [
{
"id": "<string>",
"featureId": "<string>",
"entitlementTemplate": {},
"feature": {
"key": "<string>",
"name": "<string>",
"type": "metered"
}
}
],
"grantDiscountEnabled": false,
"isObligation": false
}
],
"publishedAt": "2023-11-07T05:31:56Z",
"basedOnVersionId": "<string>"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}{
"message": "The requested resource was not found",
"error": "not_found"
}Authorizations
API key authentication
Path Parameters
Unique identifier for a plan
^plan_[a-zA-Z0-9]+$Body
A reference-by-id price diff applied to the prices of the plan's current version. Every id references an existing price created via POST /prices; inline price definitions are not accepted. A mint must carry at least one price change, so an empty body is rejected. A version must carry at least one price, so a diff that would leave none is rejected.
Prices to add to the version. Each must not already be on the plan's current version.
Unique identifier for a price
^price_[a-zA-Z0-9]+$Prices to remove. Each must be on the plan's current version.
Unique identifier for a price
^price_[a-zA-Z0-9]+$Prices to swap in place, preserving the slot's lineage so the price keeps its identity where the plan is configured for stable price ids. replacesPriceId must be on the plan's current version; withPriceId is the new price.
Show child attributes
Show child attributes
Response
The newly minted version, published and now the plan's default
A single plan version, including its price slots. Extends the list summary with the version's prices.
Unique identifier for a plan version
^pver_[a-zA-Z0-9]+$plan_version Monotonic version number within the plan, starting at 1.
x >= 1Lifecycle status of the version.
published, archived Whether this version is the plan's current default (live) version.
Number of committed-status subscriptions pinned to this version at creation time. Not a live-billing cohort.
x >= 0When this version was last modified.
The price slots that make up this version.
Show child attributes
Show child attributes
When this version was published.
The version this one follows on from — the version that was live when this one was created, and whose prices it was built from. Absent for versions created before this field existed.
^pver_[a-zA-Z0-9]+$Was this page helpful?