Purchase or resume a Postal Mail balance pack
Charges the organization saved billing method for a configured pack and returns its successful ledger entry. Requires raw access_payment_gateways and complete funding readiness. Reuse idempotency_key, or pending_purchase_reference from credits, to resume an existing attempt; pending/manual-review/terminal payment outcomes return 422 rather than a successful top-up. Requires the configured Handwrytten feature (normally handwrytten_mailings). Requires permission: access_payment_gateways (raw capability).
curl --request POST \
--url https://api.gratona.com/v1/admin/handwrytten/credits/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pack_key": "postal-mail-50",
"idempotency_key": "Idempotency Key",
"pending_purchase_reference": "Pending Purchase Reference"
}
'import requests
url = "https://api.gratona.com/v1/admin/handwrytten/credits/purchase"
payload = {
"pack_key": "postal-mail-50",
"idempotency_key": "Idempotency Key",
"pending_purchase_reference": "Pending Purchase Reference"
}
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({
pack_key: 'postal-mail-50',
idempotency_key: 'Idempotency Key',
pending_purchase_reference: 'Pending Purchase Reference'
})
};
fetch('https://api.gratona.com/v1/admin/handwrytten/credits/purchase', 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/handwrytten/credits/purchase",
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([
'pack_key' => 'postal-mail-50',
'idempotency_key' => 'Idempotency Key',
'pending_purchase_reference' => 'Pending Purchase Reference'
]),
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/handwrytten/credits/purchase"
payload := strings.NewReader("{\n \"pack_key\": \"postal-mail-50\",\n \"idempotency_key\": \"Idempotency Key\",\n \"pending_purchase_reference\": \"Pending Purchase Reference\"\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/handwrytten/credits/purchase")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"pack_key\": \"postal-mail-50\",\n \"idempotency_key\": \"Idempotency Key\",\n \"pending_purchase_reference\": \"Pending Purchase Reference\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/handwrytten/credits/purchase")
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 \"pack_key\": \"postal-mail-50\",\n \"idempotency_key\": \"Idempotency Key\",\n \"pending_purchase_reference\": \"Pending Purchase Reference\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 100,
"credit_delta": 100,
"balance_delta_cents": 100,
"balance_after_cents": 100,
"balance_after_credits": 100,
"amount_cents": 100,
"entry_type": "Example",
"currency": "usd",
"created_at": "2026-10-20T12:00:00Z"
}
}{
"message": "Unauthorized",
"status": "error"
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}Authorizations
Passport bearer token authentication for legacy admin sessions.
Body
Validated request fields for this operation.
A key returned by credits.available_packs; availability depends on configured billing packs.
"postal-mail-50"
Idempotency key. Validation: nullable, string, max:191.
191"Idempotency Key"
Opaque attempt_reference from credits.pending_balance_purchase; resumes that organization-owned pack purchase.
2048"Pending Purchase Reference"
Response
Operation result.
Show child attributes
Show child attributes
curl --request POST \
--url https://api.gratona.com/v1/admin/handwrytten/credits/purchase \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"pack_key": "postal-mail-50",
"idempotency_key": "Idempotency Key",
"pending_purchase_reference": "Pending Purchase Reference"
}
'import requests
url = "https://api.gratona.com/v1/admin/handwrytten/credits/purchase"
payload = {
"pack_key": "postal-mail-50",
"idempotency_key": "Idempotency Key",
"pending_purchase_reference": "Pending Purchase Reference"
}
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({
pack_key: 'postal-mail-50',
idempotency_key: 'Idempotency Key',
pending_purchase_reference: 'Pending Purchase Reference'
})
};
fetch('https://api.gratona.com/v1/admin/handwrytten/credits/purchase', 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/handwrytten/credits/purchase",
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([
'pack_key' => 'postal-mail-50',
'idempotency_key' => 'Idempotency Key',
'pending_purchase_reference' => 'Pending Purchase Reference'
]),
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/handwrytten/credits/purchase"
payload := strings.NewReader("{\n \"pack_key\": \"postal-mail-50\",\n \"idempotency_key\": \"Idempotency Key\",\n \"pending_purchase_reference\": \"Pending Purchase Reference\"\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/handwrytten/credits/purchase")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"pack_key\": \"postal-mail-50\",\n \"idempotency_key\": \"Idempotency Key\",\n \"pending_purchase_reference\": \"Pending Purchase Reference\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gratona.com/v1/admin/handwrytten/credits/purchase")
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 \"pack_key\": \"postal-mail-50\",\n \"idempotency_key\": \"Idempotency Key\",\n \"pending_purchase_reference\": \"Pending Purchase Reference\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 100,
"credit_delta": 100,
"balance_delta_cents": 100,
"balance_after_cents": 100,
"balance_after_credits": 100,
"amount_cents": 100,
"entry_type": "Example",
"currency": "usd",
"created_at": "2026-10-20T12:00:00Z"
}
}{
"message": "Unauthorized",
"status": "error"
}{
"errors": {},
"status": "error",
"message": "The given data was invalid."
}