Electronic Signature
Has one or more PDFs signed by one or more signers, with simple, advanced or qualified electronic signature. The procedure goes through our signature provider (Yousign): you send the documents, the signers and where to sign, and we create the procedure, send the links (if you want) and notify you at every step. It is the same function customers use from their personal area.
| Base URL | https://api.dokicasa.it |
| Auth | Authorization: Bearer <api_token> |
| Header | Accept: application/json (without it, errors are not returned as JSON) |
| Content-Type | application/json (creation), multipart/form-data (PDF checks) |
Creation is synchronous: when it responds, the procedure exists and the signing links are ready. Signatures, instead, arrive when the signers sign: to find out you use the webhook or read the procedure again.
WARNING
In production every procedure is real: it has legal value and is billed. For testing use the sandbox environment https://api-dev.dokicasa.it, where signatures go through the test Yousign and have no value. The events webhook is currently active in production only.
The flow in brief
- Optional: check the PDF with
check-pdfand get a suggestion on where to sign withdetect-fields. - Create the procedure with
POST /api/signature. Also pass thewebhook_urlif you want to receive events. - If the procedure is born
CREATED, activate it withunlock. - Signers receive the link from us (
need_to_send_emails: true) or you send it to them (need_to_send_emails: false): you find it inmembers[].signature_link. - You receive the events or read the procedure again.
- With the
FINISHEDstatus you download the signed PDFs and the audit trail.
Prerequisites
- Active price list for the
DIGITAL_SIGNATUREtype on your account: without it, activation returns403 PARTNER_PRICING_REQUIRED. Contact us to enable it. - Enough credit: an active signature consumes one signature credit, if you have one, otherwise the price list price from the wallet. See Costs.
- Non-editable PDFs: PDFs with fillable fields are rejected, because they could be changed after signing. Export them "flattened" (print to PDF).
Create a procedure
POST /api/signature
{
"procedure_name": "Contratto di locazione Via Roma 10",
"ordered_signers": false,
"need_to_send_emails": false,
"notification_emails": ["ufficio@tuaagenzia.it"],
"webhook_url": "https://tuo-server.it/dokicasa/firma",
"documents": [
{
"document_id": "contratto",
"name": "Contratto.pdf",
"content_type": "application/pdf",
"file_content": "JVBERi0xLjQK..."
}
],
"members": [
{
"first_name": "Mario",
"last_name": "Rossi",
"email": "mario.rossi@example.com",
"phone": "+393331234567",
"type": "signer",
"signature_level": "electronic_signature",
"signature_authentication_mode": "otp_email",
"save_member": false,
"fields": [
{ "document_id": "contratto", "type": "signature", "page": 3, "x": 63, "y": 616, "width": 108, "height": 45 }
]
}
]
}Procedure fields
| Field | Type | Req. | What it does |
|---|---|---|---|
procedure_name | string | yes | Name of the procedure (maximum 125 characters). |
ordered_signers | boolean | yes | true: signing happens one at a time in the order of members. With qualified signature it is always true. |
need_to_send_emails | boolean | yes | true: we send the links to the signers and the progress emails. false: you send the links. |
documents | array | yes | The PDFs to sign (below). |
members | array | yes | Signers and approvers (below). |
notification_emails | array of emails | no | They receive the progress emails and the final one with the signed documents. |
webhook_url | https URL | no | Where to send you the events. Public addresses only. |
seals | array | no | Seals to apply once signing is complete. |
practice_id | integer | no | One of your DokiCasa practices to link the signature to. If it is not yours: 422 PRACTICE_NOT_ALLOWED. |
documents[]
| Field | Req. | Notes |
|---|---|---|
document_id | yes | An id chosen by you, unique within the request: fields and seals use it to say which document they refer to. |
name | yes | File name. |
content_type | yes | Always application/pdf. |
file_content | yes | The PDF in base64. The data:application/pdf;base64, prefix is accepted. |
All pages of the same document must have the same format (for example all A4): with mixed A4 and A3 pages the provider rejects the file.
members[]
| Field | Req. | Notes |
|---|---|---|
first_name, last_name | yes | |
email | yes | Must be valid: the OTP code is sent there. |
phone | no | International format (+39...). Required with otp_sms. |
type | yes | signer (signs) or approver (approves without signing). |
signature_level | yes | See signature levels. Also for approvers. |
signature_authentication_mode | no | otp_email, otp_sms, no_otp. |
fields | yes for signer | Where they sign on the documents (below). |
save_member | no | true: saves the signer among your signing contacts. |
All members must have the same signature_level, otherwise 422.
Signature levels
signature_level | Signature | When to use it |
|---|---|---|
electronic_signature | Simple (FES) | Documents with no formal requirements. |
advanced_electronic_signature | Advanced (FEA) | Contracts, with OTP via SMS or email. |
qualified_electronic_signature | Qualified (FEQ) | Equivalent to a handwritten signature. The signer identifies themselves with a document; signers sign in order. |
fields[]: where to sign
| Field | Notes |
|---|---|
document_id | One of the documents[].document_id. |
type | signature (signature box) or text (text to fill in). |
page | Page, counting from 1. |
x, y | Top-left corner of the box, in PDF points (1/72 of an inch) from the top-left corner of the page. An A4 page is 595 × 842. |
width, height | Size of the box in points. 108 × 45 works well for a signature. |
show_signature_date | signature only: adds name and date below the signature. Use a larger box, at least 170 × 74. |
text_content | text only: the question shown to the signer (maximum 40 characters of answer). |
is_mandatory | text only: false for an optional field. |
If you do not know where to sign, ask detect-fields for a suggestion.
Response: 201 Created
The newly created procedure. The most important field is status; in members you find the signing links.
{
"id": 17620,
"name": "Contratto di locazione Via Roma 10",
"status": "SIGN_SENT",
"procedure_id": "6b0c4c2e-6a7d-4d0e-9a55-1c2f3b4d5e6f",
"need_to_send_emails": false,
"source_practice_id": null,
"data": {
"procedure_name": "Contratto di locazione Via Roma 10",
"ordered_signers": false,
"documents": [
{ "document_id": "contratto", "name": "Contratto.pdf", "content_type": "application/pdf", "yousign_id": "850fa268-2d39-4307-8a55-93cd1a2a4ef6" }
]
},
"members": [
{
"yousign_id": "cfa2a4e2-5a98-4fa2-aa91-3c3ad754f453",
"firstname": "Mario",
"lastname": "Rossi",
"email": "mario.rossi@example.com",
"type": "signer",
"position": 1,
"status": "pending",
"can_sign": true,
"operation_level": "electronic_signature",
"otp_type": "otp_email",
"signature_link": "https://yousign.app/signatures/...",
"signature_link_expiration_date": "2026-11-12T18:27:40+00:00",
"dokicasa_signature_link": "https://app.dokicasa.it/app/firma-documento/17620/cfa2a4e2-...",
"identification_issue": null
}
]
}idis the DokiCasa id of the procedure: all the other calls use it.data.documents[].yousign_idis needed to download the signed PDF.members[].yousign_ididentifies the signer in events and in the other calls.signature_linkis the provider's signing link;dokicasa_signature_linkopens the same signature inside a DokiCasa page (with your logo, if you have one). Send one of the two. The link expires after a few days: if needed, ask for a new one withnew-link.
Costs and activation
- If you have a signature credit, the procedure starts right away:
status: "SIGN_SENT". - Otherwise it is born
CREATED: it exists, but signers cannot sign yet. Activate it with:
POST /api/signature/{id}/unlock
Activation charges the price of your DIGITAL_SIGNATURE price list from the wallet and responds 201:
{ "redirect_link": "/contract-signature/thankyou?procedure_id=17620" }| Outcome | Response |
|---|---|
| No price list for signature | 403 { "error": "PARTNER_PRICING_REQUIRED", "scanner_type": "DIGITAL_SIGNATURE" } |
| Insufficient wallet | 400 { "error": "AMOUNT_NOT_ENOUGH", "missing_amount", "wallet_balance", "total_amount", "checkout_link" } |
The charge happens only once, when the procedure is activated. If you cancel a procedure before any signature, the signature credit becomes available again; an amount paid from the wallet is not refunded automatically.
Read a procedure
GET /api/signature/{id}
Responds with the procedure in the same shape as creation. Only the owner can read it: with the token of another account it responds 403, with a nonexistent or canceled id 404.
What to look at:
| Field | What it tells you |
|---|---|
status | Where the procedure stands: see below. |
members[].status | The signer: pending (still has to sign) or done (has signed or approved). |
members[].can_sign | Whether they can sign now (with ordered_signers signing happens one at a time). |
members[].identification_issue | With qualified signature: why identification failed, already explained in Italian. |
Reading again does not call the signature provider and has no cost. If you do not use the webhook, read again every few minutes, no more often.
Procedure statuses
status | Meaning |
|---|---|
CREATED | Created but not active: it must be activated with unlock. |
SIGN_SENT | Active: signers can sign. |
SIGN_STARTED | At least one signer has signed or approved. |
FINISHED | Everyone has signed: the signed (and possibly sealed) PDFs are ready. |
A canceled procedure has no status: it ceases to exist (404).
Events webhook
Recommended for backend integrations
Pass webhook_url at creation: for every event of the procedure we send you a signed POST. It is the same mechanism as the Market Scanner webhooks, with the same verification.
event | When |
|---|---|
signature.activated | The procedure is active and the signing links are ready. |
signer.signed | A signer has signed. In member you find who. |
approver.approved | An approver has approved. |
signer.identification_succeeded | Qualified signature: the signer has identified themselves. |
signer.issue | Qualified signature: identification failed or was blocked, or a signer error. In issue.type: IDENTIFICATION_FAILED, IDENTIFICATION_BLOCKED, SIGNER_ERROR. |
signature.finished | Everyone has signed and the signed PDFs are ready to download. |
signature.declined | A signer has declined to sign. |
signature.expired | The procedure expired without all the signatures. |
signature.canceled | The procedure was canceled by the provider. |
signature.deleted | The procedure was canceled by you or by your account. |
The body
{
"event": "signer.signed",
"occurred_at": "2026-11-05T18:40:12+01:00",
"signature": {
"id": 17620,
"name": "Contratto di locazione Via Roma 10",
"status": "SIGN_STARTED",
"procedure_id": "6b0c4c2e-6a7d-4d0e-9a55-1c2f3b4d5e6f",
"practice_id": null,
"deleted": false,
"members": [
{
"id": "cfa2a4e2-5a98-4fa2-aa91-3c3ad754f453",
"type": "signer",
"first_name": "Mario",
"last_name": "Rossi",
"email": "mario.rossi@example.com",
"status": "done",
"can_sign": false,
"identification_issue": null
}
],
"documents": [
{ "document_id": "contratto", "name": "Contratto.pdf", "yousign_id": "850fa268-2d39-4307-8a55-93cd1a2a4ef6" }
]
},
"member": {
"id": "cfa2a4e2-5a98-4fa2-aa91-3c3ad754f453",
"type": "signer",
"first_name": "Mario",
"last_name": "Rossi",
"email": "mario.rossi@example.com",
"status": "done",
"can_sign": false,
"identification_issue": null
}
}memberis present only in events about a signer; in the others it isnull.issueis present only insigner.issue.members[].idis the sameyousign_idas at creation. Signing links are not in the webhook: they are personal.
Verify the signature
Every webhook has the Signature header: the HMAC-SHA256 of the raw body, signed with your api_token, the same one you use as Bearer.
$raw = file_get_contents('php://input');
$expected = hash_hmac('sha256', $raw, $MY_API_TOKEN);
if (!hash_equals($expected, $_SERVER['HTTP_SIGNATURE'] ?? '')) {
http_response_code(401);
exit;
}app.post('/dokicasa/firma', express.raw({ type: 'application/json' }), (req, res) => {
const expected = crypto.createHmac('sha256', MY_API_TOKEN).update(req.body).digest('hex')
if (expected !== req.get('Signature')) return res.sendStatus(401)
const event = JSON.parse(req.body)
res.sendStatus(200)
})NOTE
Respond 2xx right away and process the event afterwards. The same event can arrive twice: use signature.id + event + member.id to recognize duplicates. If a webhook does not reach you, the procedure can still be read with GET.
Download the signed documents
With the FINISHED status:
GET /api/signature/{id}/documents/{yousign_id}/signed-pdf
{yousign_id} is data.documents[].yousign_id. Responds with the PDF. If the procedure has seals, it is already the sealed PDF.
GET /api/signature/{id}/members/{member_yousign_id}/audit-trail
The signer's audit trail as a PDF: who signed, when, with what verification.
GET /api/signature/{id}/documents
The procedure's documents as the provider sees them (id, filename, total_pages, is_signed...).
Manage signers
PATCH /api/signature/{id}/signers/{member_yousign_id}
Corrects the data of a signer who has not signed yet. All fields are optional: send only the ones to change. Responds 204.
{
"info": { "first_name": "Mario", "last_name": "Rossi", "email": "mario.rossi@nuovo.it", "phone_number": "+393331234567" },
"signature_authentication_mode": "otp_sms"
}Here the no-OTP mode is called none (at creation it is no_otp). If you change signature_level, the same rule applies: all members with the same level.
POST /api/signature/{id}/signers/{member_yousign_id}/new-link
Regenerates an expired signing link. No token is needed: it is the call made by the signer's page. At most 5 per minute.
{ "signature_link": "https://yousign.app/signatures/...", "signature_link_expiration_date": "2026-11-19T10:00:00+00:00", "reminder_sent": false }Cancel a procedure
DELETE /api/signature/{id}
Cancels the procedure with the provider and in DokiCasa. Responds 204 and sends the event signature.deleted. Afterwards, the procedure can no longer be read (404).
Seals
You can apply your seals to the documents, once everyone has signed. The seal id is the one from GET /api/users/me/seals.
"seals": [
{ "id": 42, "document_id": "contratto", "page": 3, "x": 400, "y": 700, "width": 92, "height": 38 }
]Coordinates follow the same rules as the signature fields. The PDF you download with signed-pdf is already sealed.
PDF tools
Can the PDF be signed?
POST /api/signature/check-pdf, multipart with file.
| Response | Meaning |
|---|---|
200 { "editable": false } | All good. |
422 { "editable": true, "message": "..." } | It has fillable fields: it must be flattened. |
Where to sign?
POST /api/signature/detect-fields, multipart with file and roles[]: the role of each signer in the order of members (locatore, conduttore or empty). At most 60 per minute.
It reads the PDF text and looks for signature labels ("Il Locatore", "Firma del conduttore", "Firma"...). Responds with the positions already in the fields format:
{
"fields": [
{ "signer_index": 0, "page": 1, "x": 63, "y": 616, "width": 108, "height": 45, "label": "Il Locatore" },
{ "signer_index": 1, "page": 1, "x": 383, "y": 616, "width": 108, "height": 45, "label": "Il Conduttore" }
],
"reason": "DETECTED"
}signer_index is the signer's position in roles[]. It is a suggestion: have the user confirm it before creating the procedure.
reason | Meaning |
|---|---|
DETECTED | There are suggestions. |
NO_ANCHORS | The PDF has text, but no signature label was recognized. |
NO_TEXT | It is a scan: position the fields by hand. |
UNREADABLE | The file cannot be read. |
If the signature provider does not respond
GET /api/signature-status (public) tells you whether the provider is reachable:
{ "yousign_available": true }If it is not, the creation is not lost: we put it in a queue and retry it ourselves every 10 minutes, for 24 hours. You receive:
{ "error": "YOUSIGN_QUEUED", "queued": true, "queue_id": 812, "message": "..." }with code 422. Do not resend the same request: follow the queue with
GET /api/signature-queue/{queue_id}
{ "id": 812, "status": "sent", "signature_id": 17620, "created_at": "2026-11-05T18:00:00+01:00" }status: pending, processing, sent (in signature_id you find the procedure), failed.
Errors
| HTTP | error | Cause |
|---|---|---|
401 | Missing or invalid token. | |
403 | ORIGIN_NOT_ALLOWED | The origin of the call is not among those authorized for your account. |
403 | PARTNER_PRICING_REQUIRED | No price list for signature (at activation). |
403 | Non autorizzato | The procedure is not yours. |
400 | AMOUNT_NOT_ENOUGH | Insufficient wallet (at activation). |
404 | Nonexistent or canceled procedure. | |
422 | Validation: errors lists the wrong fields (same signature level for everyone, email, phone...). | |
422 | PRACTICE_NOT_ALLOWED | practice_id is not one of your practices. |
422 | Editable PDF, unreadable PDF or pages of different formats: the explanation is in message. | |
422 | YOUSIGN_QUEUED | Provider not reachable: request put in the queue. |
503 | YOUSIGN_UNAVAILABLE | Provider not reachable and queue not available: try again later. |
Every 422 also has message, a ready-made sentence to show to the user.