Issue a document
End-to-end guide to issuing an Ananke Trust document. Covers prerequisites, SDK setup, making the request, handling the response, and verifying the result.
Use case
You want to issue a verifiable digital credential — a certificate, diploma, or license — and deliver it to a recipient. The recipient or any third party can later verify its authenticity.
Prerequisites
- An active Ananke Labs tenant with an API key
- An Ananke Trust template configured for your document type
- Node.js 18+ (for the SDK) or any HTTP client
1. Install and configure the SDK
npm install @ananke/sdkimport { AnankeClient } from "@ananke/sdk";
const client = new AnankeClient({
baseUrl: process.env.ANANKE_BASE_URL ?? "http://localhost:5300",
apiKey: process.env.ANANKE_API_KEY!,
});2. Choose or create a template
Templates define the document structure. List your existing templates or create a new one:
const templates = await client.trust.templates.list({ page: 1, pageSize: 10 });
for (const t of templates.items) {
console.log(t.id, t.name);
}Note the id of the template you want to use. See Templates for more details.
3. Issue the document
const doc = await client.trust.documents.issue({
templateId: "your-template-id",
recipientName: "Jane Doe",
recipientEmail: "jane@example.com",
documentTitle: "Certificate of Completion",
fields: [
{ key: "certNumber", value: "C-2026-001" },
{ key: "course", value: "Platform Engineering" },
{ key: "grade", value: "Distinction" },
],
});Or with raw HTTP:
curl -X POST http://localhost:5300/v1/trust/issuances \
-H "x-api-key: $ANANKE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"templateId": "your-template-id",
"recipientName": "Jane Doe",
"recipientEmail": "jane@example.com",
"documentTitle": "Certificate of Completion",
"fields": [
{ "key": "certNumber", "value": "C-2026-001" },
{ "key": "course", "value": "Platform Engineering" }
]
}'4. Handle the response
console.log(doc.reference); // "TRF-XXXX" - unique document reference
console.log(doc.status); // "Active"
console.log(doc.id); // UUID for API operations
// Store the reference for later verification
// Store the ID for lifecycle managementThe reference is what you share with the recipient and verifiers. The id is what you use for API operations (suspend, revoke, replace).
5. Attach a PDF (optional)
If your credential includes a PDF file:
import { readFileSync } from "node:fs";
const doc = await client.trust.documents.issue({
templateId: "your-template-id",
recipientName: "Jane Doe",
recipientEmail: "jane@example.com",
fields: [{ key: "certNumber", value: "C-2026-001" }],
pdf: readFileSync("./certificate.pdf"),
});6. Verify the issuance
Confirm the document was issued correctly by verifying it:
const result = await client.trust.verify.byReference(doc.reference);
console.log(result.verdict); // "valid"
console.log(result.issuerName); // Your tenant name
console.log(result.status); // "Active"Error cases
import { AnankeApiError, AnankeFieldValidationError } from "@ananke/sdk";
try {
const doc = await client.trust.documents.issue({ /* ... */ });
} catch (err) {
if (err instanceof AnankeFieldValidationError) {
// 400 - field validation failed
console.error("Validation errors:", err.fieldErrors);
} else if (err instanceof AnankeApiError) {
// Other API errors (401, 403, 404, 409, 422)
console.error(err.code, err.message);
}
}Next steps
- Verify a document — Build verification into your workflow.
- Issuance reference — All issuance options and lifecycle states.
- Templates — Create and manage document templates.
- Ananke Trust API Reference — Full endpoint documentation.