curl --request POST \
--url https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"billing_cadence": "RECURRING",
"target_plan_id": "<string>",
"billing_period_count": 123,
"metadata": {}
}
'import requests
url = "https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview"
payload = {
"billing_cadence": "RECURRING",
"target_plan_id": "<string>",
"billing_period_count": 123,
"metadata": {}
}
headers = {
"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-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billing_cadence: 'RECURRING',
target_plan_id: '<string>',
billing_period_count: 123,
metadata: {}
})
};
fetch('https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview', 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://us.api.flexprice.io/v1/subscriptions/{id}/change/preview",
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([
'billing_cadence' => 'RECURRING',
'target_plan_id' => '<string>',
'billing_period_count' => 123,
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-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://us.api.flexprice.io/v1/subscriptions/{id}/change/preview"
payload := strings.NewReader("{\n \"billing_cadence\": \"RECURRING\",\n \"target_plan_id\": \"<string>\",\n \"billing_period_count\": 123,\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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("https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"billing_cadence\": \"RECURRING\",\n \"target_plan_id\": \"<string>\",\n \"billing_period_count\": 123,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"billing_cadence\": \"RECURRING\",\n \"target_plan_id\": \"<string>\",\n \"billing_period_count\": 123,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"change_type": "upgrade",
"current_plan": {
"description": "<string>",
"id": "<string>",
"lookup_key": "<string>",
"name": "<string>"
},
"effective_date": "2023-11-07T05:31:56Z",
"metadata": {},
"new_billing_cycle": {
"billing_anchor": "2023-11-07T05:31:56Z",
"billing_cadence": "RECURRING",
"billing_period": "MONTHLY",
"billing_period_count": 123,
"period_end": "2023-11-07T05:31:56Z",
"period_start": "2023-11-07T05:31:56Z"
},
"next_invoice_preview": {
"currency": "<string>",
"due_date": "2023-11-07T05:31:56Z",
"line_items": [
{
"amount": "<string>",
"description": "<string>",
"is_proration": true,
"period_end": "2023-11-07T05:31:56Z",
"period_start": "2023-11-07T05:31:56Z",
"quantity": "<string>",
"unit_price": "<string>"
}
],
"subtotal": "<string>",
"tax_amount": "<string>",
"total": "<string>"
},
"proration_details": {
"charge_amount": "<string>",
"charge_description": "<string>",
"credit_amount": "<string>",
"credit_description": "<string>",
"currency": "<string>",
"current_period_end": "2023-11-07T05:31:56Z",
"current_period_start": "2023-11-07T05:31:56Z",
"days_remaining": 123,
"days_used": 123,
"net_amount": "<string>",
"proration_date": "2023-11-07T05:31:56Z"
},
"subscription_id": "<string>",
"target_plan": {
"description": "<string>",
"id": "<string>",
"lookup_key": "<string>",
"name": "<string>"
},
"warnings": [
"<string>"
]
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Preview subscription plan change
Use when showing a customer the cost of a plan change before they confirm (e.g. upgrade/downgrade preview with proration).
curl --request POST \
--url https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"billing_cadence": "RECURRING",
"target_plan_id": "<string>",
"billing_period_count": 123,
"metadata": {}
}
'import requests
url = "https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview"
payload = {
"billing_cadence": "RECURRING",
"target_plan_id": "<string>",
"billing_period_count": 123,
"metadata": {}
}
headers = {
"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-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billing_cadence: 'RECURRING',
target_plan_id: '<string>',
billing_period_count: 123,
metadata: {}
})
};
fetch('https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview', 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://us.api.flexprice.io/v1/subscriptions/{id}/change/preview",
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([
'billing_cadence' => 'RECURRING',
'target_plan_id' => '<string>',
'billing_period_count' => 123,
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-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://us.api.flexprice.io/v1/subscriptions/{id}/change/preview"
payload := strings.NewReader("{\n \"billing_cadence\": \"RECURRING\",\n \"target_plan_id\": \"<string>\",\n \"billing_period_count\": 123,\n \"metadata\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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("https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"billing_cadence\": \"RECURRING\",\n \"target_plan_id\": \"<string>\",\n \"billing_period_count\": 123,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://us.api.flexprice.io/v1/subscriptions/{id}/change/preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"billing_cadence\": \"RECURRING\",\n \"target_plan_id\": \"<string>\",\n \"billing_period_count\": 123,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"change_type": "upgrade",
"current_plan": {
"description": "<string>",
"id": "<string>",
"lookup_key": "<string>",
"name": "<string>"
},
"effective_date": "2023-11-07T05:31:56Z",
"metadata": {},
"new_billing_cycle": {
"billing_anchor": "2023-11-07T05:31:56Z",
"billing_cadence": "RECURRING",
"billing_period": "MONTHLY",
"billing_period_count": 123,
"period_end": "2023-11-07T05:31:56Z",
"period_start": "2023-11-07T05:31:56Z"
},
"next_invoice_preview": {
"currency": "<string>",
"due_date": "2023-11-07T05:31:56Z",
"line_items": [
{
"amount": "<string>",
"description": "<string>",
"is_proration": true,
"period_end": "2023-11-07T05:31:56Z",
"period_start": "2023-11-07T05:31:56Z",
"quantity": "<string>",
"unit_price": "<string>"
}
],
"subtotal": "<string>",
"tax_amount": "<string>",
"total": "<string>"
},
"proration_details": {
"charge_amount": "<string>",
"charge_description": "<string>",
"credit_amount": "<string>",
"credit_description": "<string>",
"currency": "<string>",
"current_period_end": "2023-11-07T05:31:56Z",
"current_period_start": "2023-11-07T05:31:56Z",
"days_remaining": 123,
"days_used": 123,
"net_amount": "<string>",
"proration_date": "2023-11-07T05:31:56Z"
},
"subscription_id": "<string>",
"target_plan": {
"description": "<string>",
"id": "<string>",
"lookup_key": "<string>",
"name": "<string>"
},
"warnings": [
"<string>"
]
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}{
"code": "http_client_error",
"http_status_code": 123,
"message": "<string>"
}Authorizations
Enter your API key in the format x-api-key <api-key>*
Path Parameters
Subscription ID
Body
Subscription change preview request
Request object for changing a subscription plan (upgrade/downgrade)
RECURRING anniversary, calendar MONTHLY, ANNUAL, WEEKLY, DAILY, QUARTERLY, HALF_YEARLY, ONETIME create_prorations, none target_plan_id is the ID of the new plan to change to (required)
billing_period_count is the billing period count for the new subscription
immediate, end_of_period metadata contains additional key-value pairs for storing extra information
Show child attributes
Show child attributes
Response
OK
Response showing the financial impact of a subscription plan change
upgrade, downgrade, lateral Show child attributes
Show child attributes
effective_date is when the change would take effect
metadata from the request
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
subscription_id is the ID of the subscription being changed
Show child attributes
Show child attributes
warnings contains any warnings about the change

