Guide · Ananke TCode
Generate an Ananke TCode
Create an Ananke TCode stamp for a document. Covers the stamping request, payload generation, and next steps for verification.
Use case
You have a document (PDF) that needs a verifiable DataMatrix barcode. After stamping, anyone who scans the barcode can verify the document's authenticity.
Prerequisites
- An active Ananke Labs tenant with an API key
- A PDF file to stamp
- Node.js 18+ (for the SDK) or any HTTP client
1. Install and configure the SDK
bash
npm install @ananke/sdkConfigure the client
import { AnankeClient } from "@ananke/sdk";
const client = new AnankeClient({
baseUrl: process.env.ANANKE_BASE_URL ?? "http://localhost:5300",
apiKey: process.env.ANANKE_API_KEY!,
});2. Prepare your document
Ensure your PDF is finalized — no further edits after stamping, as any change would invalidate the content hash and verification.
Read the PDF
import { readFileSync } from "node:fs";
const pdf = readFileSync("./invoice.pdf");3. Create the stamp
SDK — Stamp the document
const stamp = await client.tcode.documents.stamp({
name: "Invoice #1234",
documentTypeCode: "INV",
pdf: pdf,
});Or with curl:
curl
curl -X POST http://localhost:5300/v1/tcode/stamps \
-H "x-api-key: $ANANKE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Invoice #1234",
"documentTypeCode": "INV",
"pdf": "<base64-encoded PDF>"
}'4. Handle the response
Check the result
console.log(stamp.reference); // "TCR-XXXX"
console.log(stamp.status); // "Active"
console.log(stamp.id); // UUID for API operations5. Download the stamped PDF
SDK — Download the stamped PDF
import { writeFileSync } from "node:fs";
const stampedPdf = await client.tcode.documents.download(stamp.id);
writeFileSync("./invoice-stamped.pdf", stampedPdf);6. Verify the stamp
Confirm the stamp works by verifying it:
SDK — Verify
const result = await client.tcode.verify.byReference(stamp.reference);
console.log(result.verdict); // "valid"
console.log(result.status); // "Active"Next steps
- Stamp a PDF — Deep dive into placement and rendering.
- Verification & scans — Full verification reference.
- Ananke TCode API Reference — Endpoint documentation.