One call per action
Counted outside the company that ran it.
- Get your key, once (below).
- Where your AI has finished an action, one call:
POST /v1/count. Your AI writes it in its own language from the form below.
Your evidence is the month’s invoice, from Stripe: each day’s count, and STK’s signature on each line. You keep nothing else.
The count on the invoice can be lower than the actions counted. On a day STK stopped or was replaced, you are billed the smaller number. You are never billed more.
POST /v1/count
POST https://api.stk-evidence.com/v1/count
X-STK-Key: <key>
{}
→ stk1.<seal>.<time_ms>.<account>.<kid>.<sig>
The body is {}, or {"seal": …}. Seal: sha256(<a string only the two sides know> + <the id of that one action>), 64 hex, the string in STK_SALT; the same seal again within 48 hours is not counted twice. Do not send this string to STK: STK is stronger not knowing it. Make it once, with: openssl rand -hex 32. Keep it. Do not send it to STK. A seal points to one finished action, not to its container (a conversation or a job): two actions finished in one container, two ids. With a random seal, the receipts are only in one company’s hands. With the same seal on both sides, the two sets of receipts side by side show any action only one side has.
What STK does not do
STK does not watch your AI. It counts what you send, when you send it, and signs it.
It cannot know about actions you do not send. A count you never make does not exist, and it will not show up on your bill.
Inside a vendor's product, what is counted is what the vendor reported.
What STK receives
Your key, and a seal: yours, or one STK makes. Nothing of the conversation, the customer or your records. The same seal is not counted again for 48 hours. But if STK restarts, it does not remember them.
What STK returns
200, one line, text/plain: stk1.<seal>.<time_ms>.<account>.<kid>.<sig>. time_ms: when STK signed, ms since 1970 (UTC). account: your account at STK. kid: the key that signed, in keys.json. sig: Ed25519, base64, over the line before its last dot, as it is. No value holds a dot. The same seal again within 48 hours (today or yesterday, UTC) gets the same line back and is not counted again.
Save each line that comes back. Your count is the number of different lines.
Billed: each seal counted for your key, $0.30. A call with no key or a wrong key gets 401 and is not billed.
Errors
Every error is {"error": <its number>, "message": "<one sentence>"} and nothing else. Nothing in an error is counted or billed.
| 402 | POST /v1/count: STK signs nothing for your account. Your bank refused a debit for good, or refused the debits of two months in a row for want of money, or no bank account is registered. The message says what to do next. |
| 429 | A key of STK's has no rate limit. More than 120 calls a minute from one address with a key that is not one of STK's; or, for POST /v1/keys, more than 3 bank pages an hour from one address, or 300 from all addresses together. |
| 409 | POST /v1/keys: that bank page is not done, or gave its key already, or its email address has an account and the bank account is another one. |
| 503 | STK cannot sign or read its records just now, with Retry-After: 60: no published signing key for today, a server starting, or the day full: 46,930,325 seals, of all accounts, and then only the account with the most of them is refused, the others getting 3,355,443 more. Send the same seal again later. |
| 401 | No X-STK-Key, or not a key, or a key stopped. The message gives the way to a key. |
| 422 | A field the call does not take, or a seal not of its form. |
| 413 | A body over 16,384 bytes. |
| 500 | A fault in STK. Send the same seal again later. |
Check a receipt
In three steps: Verify. The key files: Keys.
Cut the line at its last dot and check the Ed25519 signature over the left part with the public key of its kid in keys.json (not invalid).
L=$(cat receipt.txt); B=${L%.*}; KID=${B##*.}
curl -sf "https://stk-evidence.com/keys.json" | grep -q "\"kid\": \"$KID\"" && curl -sf "https://stk-evidence.com/keys/$KID.json" > key.json || { echo "not STK's"; exit 1; }
{ printf '\060\052\060\005\006\003\053\145\160\003\041\000'; sed -n 's/.*"public_key": "\(.*\)".*/\1/p' key.json | base64 -d; } | openssl pkey -pubin -inform DER -out key.pem
printf %s "$B" > body.txt; printf %s "${L##*.}" | base64 -d > sig.bin
grep -q '"invalid": null' key.json && openssl pkeyutl -verify -pubin -inkey key.pem -rawin -in body.txt -sigfile sig.bin > /dev/null 2>&1 && echo "STK's" || { echo "not STK's"; exit 1; }
Known limits
What STK cannot do today, or can get wrong, at Stripe and with one server.
US bank account required
What happens. STK is paid one way only: a US bank account, debited by STK (ACH). A company with no US bank account cannot have a key. There is no card, no invoice to pay yourself, and nothing per country.
What you can do. Register a US bank account once (how).
A debit is refused
What happens. STK signs from when a debit begins, before your bank answers. Refused for want of money, or for any reason not named as refused for good below, it is debited again 3 days later, 3 tries in all, and STK signs throughout; after the third, STK does not try again, and that month is not owed (STK never asks for it, except as the way to sign again below). All 3 refused for want of money in two months billed in a row: STK signs nothing for your account from the next call (402) until the later of the last two such months is debited once and goes through. STK does not debit it again by itself; another bank account registered (POST /v1/keys with your key in X-STK-Key) is debited for it once. Gone through, STK signs again from the next call after it reads that (it reads the debits every hour); refused, nothing changes. A debit begun or a later month paid is not enough. Refused for good (a closed account, no such account, an invalid account number, the account restricted, or debits not authorized): STK signs nothing for your account from the next call (402). An invoice refused for good, or of a month not owed, that stops nothing is marked uncollectible in Stripe 90 days after its last refusal, kept as it is. STK cannot debit a refused account again by itself: the US bank network lets a refused debit be presented again twice at most, and after the other refusals Stripe ends the authorization.
What you can do. Register another bank account: POST /v1/keys with your key in X-STK-Key. Refused for good: the last month so refused is debited at once and STK signs again from your next call; a month before it stays owed, is not debited, and stops nothing. Two months in a row for want of money: the later month is debited from it once, and STK signs again once that debit goes through.
One payment is at most $999,999.99
What happens. Stripe takes one debit in US dollars of at most $999,999.99, and does not issue an invoice above it that a bank account can pay. A month above it is debited by STK on its own as several debits, as few and as equal as can be (each at most $999,999.98, the last can be a few cents less), together its amount to the cent. Each is its own invoice in Stripe. No one is asked.
Your bank's daily limit
What happens. If your bank has a daily limit on debits, the several debits of one month can be refused. Stripe gives no answer that tells this refusal from another, so it is handled as your bank's answer says: for want of money or another reason, tried again; debits not authorized, refused for good (above).
What you can do. If your month can pass $999,999.99, ask your bank to take STK's debits on the 1st of the month above its daily limit.
STK's own limit at Stripe
What happens. Stripe limits what STK may debit by bank account over a rolling week, and does not publish the amount. A debit above it is not sent to your bank: STK begins it again the next day, every day until Stripe takes it. It is not one of the 3 tries, and STK signs for your account throughout.
STK that cannot reach Stripe
What happens. STK signs only with keys whose public keys it has already written to Stripe; each day's keys are made 200 days ahead. With no published key for the day it signs nothing: every count with a key is answered 503, and nothing is billed. When it can write a public key again, the next count is signed. A server that is starting and has not read its records in Stripe answers 503; send the same seal again when STK answers. The same 503 comes for a moment when STK is deployed, until the process before it stops. Your code decides what your AI does whatever STK answers. Nobody has to do anything.
A day STK started again on
What happens. STK writes each company's count of the day to Stripe every 2 minutes. When its server starts again in a day (a deploy, or after it stopped), it cannot know which seals were counted before the start, so it never adds the two counts: the day is billed as the larger of them. The actions of the smaller count, and those not yet written when the server stopped, are not billed. A bill can come out lower than the number of seals STK counted. It cannot come out higher. STK does not deploy in the hour before or after 00:00 UTC; each deploy is in the Changelog; the later in a day it deploys, the more of that day's count can be left unbilled.
Who pays. STK.
How much STK signs
What happens. A key has no day limit. The seals of a day, of all accounts together, are each counted once, up to 46,930,325 in a day; past that, the account with the most seals that day gets no new seal signed until 00:00 UTC (503), and the others are counted on for 3,355,443 seals more, after which STK signs no new seal that day.
Who pays. Nobody: what is not signed is not billed.
All of STK’s API
Base: https://api.stk-evidence.com. These are all of STK's API.
POST /v1/count | An action your AI finished: counted, and a signed line back. |
POST /v1/keys | Stripe’s bank page. No key. |
GET /v1/keys | Your key, once, where Stripe sends you back. |
Get a key
POST https://api.stk-evidence.com/v1/keys
{}
→ {"bank_url": "https://checkout.stripe.com/c/pay/cs_live_…", "next": "Open bank_url and register a US bank account; Stripe then sends you to a page that shows your key, once."}
Open bank_url: Stripe's page takes your email and your US bank account, once. Stripe sends you back to https://api.stk-evidence.com/v1/keys?bank=…, which shows your key once, as text. It works at once; STK keeps only its hash.
GET /v1/keys
Where Stripe sends you back: ?bank=cs_…. text/plain: the key, that it is shown once, and the next call. Again: 409.
POST /v1/keys
A form post with no field, or {} as JSON: Stripe’s bank page (303 to it, or {"bank_url"}). With your key in X-STK-Key: the page registers another bank account to your account. A page gives one key. 3 bank pages an hour from one address.
Lost your key? POST /v1/keys with {}, and register the same bank account again: a new key. An account has one key: a new one replaces it, and the one before stops. Another bank account on an address that has an account: only with the key (409 without it). Your bank must let you sign in to it on Stripe's page (instant verification); there is no other way to register a bank account.
Pay. One way only: the US bank account registered on Stripe's page, debited by STK (ACH) on the 1st of each month, from 01:00 UTC, for the month before. A month under the least amount Stripe can debit gets no invoice: its count goes on the next month's, each such line saying it was carried, for as many months as it takes. Your receipts are as always. If a debit is refused: Known limits. When a debit goes through, Stripe sends a receipt to your address. STK sends you no email. Stripe also sends the one email the US bank network requires when the authorization is given.