---
title: "Sign a PDF (Base64)"
method: POST
path: "/api/signatures/sign"
tags: ["Digital Signatures"]
---

# Sign a PDF (Base64)

`POST /api/signatures/sign`

## Request

- Base URL: `https://api.dokmatiq.com`
- URL: `https://api.dokmatiq.com/api/signatures/sign`
- Auth: API key in header `X-API-Key`

Digitally sign a PDF using a PKCS#12 certificate. The certificate can be referenced by name (pre-uploaded) or provided inline as Base64. Optionally includes a visible signature and/or a trusted timestamp.

## Headers

- `X-DocGen-Validate` string

## Request body

- SignatureRequest: Request to digitally sign a PDF with a PKCS#12 certificate
  - `pdfBase64` string, required: Base64-encoded PDF to sign
  - `certificateName` string: Name of a pre-uploaded certificate (stored on server)
  - `certificateBase64` string: Base64-encoded PKCS#12 (.p12/.pfx) certificate (inline, alternative to certificateName)
  - `certificatePassword` string, required: Password for the PKCS#12 certificate
  - `reason` string: Reason for signing
  - `location` string: Location of signing
  - `contactInfo` string: Contact information of the signer
  - `signerName` string: Name of the signer (if not extracted from certificate)
  - `timestampUrl` string: URL of a Timestamp Authority (TSA) server for trusted timestamps. Examples: http://timestamp.digicert.com, http://tsa.swisssign.net
  - `visibleSignature` VisibleSignatureConfig: Visible signature appearance on the PDF
    - `page` integer: Page number (1-based) where the signature should appear
    - `x` number, float: X position in mm from the left edge
    - `y` number, float: Y position in mm from the bottom edge
    - `width` number, float: Width of the signature rectangle in mm
    - `height` number, float: Height of the signature rectangle in mm
    - `text` string: Text to display in the signature field. Supports placeholders: ${signer}, ${date}, ${reason}, ${location}
    - `fontSize` number, float: Font size for the signature text in points
    - `imageBase64` string: Base64-encoded image (PNG/JPEG) to display in the signature field (e.g. a handwritten signature)

## Response `200`

Signed PDF

## Other responses

- `400`: Invalid request or certificate

---

[API](https://skmtc.dev/dokmatiq/apis/docgen-api.md) · [All operations](https://skmtc.dev/dokmatiq/apis/docgen-api/llms.txt) · [OpenAPI document](https://skmtc.dev/dokmatiq/apis/docgen-api/revisions/3fa1a922764d?raw)
