Upgrade to pay as you go
curl --request POST \
--url https://api.twinbay.ai/organizations/current/billing/upgrade \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_session": "<string>"
}
'import requests
url = "https://api.twinbay.ai/organizations/current/billing/upgrade"
payload = { "checkout_session": "<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_session: '<string>'})
};
fetch('https://api.twinbay.ai/organizations/current/billing/upgrade', 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.twinbay.ai/organizations/current/billing/upgrade",
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_session' => '<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.twinbay.ai/organizations/current/billing/upgrade"
payload := strings.NewReader("{\n \"checkout_session\": \"<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.twinbay.ai/organizations/current/billing/upgrade")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_session\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.twinbay.ai/organizations/current/billing/upgrade")
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_session\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"plan": "free",
"max_environment_seconds": 123,
"max_parallel_twins": 123,
"ai_generation_enabled": true,
"active_twins": 123,
"ready": true,
"upgrade_available": true,
"remaining_credit_cents": 123,
"invoice": {
"period_start": "2023-11-07T05:31:56Z",
"period_end": "2023-11-07T05:31:56Z",
"total_cents": 123,
"line_items": [
{
"name": "<string>",
"total_cents": 123,
"twin": "<string>",
"quantity": 123,
"unit_price_cents": 123
}
],
"credits_applied_cents": 0
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}billing
Upgrade to pay as you go
Finishes a checkout: its card becomes the default, and the organization moves to pay as you go. Limits lift at once; charges start at the next hour. Requires the admin role.
POST
/
organizations
/
current
/
billing
/
upgrade
Upgrade to pay as you go
curl --request POST \
--url https://api.twinbay.ai/organizations/current/billing/upgrade \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"checkout_session": "<string>"
}
'import requests
url = "https://api.twinbay.ai/organizations/current/billing/upgrade"
payload = { "checkout_session": "<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_session: '<string>'})
};
fetch('https://api.twinbay.ai/organizations/current/billing/upgrade', 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.twinbay.ai/organizations/current/billing/upgrade",
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_session' => '<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.twinbay.ai/organizations/current/billing/upgrade"
payload := strings.NewReader("{\n \"checkout_session\": \"<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.twinbay.ai/organizations/current/billing/upgrade")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"checkout_session\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.twinbay.ai/organizations/current/billing/upgrade")
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_session\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"plan": "free",
"max_environment_seconds": 123,
"max_parallel_twins": 123,
"ai_generation_enabled": true,
"active_twins": 123,
"ready": true,
"upgrade_available": true,
"remaining_credit_cents": 123,
"invoice": {
"period_start": "2023-11-07T05:31:56Z",
"period_end": "2023-11-07T05:31:56Z",
"total_cents": 123,
"line_items": [
{
"name": "<string>",
"total_cents": 123,
"twin": "<string>",
"quantity": 123,
"unit_price_cents": 123
}
],
"credits_applied_cents": 0
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Access tokenOrganization API key
Body
application/json
Response
Successful Response