Skip to main content
POST
/
v1
/
subscriptions
/
{id}
/
simulate-updates
Simulate subscription updates
curl --request POST \
  --url https://api.hyperline.co/v1/subscriptions/{id}/simulate-updates \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "updates": [
    {
      "type": "add_product",
      "payload": {
        "product_id": "<string>",
        "billing_interval_count": 123,
        "type": "fee",
        "product_name": "<string>",
        "product_description": "<string>",
        "count": 1,
        "display_interval_dates_in_description": true,
        "prices": [
          {
            "type": "fee",
            "amount": 123
          }
        ]
      }
    }
  ],
  "apply_at": "2024-12-20T16:04:11Z",
  "charge_at": "2024-12-20T16:04:11Z",
  "precision": "calendar_days"
}
'
import requests

url = "https://api.hyperline.co/v1/subscriptions/{id}/simulate-updates"

payload = {
"updates": [
{
"type": "add_product",
"payload": {
"product_id": "<string>",
"billing_interval_count": 123,
"type": "fee",
"product_name": "<string>",
"product_description": "<string>",
"count": 1,
"display_interval_dates_in_description": True,
"prices": [
{
"type": "fee",
"amount": 123
}
]
}
}
],
"apply_at": "2024-12-20T16:04:11Z",
"charge_at": "2024-12-20T16:04:11Z",
"precision": "calendar_days"
}
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({
updates: [
{
type: 'add_product',
payload: {
product_id: '<string>',
billing_interval_count: 123,
type: 'fee',
product_name: '<string>',
product_description: '<string>',
count: 1,
display_interval_dates_in_description: true,
prices: [{type: 'fee', amount: 123}]
}
}
],
apply_at: '2024-12-20T16:04:11Z',
charge_at: '2024-12-20T16:04:11Z',
precision: 'calendar_days'
})
};

fetch('https://api.hyperline.co/v1/subscriptions/{id}/simulate-updates', 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.hyperline.co/v1/subscriptions/{id}/simulate-updates",
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([
'updates' => [
[
'type' => 'add_product',
'payload' => [
'product_id' => '<string>',
'billing_interval_count' => 123,
'type' => 'fee',
'product_name' => '<string>',
'product_description' => '<string>',
'count' => 1,
'display_interval_dates_in_description' => true,
'prices' => [
[
'type' => 'fee',
'amount' => 123
]
]
]
]
],
'apply_at' => '2024-12-20T16:04:11Z',
'charge_at' => '2024-12-20T16:04:11Z',
'precision' => 'calendar_days'
]),
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.hyperline.co/v1/subscriptions/{id}/simulate-updates"

payload := strings.NewReader("{\n \"updates\": [\n {\n \"type\": \"add_product\",\n \"payload\": {\n \"product_id\": \"<string>\",\n \"billing_interval_count\": 123,\n \"type\": \"fee\",\n \"product_name\": \"<string>\",\n \"product_description\": \"<string>\",\n \"count\": 1,\n \"display_interval_dates_in_description\": true,\n \"prices\": [\n {\n \"type\": \"fee\",\n \"amount\": 123\n }\n ]\n }\n }\n ],\n \"apply_at\": \"2024-12-20T16:04:11Z\",\n \"charge_at\": \"2024-12-20T16:04:11Z\",\n \"precision\": \"calendar_days\"\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.hyperline.co/v1/subscriptions/{id}/simulate-updates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"updates\": [\n {\n \"type\": \"add_product\",\n \"payload\": {\n \"product_id\": \"<string>\",\n \"billing_interval_count\": 123,\n \"type\": \"fee\",\n \"product_name\": \"<string>\",\n \"product_description\": \"<string>\",\n \"count\": 1,\n \"display_interval_dates_in_description\": true,\n \"prices\": [\n {\n \"type\": \"fee\",\n \"amount\": 123\n }\n ]\n }\n }\n ],\n \"apply_at\": \"2024-12-20T16:04:11Z\",\n \"charge_at\": \"2024-12-20T16:04:11Z\",\n \"precision\": \"calendar_days\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.hyperline.co/v1/subscriptions/{id}/simulate-updates")

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 \"updates\": [\n {\n \"type\": \"add_product\",\n \"payload\": {\n \"product_id\": \"<string>\",\n \"billing_interval_count\": 123,\n \"type\": \"fee\",\n \"product_name\": \"<string>\",\n \"product_description\": \"<string>\",\n \"count\": 1,\n \"display_interval_dates_in_description\": true,\n \"prices\": [\n {\n \"type\": \"fee\",\n \"amount\": 123\n }\n ]\n }\n }\n ],\n \"apply_at\": \"2024-12-20T16:04:11Z\",\n \"charge_at\": \"2024-12-20T16:04:11Z\",\n \"precision\": \"calendar_days\"\n}"

response = http.request(request)
puts response.read_body
{
  "amount": 123
}
{
"message": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string
required

Body

application/json
application_schedule
enum<string>
required
Available options:
immediately,
scheduled
payment_schedule
enum<string>
required
Available options:
immediately,
next_invoice,
custom
calculation_method
enum<string>
required
Available options:
pro_rata,
pay_in_full,
do_not_charge
updates
(Add product · object | Remove product · object | Add coupon · object | Remove coupon · object | Update count · object | Update prices · object)[]
required

Add a new product to bill as part of the subscription.

apply_at
string<date-time>

The date when the update should be applied. Required when application_schedule is 'scheduled'.

Example:

"2024-12-20T16:04:11Z"

charge_at
string<date-time>

The date when the resulting subscription update should be charged. Required when payment_schedule is 'custom'. Must be in the future.

Example:

"2024-12-20T16:04:11Z"

precision
enum<string>

Granularity used to prorate the update amount. Defaults to 'calendar_days' when omitted, prorating on whole calendar days; 'milliseconds' prorates on the exact elapsed time, charging the precise partial period.

Available options:
calendar_days,
milliseconds
Example:

"calendar_days"

refund_method
enum<string>

Override the refund destination when the update generates a refund credit note (e.g. seat reduction). When omitted, falls back to the invoicing entity's creditNoteWalletRefundEnabled setting.

Available options:
wallet,
original_payment_method,
external

Response

Simulation results

amount
number
required