Create billing checkout session
curl --request POST \
--url https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_type": "subscription",
"return_path": "<string>"
}
'import requests
url = "https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions"
payload = {
"checkout_type": "subscription",
"return_path": "<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({checkout_type: 'subscription', return_path: '<string>'})
};
fetch('https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions', 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.runaether.dev/orgs/{orgID}/billing/checkout-sessions",
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([
'checkout_type' => 'subscription',
'return_path' => '<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.runaether.dev/orgs/{orgID}/billing/checkout-sessions"
payload := strings.NewReader("{\n \"checkout_type\": \"subscription\",\n \"return_path\": \"<string>\"\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.runaether.dev/orgs/{orgID}/billing/checkout-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_type\": \"subscription\",\n \"return_path\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions")
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 \"checkout_type\": \"subscription\",\n \"return_path\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"checkout_session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"checkout_session_token": "<string>",
"checkout_type": "subscription",
"status": "created",
"subscription_status": "active",
"target_tier": "starter",
"claimed_store_purchase": true,
"store_app_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"store_product_id": "<string>",
"url": "<string>"
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}Billing
Create billing checkout session
Opens a checkout for a subscription, a credit pack or an Aether inference top-up: a Stripe hosted checkout on the web, a store purchase intent on ios and android.
Use this tool when you need to:
- Subscribe the org to a paid tier
- Buy a credit pack or top up the org's Aether inference balance
- Get the store product and store identity a device buys with on ios or android
Examples:
- POST /orgs/{orgID}/billing/checkout-sessions {"checkout_type": "subscription", "surface": "web", "tier": "pro", "return_path": "/settings/billing"}
- POST /orgs/{orgID}/billing/checkout-sessions {"checkout_type": "inference_topup", "surface": "ios", "amount_usd": 25}
Hints:
- orgID is the org's uuid. checkout_type picks the body: subscription takes tier (starter, pro, max or team), credit_pack takes credit_pack_id (credits_100, credits_250, credits_500 or credits_1000), inference_topup takes amount_usd (5 to 5000). surface is required in each; return_path, a local path of at most 500 characters such as /settings/billing, is required on the web and refused on ios and android.
- In a JSON object body, a missing surface or one other than web, ios or android is refused with 400 invalid_surface before the schema runs; the schema then answers 422 for any other field out of shape or unknown. The handler answers 400 for a return_path sent from ios or android or missing on the web, the team tier on ios or android (sold on the web only), an amount_usd that is not whole cents, and a store top-up amount other than 5, 10, 25 or 50 (getBillingCatalog's top_up_skus).
- Answers 201 with the BillingCheckoutSession, status created: on the web its url is the Stripe hosted checkout to open; on ios and android it carries store_product_id and store_app_user_id for the device to buy with, and the device then binds its transaction with bindBillingCheckoutSessionTransaction. A team org's subscription is priced per seat, one per entry of plan.seats; a store top-up adds no fee.
- A new checkout expires the org's open one for the same purchase (any open subscription checkout, or the same credit pack or top-up on the same channel); one already settling (paid, bound to a store transaction, or still being created at Stripe) is refused with 409.
- Refused with 422 team_org_requires_team_plan or personal_org_requires_personal_plan for a tier the org's kind cannot buy; 409 with the reason as code when getBillingSubscription's matching action is unavailable on that surface (subscription_active, subscription_pending, checkout_pending, managed_elsewhere or provider_unavailable for a subscription; payment_delinquent, enterprise_invoice or provider_unavailable for a credit pack or top-up); 409 when the caller's profile has no email for the org's first Stripe customer; 404 for an org without billing; and 502 when Stripe fails.
- Use getBillingCheckoutSession instead to follow the checkout, createBillingPortalSession to change or manage an existing Stripe subscription, getBillingCatalog for tiers and top-up amounts, and listBillingCreditPacks for packs.
- Owners, admins and billing members only, with a session or a platform API key: a member or viewer is refused with 403 org_role_insufficient before the body is read, a non-member with 403 org_membership_required, an orgID that is not a uuid with 400, and an agent host's grant with 403 agent_host_route_not_allowed.
POST
/
orgs
/
{orgID}
/
billing
/
checkout-sessions
Create billing checkout session
curl --request POST \
--url https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_type": "subscription",
"return_path": "<string>"
}
'import requests
url = "https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions"
payload = {
"checkout_type": "subscription",
"return_path": "<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({checkout_type: 'subscription', return_path: '<string>'})
};
fetch('https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions', 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.runaether.dev/orgs/{orgID}/billing/checkout-sessions",
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([
'checkout_type' => 'subscription',
'return_path' => '<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.runaether.dev/orgs/{orgID}/billing/checkout-sessions"
payload := strings.NewReader("{\n \"checkout_type\": \"subscription\",\n \"return_path\": \"<string>\"\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.runaether.dev/orgs/{orgID}/billing/checkout-sessions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_type\": \"subscription\",\n \"return_path\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.runaether.dev/orgs/{orgID}/billing/checkout-sessions")
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 \"checkout_type\": \"subscription\",\n \"return_path\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"checkout_session_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"checkout_session_token": "<string>",
"checkout_type": "subscription",
"status": "created",
"subscription_status": "active",
"target_tier": "starter",
"claimed_store_purchase": true,
"store_app_user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"store_product_id": "<string>",
"url": "<string>"
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}{
"code": "bad_gateway",
"error": "<string>",
"errors": [
{
"location": "<string>",
"message": "<string>",
"value": "<unknown>"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
Body
application/json
- Option 1
- Option 2
- Option 3
Available options:
subscription The client purchasing: web opens a Stripe hosted checkout; ios and android create a store purchase intent.
Available options:
web, ios, android Available options:
starter, pro, max, team Where the hosted checkout returns. Required on the web; refused on ios and android.
Maximum string length:
500Pattern:
^/(?:(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)/)*(?:\.{3,}[!-"$&-.0->A-\[\]-~]*|\.{0,2}[!-"$&--0->A-\[\]-~][!-"$&-.0->A-\[\]-~]*)?$Response
Created
- Option 1
- Option 2
- Option 3
Pattern:
^pcs_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$Available options:
subscription Available options:
created, completed, expired, failed Available options:
active, failed, pending, pending_webhook Available options:
starter, pro, max, team Present and true when binding the store transaction claimed the purchase the store had already reported: the intent completed and granted from it.
The store identity the device buys as. Present only when a store purchase intent is created.
The store product the device buys. Present only when a store purchase intent is created.
The Stripe hosted checkout to open. Absent for a store purchase intent.