Ananke TCode
Stamping PDFs
Place an Ananke TCode DataMatrix barcode into a PDF document. Configure placement, rendering, and output handling.
Overview
Stamping takes an original PDF and produces a new version with a DataMatrix barcode embedded at a configurable position. The barcode encodes the Ananke TCode payload — document metadata, a content hash, and a cryptographic signature.
Stamp request
SDK — Stamp a PDF
import { readFileSync } from "node:fs";
const stamp = await client.tcode.documents.stamp({
name: "Invoice #1234",
documentTypeCode: "INV",
placementTemplateId: "placement-uuid", // optional
pdf: readFileSync("./invoice.pdf"),
});
console.log(stamp.reference); // "TCR-XXXX"
console.log(stamp.status); // "Active"curl — Stamp a PDF
curl -X POST https://api.anankelabs.net/v1/tcode/stamps \
-H "x-api-key: ak_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Invoice #1234",
"documentTypeCode": "INV",
"pdf": "<base64-encoded PDF>"
}'Request fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Display name for this stamp. |
documentTypeCode | string | Yes | Document type code from reference data. |
pdf | Buffer | Blob | string | Yes | The PDF file to stamp. |
placementTemplateId | string | No | ID of a placement template controlling barcode position. |
tdocTemplateId | string | No | ID of a TDoc template defining the document schema. |
externalId | string | No | Your system's correlation ID for duplicate detection. |
Placement templates
Placement templates control where and how the barcode appears on the PDF. Without one, defaults apply. With one, you can configure:
- Page position (first page, last page, or specific page)
- Barcode coordinates (X, Y position on the page)
- Barcode size and margins
- Optional text labels around the barcode
Creating a placement template
SDK — Create a placement template
const placement = await client.tcode.placementTemplates.create({
name: "Bottom-right corner",
positionX: 450,
positionY: 50,
width: 100,
height: 100,
page: "last",
});
console.log(placement.id); // "placement-uuid"Response
A successful stamp returns the stamp object:
201 Created
{
"data": {
"id": "uuid",
"reference": "TCR-ABCD1234",
"status": "Active",
"name": "Invoice #1234",
"documentTypeCode": "INV",
"createdAt": "2026-03-18T10:00:00Z"
}
}Downloading the stamped PDF
After stamping, download the result with the barcode embedded:
SDK — Download stamped PDF
const pdf = await client.tcode.documents.download(stamp.id);
// pdf is a Buffer of the stamped PDFcurl — Download stamped PDF
curl https://api.anankelabs.net/v1/tcode/stamps/{id}/download \
-H "x-api-key: ak_live_..." \
-o stamped-invoice.pdfReplacing a stamp
Replace an existing stamp with an updated PDF. The original stamp is revoked and a new reference is issued:
SDK — Replace a stamp
const replacement = await client.tcode.documents.replace(stamp.id, {
name: "Invoice #1234 — Corrected",
pdf: readFileSync("./invoice-corrected.pdf"),
});Rendering guidance
- Keep the barcode at least 15mm × 15mm for reliable scanning.
- Ensure sufficient white-space around the barcode (quiet zone).
- Avoid placing the barcode over existing text or graphics.
- Test with both mobile camera scanners and dedicated barcode readers.
- Print at 300 DPI or higher for best scan reliability.
Errors
| Status | Reason |
|---|---|
400 | Missing required fields or invalid PDF format. |
404 | Placement template or TDoc template not found. |
409 | Duplicate detection fired for this externalId. |
422 | Template is archived or configuration mismatch. |
Next steps
- Verification & scans — Verify stamped documents.
- Guide: Stamp a PDF — Step-by-step tutorial.
- Ananke TCode API Reference — Full endpoint docs.