SDK npm package is not published yet and API environments may be unavailable.View status
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

FieldTypeRequiredDescription
namestringYesDisplay name for this stamp.
documentTypeCodestringYesDocument type code from reference data.
pdfBuffer | Blob | stringYesThe PDF file to stamp.
placementTemplateIdstringNoID of a placement template controlling barcode position.
tdocTemplateIdstringNoID of a TDoc template defining the document schema.
externalIdstringNoYour 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 PDF
curl — Download stamped PDF
curl https://api.anankelabs.net/v1/tcode/stamps/{id}/download \
  -H "x-api-key: ak_live_..." \
  -o stamped-invoice.pdf

Replacing 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

StatusReason
400Missing required fields or invalid PDF format.
404Placement template or TDoc template not found.
409Duplicate detection fired for this externalId.
422Template is archived or configuration mismatch.

Next steps