Skip to main content
POST
/
workspaces
/
{workspaceId}
/
billing-accounts
/
{billingAccountId}
/
subscriptions
Create a subscription
curl --request POST \
  --url https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "product_quantities": {
    "locations": 5,
    "users": 25
  },
  "metadata": {
    "project_id": "proj_abc123"
  }
}
'
import requests

url = "https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions"

payload = {
"product_quantities": {
"locations": 5,
"users": 25
},
"metadata": { "project_id": "proj_abc123" }
}
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({
product_quantities: {locations: 5, users: 25},
metadata: {project_id: 'proj_abc123'}
})
};

fetch('https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions', 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://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions",
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([
'product_quantities' => [
'locations' => 5,
'users' => 25
],
'metadata' => [
'project_id' => 'proj_abc123'
]
]),
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://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions"

payload := strings.NewReader("{\n \"product_quantities\": {\n \"locations\": 5,\n \"users\": 25\n },\n \"metadata\": {\n \"project_id\": \"proj_abc123\"\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://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"product_quantities\": {\n \"locations\": 5,\n \"users\": 25\n },\n \"metadata\": {\n \"project_id\": \"proj_abc123\"\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://v1.api.altostrat.io/workspaces/{workspaceId}/billing-accounts/{billingAccountId}/subscriptions")

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 \"product_quantities\": {\n \"locations\": 5,\n \"users\": 25\n },\n \"metadata\": {\n \"project_id\": \"proj_abc123\"\n }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "sub_a1b2c3d4e5f6g7h8",
  "billing_account_id": "cus_a1b2c3d4e5f6g7h8",
  "status": "active",
  "currency": "usd",
  "product_quantities": {
    "locations": {
      "price_id": "price_123abc",
      "quantity": 10,
      "interval": "month"
    },
    "users": {
      "price_id": "price_456def",
      "quantity": 50,
      "interval": "month"
    }
  },
  "metadata": {
    "order_id": "6735"
  },
  "current_period_start": "2025-10-15T00:00:00Z",
  "current_period_end": "2025-11-15T00:00:00Z",
  "created_at": "2025-10-15T12:30:00Z",
  "updated_at": "2025-10-20T09:00:00Z"
}
{
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "The 'name' parameter cannot exceed 50 characters.",
"doc_url": "https://docs.altostrat.io/errors/parameter_invalid"
}
{
"type": "unprocessable_entity",
"code": "payment_method_required",
"message": "A default payment method is required to create a subscription. This workspace is not eligible for a trial.",
"doc_url": "https://docs.altostrat.io/errors/payment_method_required"
}
{
"type": "api_error",
"code": "internal_server_error",
"message": "An internal server error occurred. Please try again later.",
"doc_url": "https://docs.altostrat.io/errors/internal_server_error"
}

Authorizations

Authorization
string
header
required

Enter your JWT in the format: Bearer {token}

Path Parameters

workspaceId
string
required

The ID of the workspace.

Example:

"ws_a1b2c3d4e5f6g7h8"

billingAccountId
string
required

The ID of the billing account, which corresponds to a Stripe Customer ID (cus_...).

Example:

"cus_a1b2c3d4e5f6g7h8"

Body

application/json
product_quantities
object
required

A map of meterable product types (locations, users, sso) to the desired quantity. At least one product is required.

Example:
{ "locations": 5, "users": 25 }
metadata
object

A set of up to 10 key-value pairs to store with the subscription.

Example:
{ "project_id": "proj_abc123" }

Response

The subscription was created successfully.

id
string

Unique identifier for the subscription (Stripe Subscription ID), prefixed with sub_.

Example:

"sub_a1b2c3d4e5f6g7h8"

billing_account_id
string

The ID of the billing account this subscription belongs to.

Example:

"cus_a1b2c3d4e5f6g7h8"

status
enum<string>

The status of the subscription.

Available options:
active,
past_due,
unpaid,
canceled,
incomplete,
incomplete_expired,
trialing,
paused
Example:

"active"

currency
enum<string>

The three-letter ISO currency code for the subscription.

Available options:
usd,
zar,
eur,
gbp,
aud
Example:

"usd"

product_quantities
object

A map of meterable product types to their subscribed quantities and pricing details.

Example:
{
"locations": {
"price_id": "price_123abc",
"quantity": 10,
"interval": "month"
},
"users": {
"price_id": "price_456def",
"quantity": 50,
"interval": "month"
}
}
metadata
object

A set of key-value pairs that you can attach to an object.

Example:
{ "order_id": "6735" }
current_period_start
string<date-time> | null

The start of the current billing period.

Example:

"2025-10-15T00:00:00Z"

current_period_end
string<date-time> | null

The end of the current billing period.

Example:

"2025-11-15T00:00:00Z"

created_at
string<date-time> | null

The timestamp when the subscription was created.

Example:

"2025-10-15T12:30:00Z"

updated_at
string<date-time> | null

The timestamp when the subscription was last updated in our system.

Example:

"2025-10-20T09:00:00Z"