Skip to content

Electronic Signature ​

Integrate with an AI assistant
Download or copy the integration prompt for Electronic Signature and paste it into Claude Code, Cursor or Copilot: it contains auth, end-to-end examples and a checklist.
Open

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 URLhttps://api.dokicasa.it
AuthAuthorization: Bearer <api_token>
HeaderAccept: application/json (without it, errors are not returned as JSON)
Content-Typeapplication/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 ​

  1. Optional: check the PDF with check-pdf and get a suggestion on where to sign with detect-fields.
  2. Create the procedure with POST /api/signature. Also pass the webhook_url if you want to receive events.
  3. If the procedure is born CREATED, activate it with unlock.
  4. 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 in members[].signature_link.
  5. You receive the events or read the procedure again.
  6. With the FINISHED status you download the signed PDFs and the audit trail.

Prerequisites ​

  1. Active price list for the DIGITAL_SIGNATURE type on your account: without it, activation returns 403 PARTNER_PRICING_REQUIRED. Contact us to enable it.
  2. Enough credit: an active signature consumes one signature credit, if you have one, otherwise the price list price from the wallet. See Costs.
  3. 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

json
{
  "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 ​

FieldTypeReq.What it does
procedure_namestringyesName of the procedure (maximum 125 characters).
ordered_signersbooleanyestrue: signing happens one at a time in the order of members. With qualified signature it is always true.
need_to_send_emailsbooleanyestrue: we send the links to the signers and the progress emails. false: you send the links.
documentsarrayyesThe PDFs to sign (below).
membersarrayyesSigners and approvers (below).
notification_emailsarray of emailsnoThey receive the progress emails and the final one with the signed documents.
webhook_urlhttps URLnoWhere to send you the events. Public addresses only.
sealsarraynoSeals to apply once signing is complete.
practice_idintegernoOne of your DokiCasa practices to link the signature to. If it is not yours: 422 PRACTICE_NOT_ALLOWED.

documents[] ​

FieldReq.Notes
document_idyesAn id chosen by you, unique within the request: fields and seals use it to say which document they refer to.
nameyesFile name.
content_typeyesAlways application/pdf.
file_contentyesThe 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[] ​

FieldReq.Notes
first_name, last_nameyes
emailyesMust be valid: the OTP code is sent there.
phonenoInternational format (+39...). Required with otp_sms.
typeyessigner (signs) or approver (approves without signing).
signature_levelyesSee signature levels. Also for approvers.
signature_authentication_modenootp_email, otp_sms, no_otp.
fieldsyes for signerWhere they sign on the documents (below).
save_membernotrue: saves the signer among your signing contacts.

All members must have the same signature_level, otherwise 422.

Signature levels ​

signature_levelSignatureWhen to use it
electronic_signatureSimple (FES)Documents with no formal requirements.
advanced_electronic_signatureAdvanced (FEA)Contracts, with OTP via SMS or email.
qualified_electronic_signatureQualified (FEQ)Equivalent to a handwritten signature. The signer identifies themselves with a document; signers sign in order.

fields[]: where to sign ​

FieldNotes
document_idOne of the documents[].document_id.
typesignature (signature box) or text (text to fill in).
pagePage, counting from 1.
x, yTop-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, heightSize of the box in points. 108 × 45 works well for a signature.
show_signature_datesignature only: adds name and date below the signature. Use a larger box, at least 170 × 74.
text_contenttext only: the question shown to the signer (maximum 40 characters of answer).
is_mandatorytext 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.

json
{
  "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
    }
  ]
}
  • id is the DokiCasa id of the procedure: all the other calls use it.
  • data.documents[].yousign_id is needed to download the signed PDF.
  • members[].yousign_id identifies the signer in events and in the other calls.
  • signature_link is the provider's signing link; dokicasa_signature_link opens 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 with new-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:

json
{ "redirect_link": "/contract-signature/thankyou?procedure_id=17620" }
OutcomeResponse
No price list for signature403 { "error": "PARTNER_PRICING_REQUIRED", "scanner_type": "DIGITAL_SIGNATURE" }
Insufficient wallet400 { "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:

FieldWhat it tells you
statusWhere the procedure stands: see below.
members[].statusThe signer: pending (still has to sign) or done (has signed or approved).
members[].can_signWhether they can sign now (with ordered_signers signing happens one at a time).
members[].identification_issueWith 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 ​

statusMeaning
CREATEDCreated but not active: it must be activated with unlock.
SIGN_SENTActive: signers can sign.
SIGN_STARTEDAt least one signer has signed or approved.
FINISHEDEveryone 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.

eventWhen
signature.activatedThe procedure is active and the signing links are ready.
signer.signedA signer has signed. In member you find who.
approver.approvedAn approver has approved.
signer.identification_succeededQualified signature: the signer has identified themselves.
signer.issueQualified signature: identification failed or was blocked, or a signer error. In issue.type: IDENTIFICATION_FAILED, IDENTIFICATION_BLOCKED, SIGNER_ERROR.
signature.finishedEveryone has signed and the signed PDFs are ready to download.
signature.declinedA signer has declined to sign.
signature.expiredThe procedure expired without all the signatures.
signature.canceledThe procedure was canceled by the provider.
signature.deletedThe procedure was canceled by you or by your account.

The body ​

json
{
  "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
  }
}
  • member is present only in events about a signer; in the others it is null.
  • issue is present only in signer.issue.
  • members[].id is the same yousign_id as 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.

php
$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;
}
js
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.

json
{
  "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.

json
{ "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.

json
"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.

ResponseMeaning
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:

json
{
  "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.

reasonMeaning
DETECTEDThere are suggestions.
NO_ANCHORSThe PDF has text, but no signature label was recognized.
NO_TEXTIt is a scan: position the fields by hand.
UNREADABLEThe file cannot be read.

If the signature provider does not respond ​

GET /api/signature-status (public) tells you whether the provider is reachable:

json
{ "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:

json
{ "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}

json
{ "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 ​

HTTPerrorCause
401Missing or invalid token.
403ORIGIN_NOT_ALLOWEDThe origin of the call is not among those authorized for your account.
403PARTNER_PRICING_REQUIREDNo price list for signature (at activation).
403Non autorizzatoThe procedure is not yours.
400AMOUNT_NOT_ENOUGHInsufficient wallet (at activation).
404Nonexistent or canceled procedure.
422Validation: errors lists the wrong fields (same signature level for everyone, email, phone...).
422PRACTICE_NOT_ALLOWEDpractice_id is not one of your practices.
422Editable PDF, unreadable PDF or pages of different formats: the explanation is in message.
422YOUSIGN_QUEUEDProvider not reachable: request put in the queue.
503YOUSIGN_UNAVAILABLEProvider not reachable and queue not available: try again later.

Every 422 also has message, a ready-made sentence to show to the user.