Preskoči na sadržaj

Prepare PDF and calculate hash (PreSign)

POST
/pades/v2
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.
Media typeapplication/json

PreSign request: the ePotpis transaction data, the signer data for the visual (if one is used) and the documents.

object
token
required

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.

string
>= 1 characters
signatureFormat
required

Signature format. Always pades.

string
Allowed values: pades
signatureType
required
  • 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.
string
Allowed values: sign seal
addVisualData
required

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).

boolean
addVisualDataOptions

Options for the visual. Used only when addVisualData is true.

object
layoutId

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.
string
default: default nullable
personNaturalData

Natural person data for the visual.

  • Required when addVisualData is true and signatureType is sign. Then pin and pinCountry are required and nameSurname is 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
nameSurname

Name and surname as in the certificate (and in the ID card or passport). Not case sensitive.

string
nullable
pin

Personal identification number as in the certificate (in Croatia, the OIB). Not case sensitive.

string
nullable
pinCountry

Country code of the personal identification number, as in the certificate. Not case sensitive.

string
nullable
personLegalData

Legal person (organisation) data for the visual.

  • Required when addVisualData is true and signatureType is seal.
  • Optional for a signature made for business purposes (sign with a business certificate).
  • When sent, vat and vatCountry are required; name and sealName are optional.
  • The data must match the certificate. The API compares it with the certificate when the signature is embedded.
object
name

Organisation name as in the register and in the certificate. Not case sensitive.

string
nullable
vat

Organisation identification (VAT) number as in the certificate (in Croatia, the OIB). Not case sensitive.

string
nullable
vatCountry

Country code of the VAT number, as in the certificate. Not case sensitive.

string
nullable
sealName

Seal name, for an electronic seal certificate. Must be the same as in the certificate.

string
nullable
documents
required

Documents to prepare. The number of documents per request is not limited, but the request size is (about 35 MB per request).

Array<object>

One document to prepare, with optional visual settings.

object
verificationCode
required

Verification code of this document, received from ePotpis when the transaction was created. Use each code for one document only.

string
>= 1 characters
base64Document
required

The PDF to sign, Base64-encoded.

string
>= 1 characters
documentName

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.

string
nullable
firstRowMessage

Optional message in row 1 of the visual. At most 60 characters. Used only with the default visual layout.

string
nullable
secondRowMessage

Optional message in row 2 of the visual. At most 60 characters. Used only with the default visual layout.

string
nullable
thirdRowMessage

Optional message in row 3 of the visual. At most 60 characters. Used only with the default visual layout.

string
nullable
pageNumber

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.

integer format: int32
0
pageLocation

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.

integer format: int32
0

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
}
]
}

The hash of each prepared document.

Media typeapplication/json

PreSign response.

object
token
required

EPotpis transaction token, the same as in the request.

string
>= 1 characters
documents
required

One entry per prepared document.

Array<object>

One prepared document.

object
verificationCode
required

Verification code, the same as in the request.

string
>= 1 characters
hash
required

Hash of the prepared document, hex-encoded. Send it unchanged to ePotpis for signing, and send it again in the PostSign request.

string
>= 1 characters
documentName

Document name, as sent in the request.

string
nullable
mimeType
required

Document type. pdf for PAdES.

string
>= 1 characters

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.

Media typeapplication/json

Error response.

object
error

Error details.

object
traceId

Trace identifier, if the response has one. Send it to support when you report a problem.

string
nullable
type

Error type, the group the error belongs to.

string
nullable
code

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.

string
nullable
status

HTTP status code.

integer format: int32
message

Public error name.

string
nullable
description

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.).

string
nullable
info

Additional information about the error.

string
nullable
language

Language of description.

string
nullable
name

Public error name, the same as message (kept for compatibility).

string
nullable

Example

{
"error": {
"type": "HPDF_DOCUMENT_SECURITY_ERROR",
"code": "6203",
"message": "PDF_PASSWORD_PROTECTED",
"description": "Pdf dokument je zaštićen zaporkom."
}
}