---
title: "Firmar por lotes (Cualquier certificado, con Rest PKI Core)"
product: "PKI Suite"
slug: "sign-a-batch-rest-pki-core"
language: "es"
canonical_url: "https://try.lacunasoftware.com/es/pki-suite/sign-a-batch-rest-pki-core"
docs_url: "https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/signature-sessions"
samples:
  - title: "Signature session with predefined documents using Rest PKI Core"
    language: "dotnet"
    framework: "aspnet-mvc"
    url: "https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/dotnet/mvc/PkiSuiteAspNetMvcSample/Controllers/SignatureSessionPreDefRestCoreController.cs"
  - title: "Signature session with predefined documents using Rest PKI Core"
    language: "java"
    framework: "spring-boot"
    url: "https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/java/springmvc/src/main/java/com/lacunasoftware/pkisuite/controller/SignatureSessionPreDefRestCoreController.java"
samples_repo: "https://github.com/LacunaSoftware/PkiSuiteSamples"
trace_recorded: "2026-11-10"
last_generated: "2026-11-10T22:45:25Z"
---

# Firmar por lotes (Cualquier certificado, con Rest PKI Core)

Revise varios PDF aquí y fírmelos todos a la vez en la página de firma de Rest PKI Core, en una nueva pestaña: con un certificado en su computadora o token, mediante Web PKI, o con un certificado en la nube, en una computadora o en un móvil.

Live demo: [https://try.lacunasoftware.com/es/pki-suite/sign-a-batch-rest-pki-core](https://try.lacunasoftware.com/es/pki-suite/sign-a-batch-rest-pki-core). It runs against Lacuna's real products; this page describes it for AI coding agents.

## Call sequence

Recorded on 2026-11-10 against the real products with Lacuna's public test certificates and data. Keys, tokens, sessions, ids, file contents and personal data are masked.

Recorded up to the hand-off to the Hosted signing page: signing there needs a person with a certificate, so the wait on `when-completed`, the signed PDFs' download and their inspection are not shown yet.

### 1. Rest PKI Core opens a signature session with the PDFs as predefined documents, downloads disabled and the stamp's text tags, and returns its page's link.

On the server: `IRestPkiService.CreateSignatureSessionAsync`

`POST https://core.pki.rest/api/signature-sessions` → 200

Request:

```json
{
  "SecurityContextId": "00000000-0000-0000-0000-000000000000",
  "EnableBackgroundProcessing": false,
  "DisableDownloads": true,
  "CloudCertificatesOnly": false,
  "Documents": [
    {
      "File": {
        "MimeType": "application/pdf",
        "Content": "<Content, 2264 bytes>",
        "Name": "Amostra-Fatura-1.pdf",
        "Length": 0,
        "ContentType": "application/pdf"
      },
      "SignatureType": 1
    },
    {
      "File": {
        "MimeType": "application/pdf",
        "Content": "<Content, 2251 bytes>",
        "Name": "Amostra-Fatura-2.pdf",
        "Length": 0,
        "ContentType": "application/pdf"
      },
      "SignatureType": 1
    }
  ],
  "PdfSignatureOptions": {
    "VisualRepresentation": {
      "Text": {
        "Text": "Digitally signed by {{name}}\nCPF: {{br_cpf_formatted}}",
        "IncludeSigningTime": true,
        "Container": {
          "Left": 0.2,
          "Top": 0.2,
          "Right": 0.2,
          "Bottom": 0.2
        }
      },
      "Position": {
        "PageNumber": -1,
        "MeasurementUnits": 1,
        "Auto": {
          "Container": {
            "Left": 1.5,
            "Right": 1.5,
            "Bottom": 1.5,
            "Height": 4.7
          },
          "SignatureRectangleSize": {
            "Height": 2.2,
            "Width": 5.8
          },
          "RowSpacing": 0.3
        }
      }
    },
    "BypassMarksIfSigned": false
  }
}
```

Response:

```json
{
  "sessionId": "***",
  "redirectUrl": "https://restpkicore.lacunasoftware.com/en/sign?sub={value}&thm={value}&sav=0&tk={value}"
}
```

### 2. Hand the visitor the Hosted signing page as a plain link that opens in a new tab: they choose a certificate and sign every PDF there, while this page waits.

In the browser: `<a href="{redirectUrl}" target="_blank" rel="noopener">`

### 3. Read the session while the visitor hasn't signed: it is pending, so the server reads it again after 3 seconds, then less often up to every 30, until Rest PKI Core processes it.

On the server: `IRestPkiService.GetSignatureSessionAsync`

`GET https://core.pki.rest/api/signature-sessions/00000000-0000-0000-0000-000000000000` → 200

Response:

```json
{
  "documents": [
    {
      "status": "PendingSignature",
      "id": "00000000-0000-0000-0000-000000000000",
      "key": "***",
      "dateCreated": "2026-11-10T00:28:48.3286697+00:00",
      "subscriptionId": "00000000-0000-0000-0000-000000000000",
      "formattedKey": "***",
      "originalFile": {
        "mimeType": "application/pdf",
        "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en",
        "name": "Amostra-Fatura-1.pdf",
        "length": 2264,
        "contentType": "application/pdf",
        "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en"
      },
      "signatureType": "Pdf"
    },
    {
      "status": "PendingSignature",
      "id": "00000000-0000-0000-0000-000000000000",
      "key": "***",
      "dateCreated": "2026-11-10T00:28:48.3642064+00:00",
      "subscriptionId": "00000000-0000-0000-0000-000000000000",
      "formattedKey": "***",
      "originalFile": {
        "mimeType": "application/pdf",
        "url": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en",
        "name": "Amostra-Fatura-2.pdf",
        "length": 2251,
        "contentType": "application/pdf",
        "location": "https://restpkicore.lacunasoftware.com/api/documents/00000000-0000-0000-0000-000000000000/original-file?access_ticket={value}&culture=en"
      },
      "signatureType": "Pdf"
    }
  ],
  "id": "00000000-0000-0000-0000-000000000000",
  "status": "Pending",
  "subscriptionId": "00000000-0000-0000-0000-000000000000",
  "dateCreated": "2026-11-10T00:28:48.2975173+00:00"
}
```

## Patterns to copy

- Hand the reviewed PDFs to Rest PKI Core as a signature session's predefined documents (`CreateSignatureSessionAsync` with the documents in order), with no `ReturnUrl`, and show its `RedirectUrl` as a plain link that opens in a new tab: the visitor's page, and the Batch on it, stay where they are, and a link the visitor clicks is never popup-blocked. Set `DisableDownloads`, so the signed files come only from your own page.
- Nobody knows the signer when the session opens, so the stamp's text can't be written from the certificate: put Rest PKI Core's text tags in it, `{{name}}` and `{{br_cpf_formatted}}`, which it fills in from the signer's certificate, and let it add the signing time.
- Wait for the session from the server by its status, read with `GetSignatureSessionAsync`. While it is `Pending`, the visitor hasn't signed: read it again after a pause that grows from 3 seconds, doubling, to 30 (`PauseAfter`), so a quick signer is noticed at once and a page left open 4 hours costs about 480 reads; `GET api/signature-sessions/{id}/when-completed` fails at once on a pending session. Only while it is `Processing` wait on `when-completed`, which answers as soon as Rest PKI Core is done, or within about 15 seconds, then read the session again. `Completed`, `UserCancelled`, `Expired` and `ProcessingError` end the wait. A failed read doesn't: read again after the same pauses, and give up only after several in a row, since a visitor who signs after the wait gave up is billed for PDFs you never fetch. Rest PKI Core doesn't mark a session expired by itself: one still pending 4 hours after it opened has expired.
- Once it is completed, fetch every signed PDF at once, since their links expire and carry an access ticket you never log, and match each document back to its file by the name you sent and its size, and, only when several still match (the same PDF twice), by its original content, since the session lists them in no set order and gives back no id of yours. Rest PKI Core keeps a name in 200 characters: send a longer one shortened, keeping its extension. The signer's certificate is on the session.
- Count the Batch as one billed action however many PDFs it holds, since Rest PKI Core opens one signature session for it, and pass that gate before the session opens.

## Links

- Live demo: https://try.lacunasoftware.com/en/pki-suite/sign-a-batch-rest-pki-core (Portuguese: https://try.lacunasoftware.com/pt/pki-suite/sign-a-batch-rest-pki-core; Spanish: https://try.lacunasoftware.com/es/pki-suite/sign-a-batch-rest-pki-core)
- Docs: https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/signature-sessions
- Sample, .NET (aspnet-mvc): [Signature session with predefined documents using Rest PKI Core](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/dotnet/mvc/PkiSuiteAspNetMvcSample/Controllers/SignatureSessionPreDefRestCoreController.cs)
- Sample, Java (spring-boot): [Signature session with predefined documents using Rest PKI Core](https://github.com/LacunaSoftware/PkiSuiteSamples/blob/master/java/springmvc/src/main/java/com/lacunasoftware/pkisuite/controller/SignatureSessionPreDefRestCoreController.java)
- Every demo: https://try.lacunasoftware.com/llms.txt and https://try.lacunasoftware.com/demos.json
