---
title: "Recipe: one-shot certificate"
description: "A signing worker for a provider that identifies the signer, issues a certificate for one signature and returns a complete CMS signature, with the cms signature format"
canonical: "https://signatureapi.com/docs/qualified-signatures/recipes/one-shot-cms"
source: "https://signatureapi.com/docs/qualified-signatures/recipes/one-shot-cms.md"
last_verified_api_version: "1.18.1"
last_modified: "2026-11-18T16:06:16Z"
---

# Recipe: one-shot certificate

A signing worker for a provider that identifies the signer, issues a certificate for one signature and returns a complete CMS signature, with the cms signature format

_Last verified against API version 1.18.1._

> **Note:** **Public beta.** Qualified signatures are available on request, with any qualified trust service provider you choose and at no extra charge during the beta. See [Request access](https://signatureapi.com/docs/qualified-signatures#request-access). SWP/1 is in beta and may change.

This recipe fits a provider that:

- has **no certificate** for the signer before they sign,
- **identifies the signer** in its own flow, for example with an identity document and a selfie, a video call or a national eID,
- **issues a one-shot certificate**, valid for minutes, and signs with it, and
- returns a **complete CMS signature** over a hash.

With the `cms` [signature format](https://signatureapi.com/docs/qualified-signatures/signing-worker-protocol/signature-formats), SignatureAPI doesn't need the certificate until `sign`. So the whole provider flow, identification, issuance and approval, fits in one `authorize` interaction. The signer leaves the ceremony once. Not sure this is your provider? See [Choose your provider's model](https://signatureapi.com/docs/qualified-signatures/worker-models).

## The flow

### Format and approval request

**One-shot certificate with cms, part 1: only the hash leaves SignatureAPI**

Participants: Signer's browser, SignatureAPI, Your worker, Provider.

1. **Signer's browser** to **SignatureAPI**: Finish the ceremony
2. **SignatureAPI** to **Your worker**: `POST /v1/credential`
3. **Your worker** to **SignatureAPI**: `completed` with `id` and `"signature_format": "cms"`
4. **SignatureAPI**: Reserve space, compute the byte-range digest
   The document never leaves SignatureAPI. From here on, the worker and the provider work with its SHA-256 digest only.
5. **SignatureAPI** to **Your worker**: `POST /v1/authorize` with the digest and its `label`
   The `label` is the envelope title, so the signer knows what they approve.

   ```json
   {
       "credential_id": "sgs_YFobK1NDktAuz0wzplR4OP",
       "digests": [
           {
               "value": "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=",
               "hash_algorithm_oid": "2.16.840.1.101.3.4.2.1",
               "label": "Service Agreement"
           }
       ]
   }
   ```
6. **Your worker** to **Provider**: Start a signing request for the hash
7. **Provider** to **Your worker**: Hosted page URL
8. **Your worker** to **SignatureAPI**: `pending` with the provider's page as `action_url`

### Identification and approval

**One-shot certificate with cms, part 2: the signer identifies and approves at the provider**

Participants: Signer's browser, SignatureAPI, Your worker, Provider.

1. **SignatureAPI** to **Signer's browser**: **Authorize your signature**, then redirect
2. **Signer's browser** to **Provider**: Identify, review, approve
   The provider issues a one-shot certificate for this signature.
3. **Provider** to **Signer's browser**: Redirect to your worker's return page
4. **Your worker** to **Signer's browser**: Redirect to `callback_url` with a single-use `code`
5. **Signer's browser** to **SignatureAPI**: `GET callback_url`
6. **SignatureAPI** to **Your worker**: `POST /v1/authorize` with `callback.code`
7. **Your worker** to **SignatureAPI**: `completed` with an authorization reference

### Signing

**One-shot certificate with cms, part 3: the CMS and the chain**

Participants: SignatureAPI, Your worker, Provider.

1. **SignatureAPI** to **Your worker**: `POST /v1/sign` with `"signature_format": "cms"`
   The same digest again, without the `label`.
2. **Your worker** to **Provider**: Get the signature
3. **Provider** to **Your worker**: CMS and certificate chain
4. **Your worker** to **SignatureAPI**: `completed` with `signatures` and `certificates`
5. **SignatureAPI**: Check the CMS, replace the timestamp, embed in the PDF

Your provider's API decides where the signing act happens. Some sign as soon as the signer approves, and your worker only collects the result in `sign`. Others wait for an explicit "sign" call. Either fits: `sign` is where you return the result.

## 1. `credential`: declare the format

There is no certificate yet, so answer with an ID and the format:

```json
{
    "status": "completed",
    "credential": {
        "id": "sgs_YFobK1NDktAuz0wzplR4OP",
        "signature_format": "cms",
        "max_signature_size": 16384
    }
}
```

- **`id`** is any handle you'll recognize in `authorize` and `sign`. The session ID works.
- **`max_signature_size`** is the largest CMS your provider returns, in bytes, from 1 to 53,248. Leave it out for the default, 24,576. A CMS above the limit fails the session with `signature-too-large`, so measure your provider's largest output, chain included, and add a margin.
- **No `certificates`, no `key_algo_oids`.** The certificate arrives in `sign`. SignatureAPI then doesn't send `sign_algo_oid`, and your provider names its algorithm inside the CMS.

Leave out `expires_at` here. The certificate doesn't exist yet, so there's nothing to expire.

## 2. `authorize`: the whole provider flow

The digest is the SHA-256 of the PDF's signed byte range: every byte of the document except the space reserved for the signature. To your provider, it's the document hash.

1. Start a signing request at the provider with that hash and the signer's `name` and `email`. Pass the `label` as the document name, so the signer sees what they sign.

2. Register your worker's own return URL with the provider. Map it to this session.

3. Answer `pending` with the provider's page:

   ```json
   {
       "status": "pending",
       "action_url": "https://provider.example.com/sign/7c1d...",
       "expires_at": "2026-08-24T17:00:00Z"
   }
   ```

4. The signer identifies and approves at the provider. When the provider sends the browser back to your return URL, mint a single-use `code` and redirect to `callback_url` with it.

5. SignatureAPI calls `authorize` again with `"callback": { "code": "..." }`. Spend the code and answer:

   ```json
   {
       "status": "completed",
       "authorization": { "reference": "req_7c1d..." }
   }
   ```

Identification can take a while, for example a video call. Set the connection's **Authorization timeout** to cover it, up to one hour. See [Connect a signing worker](https://signatureapi.com/docs/qualified-signatures/connect-signing-worker#connect-a-worker). Your `expires_at` can shorten that deadline, never extend it.

If identification fails or the signer cancels, redirect to `callback_url` with `error=access_denied` and an `error_description` written for the signer.

## 3. `sign`: return the CMS and the chain

The request carries `"signature_format": "cms"` and no `sign_algo_oid`:

```json
{
    "credential_id": "sgs_YFobK1NDktAuz0wzplR4OP",
    "authorization": { "reference": "req_7c1d..." },
    "digests": [
        { "value": "n4bQgYhMfWWaL+qgxVrQFaO/TxsrC4Is0V1sFbDwCgg=", "hash_algorithm_oid": "2.16.840.1.101.3.4.2.1" }
    ],
    "signature_format": "cms"
}
```

Get the signature from your provider, then answer with the CMS and the one-shot certificate's chain, signer first:

```json
{
    "status": "completed",
    "signatures": ["MIIGxwYJKoZIhvcNAQcCoIIGuDCC..."],
    "certificates": [
        "-----BEGIN CERTIFICATE-----\n...one-shot signer...\n-----END CERTIFICATE-----",
        "-----BEGIN CERTIFICATE-----\n...issuing CA...\n-----END CERTIFICATE-----"
    ]
}
```

The CMS must be detached, with one signer, and signed attributes that include the `message-digest` (equal to the digest you received) and `signing-certificate-v2` (naming the signer certificate). The full list, with the failure reason for each rule, is in [Requirements on a CMS signature](https://signatureapi.com/docs/qualified-signatures/signing-worker-protocol/signature-formats#requirements-on-a-cms-signature).

Pass the provider's CMS through as it is:

- **BER is fine.** SignatureAPI converts it to DER.
- **A provider timestamp is fine.** SignatureAPI replaces it with its own.
- **Leave out revocation data.** SignatureAPI adds its own.

Return `failed` with `retryable: false` if the provider's signing failed after the signer approved. Never set `retryable: true` on `sign` unless the act certainly didn't happen. SignatureAPI doesn't retry `sign` on a retryable failure in any case.

## The signing date in the PDF

The PDF's signing date is fixed when SignatureAPI computes the digest, before your provider issues the certificate. So the certificate's validity starts after that date. The trusted time of the signature is SignatureAPI's timestamp, and the certificate must be valid at that time. Some validators warn about the earlier date. That's how the format works.

## A one-shot provider without CMS

If your provider issues a one-shot certificate but returns only a bare signature value, use `raw`. Then the certificate must exist before SignatureAPI computes the digest, so issuance moves into `credential`.

### Identification in credential

**One-shot certificate with raw, part 1: issuance moves into credential**

Participants: Signer's browser, SignatureAPI, Your worker, Provider.

1. **SignatureAPI** to **Your worker**: `POST /v1/credential`
2. **Your worker** to **SignatureAPI**: `pending` with an `action_url`
3. **SignatureAPI** to **Signer's browser**: **Confirm your identity to continue**, then redirect
4. **Signer's browser** to **Provider**: Identify
   The provider issues a one-shot certificate.
5. **Provider** to **Signer's browser**: Redirect, then `callback_url` with a single-use `code`
6. **SignatureAPI** to **Your worker**: `POST /v1/credential` with `callback.code`
7. **Your worker** to **SignatureAPI**: `completed` with `certificates`, `key_algo_oids`, `expires_at`

- **`credential`** pauses for identification. On the resumed call, return the new chain, the `key_algo_oids` and the certificate's `expires_at`.

### Authorize and sign

**One-shot certificate with raw, part 2: authorize and sign**

Participants: SignatureAPI, Your worker.

1. **SignatureAPI**: Compute the digest
2. **SignatureAPI** to **Your worker**: `POST /v1/authorize`
3. **Your worker** to **SignatureAPI**: `pending`, or `completed` if the provider session covers the approval
4. **SignatureAPI** to **Your worker**: `POST /v1/sign` with `sign_algo_oid`
5. **Your worker** to **SignatureAPI**: `completed` with `signatures`

- **`authorize`** pauses again for the approval. If the provider's session from the first step already covers this signature, answer `completed` right away.
- **`sign`** works like the [CSC recipe](https://signatureapi.com/docs/qualified-signatures/recipes/csc-remote-certificate#3-sign-spend-the-sad).

SignatureAPI checks `expires_at` before `authorize` and again before `sign`. If the certificate has expired, the session fails with `credential_expired: the signing certificate expired before it could be used`, and the signer starts again from the ceremony with a new session and a new certificate.

## Test it

- **Happy path.** A test envelope completes, and a PDF validator shows the signature with the one-shot certificate.
- **Size.** Your largest real CMS fits `max_signature_size`.
- **Identification fails.** The ceremony shows your `error_description`, and **Try again** starts a new session.
- **The signer walks away.** After the authorization timeout, the session fails with `authorization window expired`.
