Purchase shared workspace AI capacity
Requires the donor_intelligence feature and route permissions. Every client_id route is restricted to the authenticated organization, including platform administrators using workspace routes. Stored profiles are filtered against current email-privacy state; obsolete privacy snapshots are concealed. Legacy wealth-insights URLs are equivalent aliases. Charges the organization saved payment card for the configured top-up and grants credits only after provider success. Reuse idempotency_key to avoid duplicate purchases; omitted keys create a fresh purchase. Disabled purchases, missing payment setup or insufficient billing success return402.
curl --request POST \
--url https://api.gratona.com/v1/admin/ai-capacity/top-ups \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"idempotency_key": "<string>"
}
'import requests
url = "https://api.gratona.com/v1/admin/ai-capacity/top-ups"
payload = { "idempotency_key": "<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({idempotency_key: '<string>'})
};
fetch('https://api.gratona.com/v1/admin/ai-capacity/top-ups', 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.gratona.com/v1/admin/ai-capacity/top-ups",
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([
'idempotency_key' => '<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.gratona.com/v1/admin/ai-capacity/top-ups"
payload := strings.NewReader("{\n \"idempotency_key\": \"<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.gratona.com/v1/admin/ai-capacity/top-ups")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"idempotency_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/ai-capacity/top-ups")
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 \"idempotency_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Saved successfully.",
"data": {
"ledger_entry": {
"id": 123,
"client_id": 123,
"user_id": 123,
"entry_type": "<string>",
"action_type": "<string>",
"credit_delta": 123,
"balance_after_credits": 123,
"amount_cents": 123,
"currency": "<string>",
"source_type": "<string>",
"source_id": "<string>",
"run_id": 123,
"expires_at": "2023-11-07T05:31:56Z",
"pricing_version": "<string>",
"idempotency_key": "<string>",
"stripe_payment_intent_id": "<string>",
"note": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"metadata_json": {}
},
"ai_capacity": {
"available_credits": 123,
"reserved_credits": 123,
"spent_credits": 123,
"included_plan_granted": 123,
"included_plan_remaining": 123,
"annual_pack_remaining": 123,
"top_up_remaining": 123,
"display_label": "<string>",
"paid_runs_disabled": true,
"expiring_soon": [
{
"credits": 123,
"expires_at": "2023-11-07T05:31:56Z",
"source_type": "<string>"
}
],
"top_up": {
"credits": 123,
"price_cents": 123,
"currency": "<string>"
},
"action_rates": {},
"recent_entries": [
{
"id": 123,
"client_id": 123,
"user_id": 123,
"entry_type": "<string>",
"action_type": "<string>",
"credit_delta": 123,
"balance_after_credits": 123,
"amount_cents": 123,
"currency": "<string>",
"source_type": "<string>",
"source_id": "<string>",
"run_id": 123,
"expires_at": "2023-11-07T05:31:56Z",
"pricing_version": "<string>",
"idempotency_key": "<string>",
"stripe_payment_intent_id": "<string>",
"note": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"metadata_json": {}
}
]
}
}
}{
"message": "Unauthorized",
"status": "error"
}{
"status": "error",
"message": "<string>",
"code": "<string>",
"errors": {}
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}{
"status": "error",
"message": "<string>",
"code": "<string>",
"errors": {}
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}Authorizations
Passport bearer token authentication for legacy admin sessions.
Body
Request fields accepted by this operation. Omitted optional properties retain the behavior described above.
Validation: nullable|string|max:255.
255curl --request POST \
--url https://api.gratona.com/v1/admin/ai-capacity/top-ups \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"idempotency_key": "<string>"
}
'import requests
url = "https://api.gratona.com/v1/admin/ai-capacity/top-ups"
payload = { "idempotency_key": "<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({idempotency_key: '<string>'})
};
fetch('https://api.gratona.com/v1/admin/ai-capacity/top-ups', 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.gratona.com/v1/admin/ai-capacity/top-ups",
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([
'idempotency_key' => '<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.gratona.com/v1/admin/ai-capacity/top-ups"
payload := strings.NewReader("{\n \"idempotency_key\": \"<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.gratona.com/v1/admin/ai-capacity/top-ups")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"idempotency_key\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/ai-capacity/top-ups")
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 \"idempotency_key\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Saved successfully.",
"data": {
"ledger_entry": {
"id": 123,
"client_id": 123,
"user_id": 123,
"entry_type": "<string>",
"action_type": "<string>",
"credit_delta": 123,
"balance_after_credits": 123,
"amount_cents": 123,
"currency": "<string>",
"source_type": "<string>",
"source_id": "<string>",
"run_id": 123,
"expires_at": "2023-11-07T05:31:56Z",
"pricing_version": "<string>",
"idempotency_key": "<string>",
"stripe_payment_intent_id": "<string>",
"note": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"metadata_json": {}
},
"ai_capacity": {
"available_credits": 123,
"reserved_credits": 123,
"spent_credits": 123,
"included_plan_granted": 123,
"included_plan_remaining": 123,
"annual_pack_remaining": 123,
"top_up_remaining": 123,
"display_label": "<string>",
"paid_runs_disabled": true,
"expiring_soon": [
{
"credits": 123,
"expires_at": "2023-11-07T05:31:56Z",
"source_type": "<string>"
}
],
"top_up": {
"credits": 123,
"price_cents": 123,
"currency": "<string>"
},
"action_rates": {},
"recent_entries": [
{
"id": 123,
"client_id": 123,
"user_id": 123,
"entry_type": "<string>",
"action_type": "<string>",
"credit_delta": 123,
"balance_after_credits": 123,
"amount_cents": 123,
"currency": "<string>",
"source_type": "<string>",
"source_id": "<string>",
"run_id": 123,
"expires_at": "2023-11-07T05:31:56Z",
"pricing_version": "<string>",
"idempotency_key": "<string>",
"stripe_payment_intent_id": "<string>",
"note": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"metadata_json": {}
}
]
}
}
}{
"message": "Unauthorized",
"status": "error"
}{
"status": "error",
"message": "<string>",
"code": "<string>",
"errors": {}
}{
"message": "Something went wrong. Please try again.",
"status": "error",
"error": "invalid_request",
"code": "DONOR_NOT_FOUND"
}{
"status": "error",
"message": "<string>",
"code": "<string>",
"errors": {}
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}