Prepare XML and calculate hash (PreSign)
const url = 'https://api.test.certilia.com/xades/v1';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"token":"<token from ePotpis>","signatureFormat":"xades","signatureType":"sign","addVisualData":true,"personNaturalData":{"nameSurname":"Ivan Horvat","pin":"00000000001","pinCountry":"HR"},"documents":[{"verificationCode":"00000000-0000-0000-0000-000000000001","base64Document":"PD94bWwgdmVyc2lvbj0iMS4wIj8+..."}]}'};
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/xades/v1 \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "token": "<token from ePotpis>", "signatureFormat": "xades", "signatureType": "sign", "addVisualData": true, "personNaturalData": { "nameSurname": "Ivan Horvat", "pin": "00000000001", "pinCountry": "HR" }, "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "base64Document": "PD94bWwgdmVyc2lvbj0iMS4wIj8+..." } ] }'Prepares each XML document for signing and returns the hash to be signed in ePotpis.
- One request holds the ePotpis transaction
tokenand one or more documents, each with theverificationCodethat ePotpis issued for it. signatureFormatisxades.
Authorizations
Odjeljak „Authorizations”Request Bodyrequired
Odjeljak „Request Bodyrequired”PreSign request: the ePotpis transaction token, the signer data and the documents.
object
EPotpis transaction token, received from ePotpis (the eSign solution) when the transaction was created. One token per transaction; a transaction can hold one or more documents.
Signature format, xades.
Signature type, the same as signingData.signatureType in the ePotpis transaction:
sign: electronic signature.seal: electronic seal.
true adds an XML comment with data about the signature to the signature element: the signer and their
identification number from personNaturalData, the signing time, the verification link, the record
number (the verification code) and the message rows from documents[]. false leaves it out.
Natural person data.
object
Name and surname of the natural person, as written in the certificate.
Personal identification number of the natural person (in Croatia, the OIB).
Country code of the personal identification number.
Legal person (organisation) data.
object
Organisation name.
Organisation identification (VAT) number (in Croatia, the OIB).
Country code of the VAT number.
Seal name, for an electronic seal certificate.
Documents to prepare.
One XML document to prepare.
object
Verification code of this document, received from ePotpis when the transaction was created. Use each code for one document only.
The XML document to sign, Base64-encoded.
Optional message, row 1. The same field as in the PAdES web API, where it is a row of the visual.
Optional message, row 2. The same field as in the PAdES web API, where it is a row of the visual.
Optional message, row 3. The same field as in the PAdES web API, where it is a row of the visual.
Example
{ "token": "<token from ePotpis>", "signatureFormat": "xades", "signatureType": "sign", "addVisualData": true, "personNaturalData": { "nameSurname": "Ivan Horvat", "pin": "00000000001", "pinCountry": "HR" }, "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "base64Document": "PD94bWwgdmVyc2lvbj0iMS4wIj8+..." } ]}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 (96 hexadecimal characters). Send it unchanged to ePotpis for signing, and send it again in the PostSign request.
Document type, xml.
Example
{ "token": "<token from ePotpis>", "documents": [ { "verificationCode": "00000000-0000-0000-0000-000000000001", "hash": "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF", "mimeType": "xml" } ]}The request contains invalid values, or another error occurred during PreSign.
Error response.
object
Error details.
object
Error type, the group the error belongs to.
Error code. The first character identifies the API (7 for XAdES), the rest is the error number.
Public error name. Rely on code or message in your code, not on description.
Error description.
Example
{ "error": { "type": "HG_GENERAL_ERROR", "code": "7111", "message": "POSTSIGN_BUILD_ERROR", "description": "Postsign error." }}