Mohor API reference
Base URL: https://api.emohor.com. All bodies are JSON. PDFs travel as base64.
1. Authenticate
Register your app in Connected apps to get a client_id and client_secret.
POST /v1/oauth/token
{ "grant_type": "client_credentials", "client_id": "app_...", "client_secret": "..." }
→ { "access_token": "...", "token_type": "Bearer", "expires_in": 3600 }
Send Authorization: Bearer <access_token> on every call. HTTP Basic (client_id:client_secret) also works.
2. Managed signing (default)
Your app sends the PDF. Mohor draws the stamp, signs it with the signer's certificate in the HSM, keeps the signed copy in the vault and emails it.
POST /v1/sign-requests
{
"title": "Invoice INV-2026-0042",
"signers": [{ "email": "aisyah@company.my", "position": { "page": -1, "x": 360, "y": 740 } }],
"document": { "mode": "managed", "pdf": "<base64>" },
"approval": "any",
"callback": "https://yourapp.example/webhooks/mohor",
"external_ref": "INV-2026-0042"
}
→ 202 { "id": "...", "ref": "MH-...", "status": "AWAITING", ..., "sign_urls": [] }
signers[].emailorsigners[].staff_ididentifies a user. A signer who is not a Mohor user gets a one-time sign link (returned insign_urls) and signs with an email OTP.document.mode:managed(sendpdf),remote_fetch(sendurl, Mohor downloads it), orhash(see section 3).approval:mobile_push,web_otporany.page: -1means the last page. Coordinates are PDF points from the top-left.
Check status or fetch the result:
GET /v1/sign-requests/:id → { id, ref, status, signers[], verify_url, ... }
GET /v1/sign-requests/:id/signed-pdf → application/pdf
The signed PDF is the newest long-term archive version once Mohor has added archive timestamps (append-only; the signature is unchanged). Add ?version=signed to get the copy exactly as it was signed.
Statuses: AWAITING, SIGNED_NOT_FINAL (some signers done), COMPLETED, DECLINED, EXPIRED, FAILED.
3. Hash + return mode
Use this when the PDF must never leave your servers.
POST /v1/preparewith{ "signer": "email", "position": {...} }returns the stamp (signature image, name, QR link, rectangle).- Draw the stamp and reserve a signature field locally (the SDK's
startHashSigningdoes both), then hash the byte range. POST /v1/sign-requestswith"document": { "mode": "hash", "sha256": "<hex>", "preview_url": "https://..." }.- The
request.completedwebhook also carriescms(base64 CMS signature) andcertificate_pem. Embed it into your prepared PDF (finishHashSigning). - Optionally
POST /v1/sign-requests/:id/returnwith{ "pdf": "<base64>" }(vault copy) or{ "sha256": "<hex>" }(evidence only).
4. Webhooks
Events: request.signed, request.completed, request.rejected, request.failed.
Each call has the header x-mohor-signature: t=<unix>,v1=<hex>, where v1 = HMAC-SHA256(webhook_secret, "<t>.<raw body>"). Reject a call when the signature does not match or t is more than 5 minutes old. A failed delivery is retried 8 times with exponential backoff starting at 5 seconds.
{ "event": "request.completed", "id": "...", "ref": "MH-...", "status": "COMPLETED", "external_ref": "INV-2026-0042",
"signers": [{ "name": "Aisyah", "email": "aisyah@company.my", "status": "SIGNED", "signed_at": "..." }],
"document": { "verify_url": "https://app.emohor.com/v/ABCD123456", "signed_sha256": "...", "signed_pdf_url": "..." } }
5. Node SDK
import { Mohor, verifyWebhook } from '@mohor/sdk';
const mohor = new Mohor({ baseUrl: 'https://api.emohor.com', clientId, clientSecret });
const req = await mohor.signPdf(pdfBytes, { title: 'Invoice', signers: [{ email: 'aisyah@company.my' }] });
const done = await mohor.waitFor(req.id);
const signed = await mohor.downloadSignedPdf(req.id);
// in your webhook handler (raw body string)
if (!verifyWebhook(rawBody, req.headers['x-mohor-signature'], webhookSecret)) return res.sendStatus(401);
Hash mode: startHashSigning(pdf, { signer, title }) → wait for the webhook → finishHashSigning(id, prepared, cms).
6. Sign button for web pages
For signers outside your organisation, put the sign_urls[].url into a button:
<script src="https://app.emohor.com/widget.js" defer></script>
<mohor-sign-button href="https://app.emohor.com/s/TOKEN" auto-close>Sign now</mohor-sign-button>
<script>
document.querySelector('mohor-sign-button')
.addEventListener('signed', (e) => console.log(e.detail.ref, e.detail.verifyCode));
</script>
7. Public verification
- Anyone can check a document at
https://app.emohor.com/verify(enter the code under the QR, or drop the PDF). GET /v1/public/verify/:codereturns the signature record.POST /v1/public/lookupwith{ "sha256": "<hex>" }finds the code for a signed file.