Sign a CrawlClick receipt with Ed25519
Sign the UTF-8 bytes of "crawlclick-receipt-v1", a newline and the decision_id with your Ed25519 private key, and POST the unpadded base64url signature with your key_id to /v1/decide/receipts before expires_at.
Status: Coming. A receipt is how a partner tells CrawlClick that it showed a placement. It is the evidence a serve is billed and paid on: a decision you do not confirm costs nothing and earns nothing. The route is built and tested but not yet open to partners, and CrawlClick issues the base URL and your ccp_… key when it is. This page gives the exact bytes to sign, code to generate a key and sign in four languages, a test vector to check your code against, and what to do with each response. To get a decision_id, see Request a placement.
POST/v1/decide/receiptsComing
Confirm, with an Ed25519 signature, that you showed a placement. Only confirmed placements are billed and paid.
- Host
- https://<issued with your partner key>
- Authentication
Authorization: Bearer ccp_…with thereceiptsscope.- Source
- api-crawlclick-com/crates/crawlclick/src/decision_api.rs
Request body (JSON)
| Field | Type | Description |
|---|---|---|
| decision_id | string | The decision_id from /v1/decide, exactly as returned. |
| key_id | string | The id of the Ed25519 public key you registered with CrawlClick. |
| signature | string | Unpadded base64url of the 64-byte Ed25519 signature over the UTF-8 bytes of crawlclick-receipt-v1\n followed by decision_id. |
Responses
202 · Recorded as a billable serve.
{"recorded": true, "event_id": "dec:…"}200 · Already confirmed. Nothing more happens.
{"recorded": false, "duplicate": true}202 · The campaign ran out of budget between the decision and the receipt. The serve is not billed and earns nothing.
{"recorded": false, "code": "budget_exhausted"}Refusals
| Status | Code | Means | Do instead |
|---|---|---|---|
| 401 | invalid_key | The bearer token is missing, unknown, revoked, or lacks the scope this route needs. | Send Authorization: Bearer ccp_… with the key CrawlClick issued. A rotated or revoked key stops working within about ten seconds; ask CrawlClick for a new one. |
| 429 | rate_limited | Your per-minute request limit, set on your partner account, was exceeded. | Back off and retry. The limit is a token bucket that refills continuously at your per-minute rate, counted per partner and separately for decisions and receipts. |
| 413 | — | The body is over 65,536 bytes. The body is {"error": "body too large"}, with no code. | Send only the documented fields. Truncate query and topics on your side. |
| 503 | — | The service is at capacity. The body is empty and Retry-After: 1 is set. | For a decision, answer without a placement. For a receipt, retry after a second. |
| 400 | bad_request | The body lacks decision_id, key_id or signature. | Send all three as strings. |
| 400 | invalid_decision | The decision_id was not issued by this service, or was altered. | Send the token byte for byte as /v1/decide returned it; do not decode, re-encode or trim inner characters. |
| 410 | decision_expired | The decision is older than its expires_at (15 minutes after issue). | Do not confirm it. A decision you did not confirm in time costs nothing and earns nothing. |
| 403 | not_your_decision | The decision was issued to another partner account. | Confirm decisions only with the key of the account that requested them. |
| 401 | bad_receipt_signature | The signature does not verify against the public key registered under key_id. | Sign the exact message bytes, with no trailing newline, using the private half of the registered key, and send the signature as unpadded base64url. |
| 503 | unavailable | The receipt could not be written as evidence. | Retry the same receipt. Keep your own serve log: it is what reconciliation compares against. |
What exactly do I sign?
The message is the UTF-8 bytes of the string crawlclick-receipt-v1, one line feed (byte 0x0a), and the decision_id exactly as /v1/decide returned it. There is no trailing newline, no JSON, and no hashing before signing: it is plain Ed25519 (RFC 8032) over those bytes. For a decision_id of ccx1.abc.def the message is these 34 bytes:
63 72 61 77 6c 63 6c 69 63 6b 2d 72 65 63 65 69 70 74 2d 76 31 0a crawlclick-receipt-v1\n
63 63 78 31 2e 61 62 63 2e 64 65 66 ccx1.abc.def
CrawlClick trims whitespace from the ends of the decision_id before it checks the token and rebuilds the message, so a stray newline read from a file does not break verification. Do not depend on that; sign the token as returned.
How are the key and signature encoded?
- Signature: the 64-byte Ed25519 signature as base64url without padding, 86 characters. Padded base64url and standard base64 are both refused.
- Public key: the raw 32-byte Ed25519 public key as base64url without padding, 43 characters. This is what you send CrawlClick to register. Not PEM, not DER, not hex.
- Key id: a name you choose, 1 to 64 characters from
A–Z,a–z,0–9,.,_and-. Key ids are unique across CrawlClick, so include your own name, for exampleacme-receipts-2026-12.
CrawlClick verifies with strict Ed25519 verification, which also refuses non-canonical signatures and weak public keys. Every standard signer, including the four below, produces signatures that pass.
How do I register a public key with CrawlClick?
Registration is done by CrawlClick, not through the API. Generate a key pair with one of the programs below, keep the private seed in your secret store, and send CrawlClick the public key and the key id you chose. CrawlClick checks that the key decodes to 32 bytes and is a valid Ed25519 point, then adds it to your partner account. The partner area of the console lists your registered keys. A new or revoked key reaches the decision service within seconds.
You can register more than one key. To rotate, register the new key, switch your signer to it, and then ask CrawlClick to revoke the old one. A receipt signed with a revoked key gets 401 bad_receipt_signature.
The samples store the private key as its 32-byte seed in unpadded base64url, in CRAWLCLICK_RECEIPT_KEY, because all four languages can load a key from a raw seed. The key id goes in CRAWLCLICK_RECEIPT_KEY_ID.
How do I generate a key and sign a receipt in Node.js?
node:crypto supports Ed25519 directly. A JWK export gives the raw seed (d) and public key (x) already in unpadded base64url.
// keygen.mjs: run once, then register the public key with CrawlClick.
import { generateKeyPairSync } from 'node:crypto';
const { publicKey, privateKey } = generateKeyPairSync('ed25519');
// A JWK's "d" and "x" are the raw 32-byte seed and public key in unpadded base64url.
const seed = privateKey.export({ format: 'jwk' }).d;
const pub = publicKey.export({ format: 'jwk' }).x;
console.log(`private seed, keep secret (CRAWLCLICK_RECEIPT_KEY): ${seed}`);
console.log(`public key, send to CrawlClick: ${pub}`);
// sign.mjs: node sign.mjs <decision_id> prints the receipt body.
import { createPrivateKey, createPublicKey, sign } from 'node:crypto';
// RFC 8410 PKCS#8 prefix for an Ed25519 private key; the 32-byte seed follows it.
const PKCS8_PREFIX = Buffer.from('302e020100300506032b657004220420', 'hex');
function receiptKey(seedB64url) {
const seed = Buffer.from(seedB64url.trim(), 'base64url');
if (seed.length !== 32) throw new Error('the receipt key must be a 32-byte seed');
return createPrivateKey({ key: Buffer.concat([PKCS8_PREFIX, seed]), format: 'der', type: 'pkcs8' });
}
function receiptSignature(key, decisionId) {
const message = Buffer.from(`crawlclick-receipt-v1\n${decisionId}`, 'utf8');
return sign(null, message, key).toString('base64url'); // 64 bytes, unpadded base64url
}
const key = receiptKey(process.env.CRAWLCLICK_RECEIPT_KEY);
const decisionId = process.argv[2]; // the decision_id exactly as /v1/decide returned it
console.log(JSON.stringify({
decision_id: decisionId,
key_id: process.env.CRAWLCLICK_RECEIPT_KEY_ID,
signature: receiptSignature(key, decisionId),
}));
// The public key this private key pairs with, to check against what you registered.
console.error(`public key: ${createPublicKey(key).export({ format: 'jwk' }).x}`);
Pass null as the algorithm to sign: Ed25519 takes no separate digest.
How do I generate a key and sign a receipt in Python?
Use the cryptography package (pip install cryptography). Python’s base64 module pads by default, so strip = when encoding and add it back when decoding.
# keygen.py: run once, then register the public key with CrawlClick.
import base64
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
def b64url(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")
private_key = Ed25519PrivateKey.generate()
seed = private_key.private_bytes(
serialization.Encoding.Raw, serialization.PrivateFormat.Raw, serialization.NoEncryption()
)
public = private_key.public_key().public_bytes(
serialization.Encoding.Raw, serialization.PublicFormat.Raw
)
print(f"private seed, keep secret (CRAWLCLICK_RECEIPT_KEY): {b64url(seed)}")
print(f"public key, send to CrawlClick: {b64url(public)}")
# sign.py: python sign.py <decision_id> prints the receipt body.
import base64
import json
import os
import sys
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
def b64url_decode(text: str) -> bytes:
text = text.strip()
return base64.urlsafe_b64decode(text + "=" * (-len(text) % 4))
def b64url_encode(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode("ascii")
def receipt_signature(key: Ed25519PrivateKey, decision_id: str) -> str:
message = ("crawlclick-receipt-v1\n" + decision_id).encode("utf-8")
return b64url_encode(key.sign(message)) # 64 bytes, unpadded base64url
key = Ed25519PrivateKey.from_private_bytes(b64url_decode(os.environ["CRAWLCLICK_RECEIPT_KEY"]))
decision_id = sys.argv[1] # the decision_id exactly as /v1/decide returned it
print(json.dumps({
"decision_id": decision_id,
"key_id": os.environ["CRAWLCLICK_RECEIPT_KEY_ID"],
"signature": receipt_signature(key, decision_id),
}))
public = key.public_key().public_bytes(serialization.Encoding.Raw, serialization.PublicFormat.Raw)
print(f"public key: {b64url_encode(public)}", file=sys.stderr)
How do I generate a key and sign a receipt in Go?
The standard library’s crypto/ed25519 and base64.RawURLEncoding (base64url without padding) are all you need. go run receipt.go keygen creates a key; go run receipt.go sign <decision_id> prints the receipt body.
// receipt.go
package main
import (
"crypto/ed25519"
"crypto/rand"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"os"
"strings"
)
// receiptMessage is the exact byte string CrawlClick verifies.
func receiptMessage(decisionID string) []byte {
return []byte("crawlclick-receipt-v1\n" + decisionID)
}
func receiptKey(seedB64url string) (ed25519.PrivateKey, error) {
seed, err := base64.RawURLEncoding.DecodeString(strings.TrimSpace(seedB64url))
if err != nil {
return nil, fmt.Errorf("the receipt key is not unpadded base64url: %w", err)
}
if len(seed) != ed25519.SeedSize {
return nil, errors.New("the receipt key must be a 32-byte seed")
}
return ed25519.NewKeyFromSeed(seed), nil
}
func receiptSignature(key ed25519.PrivateKey, decisionID string) string {
return base64.RawURLEncoding.EncodeToString(ed25519.Sign(key, receiptMessage(decisionID)))
}
func main() {
if len(os.Args) < 2 {
fmt.Fprintln(os.Stderr, "usage: receipt keygen | receipt sign <decision_id>")
os.Exit(2)
}
switch os.Args[1] {
case "keygen":
pub, priv, err := ed25519.GenerateKey(rand.Reader)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println("private seed, keep secret (CRAWLCLICK_RECEIPT_KEY):", base64.RawURLEncoding.EncodeToString(priv.Seed()))
fmt.Println("public key, send to CrawlClick:", base64.RawURLEncoding.EncodeToString(pub))
case "sign":
if len(os.Args) < 3 {
fmt.Fprintln(os.Stderr, "usage: receipt sign <decision_id>")
os.Exit(2)
}
key, err := receiptKey(os.Getenv("CRAWLCLICK_RECEIPT_KEY"))
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
decisionID := os.Args[2] // the decision_id exactly as /v1/decide returned it
body, err := json.Marshal(map[string]string{
"decision_id": decisionID,
"key_id": os.Getenv("CRAWLCLICK_RECEIPT_KEY_ID"),
"signature": receiptSignature(key, decisionID),
})
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println(string(body))
fmt.Fprintln(os.Stderr, "public key:", base64.RawURLEncoding.EncodeToString(key.Public().(ed25519.PublicKey)))
default:
fmt.Fprintln(os.Stderr, "usage: receipt keygen | receipt sign <decision_id>")
os.Exit(2)
}
}
How do I generate a key and sign a receipt in Rust?
This uses the same crates the CrawlClick service verifies with: ed25519-dalek 2 and base64 0.22. The rand_core feature of ed25519-dalek and the getrandom feature of rand_core 0.6 are needed for key generation only.
# Cargo.toml
[package]
name = "receipt"
version = "0.1.0"
edition = "2021"
[dependencies]
ed25519-dalek = { version = "2", features = ["rand_core"] }
rand_core = { version = "0.6", features = ["getrandom"] }
base64 = "0.22"
// src/main.rs: `cargo run -- keygen` or `cargo run -- sign <decision_id>`.
use std::env;
use base64::engine::general_purpose::URL_SAFE_NO_PAD;
use base64::Engine;
use ed25519_dalek::{Signer, SigningKey};
use rand_core::OsRng;
/// The exact bytes CrawlClick verifies.
fn receipt_message(decision_id: &str) -> Vec<u8> {
format!("crawlclick-receipt-v1\n{decision_id}").into_bytes()
}
fn receipt_key(seed_b64url: &str) -> Result<SigningKey, String> {
let seed: [u8; 32] = URL_SAFE_NO_PAD
.decode(seed_b64url.trim())
.map_err(|e| format!("the receipt key is not unpadded base64url: {e}"))?
.try_into()
.map_err(|_| "the receipt key must be a 32-byte seed".to_string())?;
Ok(SigningKey::from_bytes(&seed))
}
fn receipt_signature(key: &SigningKey, decision_id: &str) -> String {
URL_SAFE_NO_PAD.encode(key.sign(&receipt_message(decision_id)).to_bytes())
}
fn main() -> Result<(), String> {
let args: Vec<String> = env::args().collect();
match args.get(1).map(String::as_str) {
Some("keygen") => {
let key = SigningKey::generate(&mut OsRng);
println!("private seed, keep secret (CRAWLCLICK_RECEIPT_KEY): {}", URL_SAFE_NO_PAD.encode(key.to_bytes()));
println!("public key, send to CrawlClick: {}", URL_SAFE_NO_PAD.encode(key.verifying_key().to_bytes()));
}
Some("sign") => {
let decision_id = args.get(2).ok_or("usage: receipt sign <decision_id>")?;
let key = receipt_key(&env::var("CRAWLCLICK_RECEIPT_KEY").map_err(|e| e.to_string())?)?;
let key_id = env::var("CRAWLCLICK_RECEIPT_KEY_ID").map_err(|e| e.to_string())?;
// A decision_id holds only base64url characters and dots, so it needs no JSON escaping.
println!(
"{{\"decision_id\":\"{decision_id}\",\"key_id\":\"{key_id}\",\"signature\":\"{}\"}}",
receipt_signature(&key, decision_id)
);
eprintln!("public key: {}", URL_SAFE_NO_PAD.encode(key.verifying_key().to_bytes()));
}
_ => return Err("usage: receipt keygen | receipt sign <decision_id>".into()),
}
Ok(())
}
Is there a test vector to check my signer against?
Yes. This vector was computed with Node’s node:crypto, checked with Python’s cryptography and with ed25519-dalek 2 using strict verification, and all three agree. The seed is 32 zero bytes, a public test value: never use it as a real key. The decision_id is a made-up string in the token’s shape; CrawlClick would refuse it as a decision, but the signature over it is still a valid test of your signing code.
| Input or output | Value |
|---|---|
| Seed (hex) | 0000000000000000000000000000000000000000000000000000000000000000 |
| Seed (base64url) | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
| Public key (base64url) | O2onvM62pC1io6jQKm8Nc2UyFXcd4kOmOsBIoYtZ2ik |
| decision_id | ccx1.test-vector-claims.test-vector-tag |
| Signature (base64url) | E2zAaiduYv_g3SUEJo_YIzHCI5qB9KRyr4-ayEgUSQ5f6408mX9oat3g0kvCu64dxYWwsfocnwZMe59tgOObBQ |
Ed25519 signatures are deterministic, so your code must print exactly this signature. With the Node program above:
CRAWLCLICK_RECEIPT_KEY=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA CRAWLCLICK_RECEIPT_KEY_ID=test \
node sign.mjs ccx1.test-vector-claims.test-vector-tag
If your public key differs, your seed is being decoded wrongly. If the public key matches and the signature differs, the message bytes are wrong: look for a missing or doubled newline, a trailing newline, or a different string encoding.
In what order does CrawlClick check a receipt?
Each check answers on its own, in this order, so the status tells you which one failed:
- The key:
401 invalid_keyif it is missing, unknown, revoked, or lacks thereceiptsscope. - The rate limit:
429 rate_limited. Receipts have their own bucket, separate from decisions. - The body:
400 bad_requestunlessdecision_id,key_idandsignatureare all strings. - The token:
400 invalid_decisionif CrawlClick did not issue it or it was altered;410 decision_expiredonceexpires_athas passed. - The owner:
403 not_your_decisionif the decision was issued to another partner account. - The signature:
401 bad_receipt_signatureifkey_idis not one of your registered keys or the signature does not verify. - Then the outcome:
202recorded,200duplicate, or202withbudget_exhausted.
Should I retry a receipt, and when?
Retry the same receipt on 503 and on 429, and when the request failed in transport (a timeout or a dropped connection), until shortly before expires_at. Send the same body each time. Ed25519 signatures are deterministic, so re-signing gives identical bytes anyway. A 503 with {"code": "unavailable"} means the receipt could not be written as evidence; a 503 with an empty body and Retry-After: 1 means the service was at its connection limit and did not read the request. Back off between attempts, and respect Retry-After when it is present.
Do not retry 400, 401 or 403: they fail the same way every time until you fix the cause. Do not retry 410: an expired decision cannot be confirmed, and it costs and earns nothing. A 200 duplicate and a 202 budget_exhausted are final answers. budget_exhausted means the campaign’s budget ran out between the decision and the receipt; the serve is not billed and earns nothing, and that is not an error on your side.
Keep your own serve log: one line per placement you showed, with the decision_id, campaign, creative, the time you showed it, and each receipt attempt and its answer. It is what CrawlClick’s reconciliation compares against. The partner area of the console shows confirmed serves paid and refused per day, and CrawlClick can compare those counts with your log for any day.
A complete client that signs, sends, retries and logs is on the reference client page.