Prepare PDF and calculate hash (PreSign)
const url = 'https://api.test.certilia.com/pades/v2';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"token":"<token from ePotpis>","signatureFormat":"pades","signatureType":"sign","addVisualData":true,"personNaturalData":{"nameSurname":"Ivan Horvat","pin":"00000000001","pinCountry":"HR"},"documents":[{"verificationCode":"00000000-0000-0000-0000-000000000001","base64Document":"JVBERi0xLjcK...","documentName":"Contract 2026-001.pdf","firstRowMessage":"Signed in the Primjer d.o.o. web shop.","secondRowMessage":"Order no. 2026-0001","pageNumber":1,"pageLocation":5}]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.test.certilia.com/pades/v2 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "token": "<token from ePotpis>", "signatureFormat": "pades", "signatureType": "sign", "addVisualData": true, "personNaturalData": { "nameSurname": "Ivan Horvat", "pin": "00000000001", "pinCountry": "HR" }, "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "base64Document": "JVBERi0xLjcK...", "documentName": "Contract 2026-001.pdf", "firstRowMessage": "Signed in the Primjer d.o.o. web shop.", "secondRowMessage": "Order no. 2026-0001", "pageNumber": 1, "pageLocation": 5 } ] }'Prepares each PDF document for signing and returns the hash to be signed in ePotpis.
- Uses the eIDAS PAdES standard.
- Reserves space in the document for the signature value.
- With
addVisualData: true, adds the visible signature element (visual) with the natural and/or legal person data. - One request can hold one or more PDF documents, for an invisible or visible signature or seal.
- By default the prepared (presign) file stays on the API server until the signature value is embedded
with
PATCH /pades/v2. Prepared files are kept for 24 hours; the signature can be embedded only within that time.
Authorizations
Odjeljak „Authorizations”Request Bodyrequired
Odjeljak „Request Bodyrequired”PreSign request: the ePotpis transaction data, the signer data for the visual (if one is used) and the documents.
object
EPotpis transaction token (a JWT), received from ePotpis when the transaction was created. One token per transaction; a transaction can hold one or more documents.
Signature format. Always pades.
sign: electronic signature. The signer is a natural person, signing for private or business purposes.seal: electronic seal, created on behalf of a legal person.
true adds the visible signature element (visual) to the document; false creates an invisible
signature or seal.
With a visual, the signer data is required: personNaturalData for a signature, personLegalData
for a seal (and optionally for a signature made for business purposes).
Options for the visual. Used only when addVisualData is true.
object
Visual layout:
default: the standard visual (248 × 122 pt).small: half the height of the standard visual (248 × 61 pt), with a smaller logo and a reduced set of data (no message rows, no dual-language labels). More visuals fit on a page.
Natural person data for the visual.
- Required when
addVisualDataistrueandsignatureTypeissign. ThenpinandpinCountryare required andnameSurnameis optional. - The data must match the signer’s certificate. The API compares it with the certificate when the signature is embedded, so that the visual shows the person who actually signed.
- Send it only when a visual is used.
object
Name and surname as in the certificate (and in the ID card or passport). Not case sensitive.
Personal identification number as in the certificate (in Croatia, the OIB). Not case sensitive.
Country code of the personal identification number, as in the certificate. Not case sensitive.
Legal person (organisation) data for the visual.
- Required when
addVisualDataistrueandsignatureTypeisseal. - Optional for a signature made for business purposes (
signwith a business certificate). - When sent,
vatandvatCountryare required;nameandsealNameare optional. - The data must match the certificate. The API compares it with the certificate when the signature is embedded.
object
Organisation name as in the register and in the certificate. Not case sensitive.
Organisation identification (VAT) number as in the certificate (in Croatia, the OIB). Not case sensitive.
Country code of the VAT number, as in the certificate. Not case sensitive.
Seal name, for an electronic seal certificate. Must be the same as in the certificate.
Documents to prepare. The number of documents per request is not limited, but the request size is (about 35 MB per request).
One document to prepare, with optional visual settings.
object
Verification code of this document, received from ePotpis when the transaction was created. Use each code for one document only.
The PDF to sign, Base64-encoded.
Optional friendly name of the document. Other components (for example the Certilia mobile app) show it to the user instead of a generic name. Returned in the responses.
Optional message in row 1 of the visual. At most 60 characters. Used only with the default visual
layout.
Optional message in row 2 of the visual. At most 60 characters. Used only with the default visual
layout.
Optional message in row 3 of the visual. At most 60 characters. Used only with the default visual
layout.
Page for the visual. Used only when addVisualData is true.
0 (default) is the last page. If all locations on it are taken, the API tries the previous page;
if no page has a free location, PreSign fails.
If the PDF has no electronic signatures yet, the API adds an A4 portrait blank page at the end when you
sign without a visual, or with a visual and pageNumber = 0 and pageLocation = 0. This keeps space
for the visuals of later signers.
Location of the visual on the page. Used only when addVisualData is true.
0 (default) is the first free location. Locations are numbered left to right, top to bottom. The
grid is calculated from the page size and the visual layout. On an A4 page:
| Page | default layout |
small layout |
|---|---|---|
| A4 portrait | 1–12 (2 columns × 6 rows) | 1–24 (2 × 12) |
| A4 landscape | 1–12 (3 columns × 4 rows) | 1–27 (3 × 9) |
If the location you set is taken, PreSign fails. The method for calculating the grid for any page size is in Annex A of the integration specification.
Examples
Signature with the default visual
{ "token": "<token from ePotpis>", "signatureFormat": "pades", "signatureType": "sign", "addVisualData": true, "personNaturalData": { "nameSurname": "Ivan Horvat", "pin": "00000000001", "pinCountry": "HR" }, "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "base64Document": "JVBERi0xLjcK...", "documentName": "Contract 2026-001.pdf", "firstRowMessage": "Signed in the Primjer d.o.o. web shop.", "secondRowMessage": "Order no. 2026-0001", "pageNumber": 1, "pageLocation": 5 } ]}Seal with the small visual
{ "token": "<token from ePotpis>", "signatureFormat": "pades", "signatureType": "seal", "addVisualData": true, "addVisualDataOptions": { "layoutId": "small" }, "personLegalData": { "name": "Primjer d.o.o.", "vat": "00000000002", "vatCountry": "HR", "sealName": "Accounting department" }, "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "base64Document": "JVBERi0xLjcK...", "documentName": "Invoice 2026-0001.pdf" } ]}Invisible signature, two documents
{ "token": "<token from ePotpis>", "signatureFormat": "pades", "signatureType": "sign", "addVisualData": false, "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "base64Document": "JVBERi0xLjcK..." }, { "verificationCode": "00000000-0000-0000-0000-000000000002", "base64Document": "JVBERi0xLjcK..." } ]}Responses
Odjeljak „Responses”The hash of each prepared document.
PreSign response.
object
EPotpis transaction token, the same as in the request.
One entry per prepared document.
One prepared document.
object
Verification code, the same as in the request.
Hash of the prepared document, hex-encoded. Send it unchanged to ePotpis for signing, and send it again in the PostSign request.
Document name, as sent in the request.
Document type. pdf for PAdES.
Example
{ "token": "<token from ePotpis>", "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "hash": "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF", "documentName": "Contract 2026-001.pdf", "mimeType": "pdf" } ]}The request contains invalid values, or another error occurred during PreSign.
All error codes are listed by GET /pades/errors.
Error response.
object
Error details.
object
Trace identifier, if the response has one. Send it to support when you report a problem.
Error type, the group the error belongs to.
Error code. The first digit is the API code (6 for this API); the remaining digits are the error
number. Example: 65 is error 5 of API 6.
HTTP status code.
Public error name.
Error description, in Croatian. If a required field is missing from the request, type and code are
empty, message is ERROR, and this field lists the missing fields in English (for example
The Token field is required.).
Additional information about the error.
Language of description.
Public error name, the same as message (kept for compatibility).
Example
{ "error": { "type": "HPDF_DOCUMENT_SECURITY_ERROR", "code": "6203", "message": "PDF_PASSWORD_PROTECTED", "description": "Pdf dokument je zaštićen zaporkom." }}