Your first check with the REST API
Works from any language that can make an HTTPS request. About 5 minutes. The examples use curl.
Sealgraf never moves money. Your agent pays through its own payment method; Sealgraf answers whether it may, and seals a receipt of the purchase your agent reports.
Before you start
You need a free Sealgraf account with spending limits. Create a free account if you don't have one.
1. Get a key
Get a REST API key. It is shown once. Keep it on your server, never in a browser or a mobile app.
export SEALGRAF_KEY="see_..."
2. See what your key may spend on
curl https://sealgraf.com/v1/whoami \
-H "X-API-Key: $SEALGRAF_KEY"
The answer describes the limits this key works under:
{
"slip": {
"categories": [{ "id": "groceries", "label": "Groceries" },
{ "id": "household", "label": "Household" }],
"currency": "USD",
"limits": { "human_approval_threshold_minor": 5000,
"per_purchase_cap_minor": 10000 }
}
}
Use one of these category ids in step 3. Amounts are in cents: 5000 is $50.00.
3. Ask before you buy
curl -X POST https://sealgraf.com/v1/preauthorize \
-H "X-API-Key: $SEALGRAF_KEY" -H "Content-Type: application/json" \
-d '{"action": {"category": "groceries", "amount_minor": 1250,
"counterparty": "Example Grocer", "description": "Coffee beans"}}'
{
"preauth_id": "pa_...",
"decision": { "outcome": "allow", "reason_code": "ok" },
"decision_token": "...",
"token_expires_at": "...15 minutes from now..."
}
For your first check, use an amount below your ask-first limit so it is allowed straight away.
decision.outcome | What your agent does |
|---|---|
allow | Buy it (step 4), then report it (step 5) within 15 minutes. |
needs_human_approval | Don't buy yet. Wait for your OK (see below). |
deny | Don't buy. reason_code says which limit refused it. |
4. Buy it your usual way
Pay through your own checkout or card. Sealgraf takes no part in the payment.
5. Report the purchase
curl -X POST https://sealgraf.com/v1/preauthorize/pa_.../complete \
-H "X-API-Key: $SEALGRAF_KEY" -H "Content-Type: application/json" \
-d '{"decision_token": "...", "completion_nonce": "order-1001",
"evidence": {"completed_amount_minor": 1250,
"counterparty_receipt_ref": "ORDER-1001",
"note": "Coffee beans"}}'
The answer is the sealed receipt, with its receipt_id. Report only a purchase that happened. The amount can be less than you checked, never more. Sending the same completion_nonce again returns the same receipt.
6. Read the receipt
curl https://sealgraf.com/v1/receipts/rcpt_... \
-H "X-API-Key: $SEALGRAF_KEY"
The purchase also appears in your Activity. Anyone you share the proof with can check it on Check a receipt, no account needed.
When a purchase needs your OK
If the check answers needs_human_approval, your agent doesn't buy yet. You approve or decline it in Sealgraf, on the web or your phone, within 24 hours.
Wait for your answer. Your agent asks for the check every 30 seconds or so until its state is authorized. If it is aborted or expired, it doesn't buy.
curl https://sealgraf.com/v1/preauthorize/pa_... \
-H "X-API-Key: $SEALGRAF_KEY"
Claim the token. Once you have approved, your agent claims its token, then buys and reports it (steps 4 and 5) within 15 minutes.
curl -X POST https://sealgraf.com/v1/preauthorize/pa_.../decision-token \
-H "X-API-Key: $SEALGRAF_KEY"
Claiming before you have approved answers 409 not_approved_yet. Only the key that ran the check can claim it.
Next
The full REST reference lists every endpoint, and errors and what to do with them. Building in Python? The LangChain walkthrough does the same steps with ready-made tools.