# Qualified electronic signatures

A **qualified electronic signature** (QES) under the EU eIDAS regulation has the legal effect of a
handwritten signature across the EU. It must be created with a qualified certificate issued to the
signer by a qualified trust service provider (TSP). Sign API doesn't issue those certificates:
you connect the provider you already use through a **signing worker**, and Sign API runs the
ceremony, builds the PDF signature and seals the result.

Qualified signatures are enabled per account. Until yours is,
envelopes with qualified signers are refused with
[`qes_not_enabled`](https://docs.signapi.dev/errors/qes_not_enabled); ask support to turn them on.

## How it works

1. You create an envelope with a `qualified_signer` recipient.
2. The signer reviews the documents in the ceremony and selects **Sign with your provider**.
3. Sign API prepares the PDF and asks your signing worker for a credential, then an
   authorization. The worker may send the signer to the provider to confirm their identity or
   approve the signature (in the browser or in the provider's app).
4. The worker returns the signature. Sign API adds a time-stamp and validation data, embeds it in
   the PDF and moves on to the next recipient.

Each qualified signature is added as a new revision of the PDF, so later signatures cover the
earlier ones and none of them is broken.

## Connect a signing worker

A signing worker is a small HTTPS service that speaks the Signing Worker Protocol (SWP/1) and
talks to your TSP. In the dashboard, open **Settings → Qualified signatures**:

1. Copy the account's connection token for the mode (test or live) and list it in your worker's
   health response.
2. Enter the worker's URL and select **Connect**. Sign API runs five checks: the URL (https on
   port 443, a public address), the health endpoint, the connection token, request
   authentication, and the static certificate if your worker uses one. Nothing is saved unless
   every check passes.
3. Run the checks again at any time with **Run checks**; replacing or disconnecting a worker is on
   the same page. Only account owners can change it.

In **test mode** you don't need a worker: when none is connected, Sign API's sandbox worker signs
with a test certificate. The ceremony then shows "Sandbox signature: not qualified", and the
signature has no legal value. Live mode always needs a connected worker
([`qes_worker_not_connected`](https://docs.signapi.dev/errors/qes_worker_not_connected)).

## Create an envelope

```json
{
  "title": "Share purchase agreement",
  "routing": "sequential",
  "documents": [
    {
      "key": "spa",
      "url": "https://api.signapi.lumin.example/v1/v1/uploads/upl_…",
      "places": [{ "key": "buyer_sig", "type": "signature", "recipient_key": "buyer" }]
    }
  ],
  "recipients": [
    { "type": "qualified_signer", "scheme": "eu_eidas", "key": "buyer",
      "name": "Alex Doe", "email": "alex@example.com" }
  ]
}
```

### Rules

Envelopes with qualified signers follow stricter rules, because a qualified signature fixes the
document's bytes:

| Rule | Error |
|---|---|
| `routing` is `sequential` | [`qes_routing_invalid`](https://docs.signapi.dev/errors/qes_routing_invalid) |
| No `signer` recipients alongside qualified signers | [`qes_mixed_signers`](https://docs.signapi.dev/errors/qes_mixed_signers) |
| Automatic signers only before the first qualified signer | [`qes_automatic_signer_invalid`](https://docs.signapi.dev/errors/qes_automatic_signer_invalid) |
| No `attestation` | [`qes_attestation_invalid`](https://docs.signapi.dev/errors/qes_attestation_invalid) |
| No deliverable password | [`qes_deliverable_encryption_invalid`](https://docs.signapi.dev/errors/qes_deliverable_encryption_invalid) |
| The deliverable includes every document | [`qes_deliverable_documents_invalid`](https://docs.signapi.dev/errors/qes_deliverable_documents_invalid) |
| Each qualified signer has exactly one place, a `signature` | [`qes_recipient_places_invalid`](https://docs.signapi.dev/errors/qes_recipient_places_invalid) |
| Input places only for the first recipient; others have only `signature` or `initials` places | [`qes_places_invalid`](https://docs.signapi.dev/errors/qes_places_invalid) |
| No `envelope_completed_date` place | [`qes_envelope_date_place_invalid`](https://docs.signapi.dev/errors/qes_envelope_date_place_invalid) |

The account checks (enabled, worker connected) run again just before the envelope is sent. If one
fails then, for example because the worker was disconnected, the envelope fails and the charge is
refunded.

## The deliverable

A `standard` deliverable becomes `simple`: there is no audit log, and the file is the PDF exactly
as the last qualified signer's signature left it, since any change would break the signatures.
Each signature carries its certificate chain, a time-stamp and revocation data, so it can be
validated for years (PAdES B-LT). Check one with the inspector on
[Verify a deliverable](https://docs.signapi.dev/verify), or with your national validation service for the qualified
status.

## When something goes wrong

If the provider refuses, the signer cancels at the provider, or the authorization window passes,
the ceremony shows what happened and offers **Try again**, which starts a new signing session.
While a signing session is open, the signer's values can't change, because the signature's
digest already covers them.
