---
title: "Archival extension - Rest PKI Core"
description: "Keep a signed PDF or XML file valid for the long term: extend it with POST api/v2/signature/archival-extension, which adds a new archive timestamp, and check it before with POST api/signature/archival-inspection."
canonical: "https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension"
locale: "en"
product: "Rest PKI Core"
last_updated: "2026-11-23"
---

# Archival extension - Rest PKI Core

A signed document stays verifiable for as long as the timestamp that protects it can be trusted, and a timestamp stops being trustworthy when the
certificate of the authority that issued it expires. The **archival extension** adds a new **archive timestamp** to an already signed file, before the
current one expires, so that the signature keeps its validity over time. The **archival inspection** is its read-only counterpart: it tells whether a file
can be extended and until when its current archive timestamp is valid, without changing the file. Both are available since [Rest PKI Core](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core) 5.4.0.

| File | What is extended |
| --- | --- |
| PDF | A new PAdES document timestamp is added to the end of the file, in an incremental revision |
| XML | The last signature that has an archive timestamp (XAdES with archive timestamp, such as AD-RA) gets a new archive timestamp |

CMS files (`.p7s`, `.p7m`) can't be extended: they fail with `UnsupportedContentType`.

> **Tip**
>
> From this point on we'll describe calls to Rest PKI Core. Make sure you've read the [Get Started](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/get-started) article to be able to keep up. The
> application's API key needs a role that allows signing and inspecting signatures, such as **Worker** (see [Choosing roles](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/get-started#roles)).

## A typical flow

1. Start from a signed file that already has an archive timestamp: a PDF that ends with a document timestamp (such as a [PDF stamp](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/pdf-stamp)) or an XAdES file with an archive timestamp.
2. From time to time, call the [inspection](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension#inspecting) and read `archiveTimestampInfo.dateExpires`.
3. Before that date, call the [extension](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension#extending) and store the file it returns in place of the previous one. The response has the new
   `dateExpires`: repeat from step 2 with the new file.

Each extension protects the file for as long as the new timestamp's authority certificate is valid, so the cycle can go on for as long as you need to
keep the document. An archive timestamp that has already expired can't be extended: the call fails with `ArchiveTimestampExpired`.

## Extending a file

On .NET, call `IRestPkiService.ExtendArchivalSignatureV2Async()` with the signed file, as a [file reference](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/file-referencing), and, optionally,
the security context:

```cs
var result = await restPkiService.ExtendArchivalSignatureV2Async(
	FileReference.FromFile(@"C:\AppData\Documents\contract.pdf"),
	securityContextId: new Guid("201856ce-273c-4058-a872-8937bd547d36")
);

// result.File is a reference to the extended file
// result.ArchiveTimestampInfo describes the new archive timestamp
Console.WriteLine($"Extended until {result.ArchiveTimestampInfo.DateExpires}");

using (var stream = await result.File.OpenReadAsync()) {
	// save the extended file
}
```

If calling the API directly, do:

```text
POST {endpoint}/api/v2/signature/archival-extension
{
	"file": {
		"content": "JVBERi0xLjcK...",
		"name": "contract.pdf",
		"mimeType": "application/pdf"
	},
	"securityContextId": "201856ce-273c-4058-a872-8937bd547d36"
}
```

The request has these fields (in .NET, the parameters of the method, with the same names):

| Field | Description |
| --- | --- |
| `file` | The signed PDF or XML file. Required. Rest PKI Core tells the format by the file's MIME type, as in [signature inspection](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/signature-inspection#inspecting): without a `mimeType`, it is taken from the file name's extension. A file whose type can't be found fails with `MimeTypeRequired`, and an unrecognized one with `UnrecognizedSignedFileMimeType` |
| `securityContextId` | The [security context](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/security-contexts) that decides which certificates are trusted and which [timestamp tier](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension#timestamp-tier) issues the new timestamp. If omitted, Rest PKI Core uses the subscription's default security context or, without one, the instance's |

There are no other options: every successful call adds one new archive timestamp.

### The result

The response has the extended file and the information of the new archive timestamp:

```json
{
	"file": {
		"url": "https://..."
	},
	"archiveTimestampInfo": {
		"timestampModel": { },
		"dateIssued": "2026-11-23T10:15:00-03:00",
		"dateExpires": "2029-06-30T23:59:59-03:00"
	}
}
```

| Field | Description |
| --- | --- |
| `file` | The extended file, as a [file reference](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/file-referencing). It always comes as a `url` from which you can download it for a limited time. In .NET, `result.File` is a `FileReference` |
| `archiveTimestampInfo.dateIssued` | When the authority issued the new timestamp |
| `archiveTimestampInfo.dateExpires` | When the new timestamp expires, which is when the validity of the timestamp authority's certificate ends. Extend the file again before this date |
| `archiveTimestampInfo.timestampModel` | The details of the new timestamp, such as its signer and certificates. Always filled |

### What is checked

Before issuing the timestamp, Rest PKI Core checks that the file can be extended.

**PDF.** The last signer of the PDF, in the order of the file, must be a document timestamp that has not expired. If the PDF ends with a signature of a
person, or has no signature, the call fails with `NoArchivalSignature`; if that document timestamp has already expired, with `ArchiveTimestampExpired`.
Rest PKI Core then validates this latest document timestamp against the security context. If it is not valid, the call fails with
`InvalidArchiveExtension`, along with the validation results, and no timestamp is issued or billed. The signatures before the latest document
timestamp are not validated: a new signature added after it starts a new archival, it is not an extension. The new document timestamp is added to the PDF in an incremental revision, together with the
validation data of the certificate of the authority that issued the latest document timestamp. An invalid PDF fails with `InvalidPdf`, and a
password-protected one with `ProtectedPdfError`.

**XML.** The file must have a signature with an archive timestamp, otherwise it fails with `NoArchivalSignature`. The latest archive timestamp must not be
expired (`ArchiveTimestampExpired`), and the signature must be valid against the security context, with at least one valid archive timestamp, otherwise the call
fails with `InvalidArchiveExtension`, along with the validation results. An XML file that can't be read fails with `InvalidXml`.

These errors are answered with HTTP 422 and an error code in the body (authentication and role failures keep their usual 401 and 403). They are:

| Code | When |
| --- | --- |
| `MimeTypeRequired`, `UnrecognizedSignedFileMimeType` | Rest PKI Core can't tell the file's type, or doesn't recognize it |
| `UnsupportedContentType` | The file is a CMS file (`.p7s`, `.p7m`), which can't be extended |
| `InvalidPdf`, `ProtectedPdfError`, `InvalidXml` | The file can't be read, or the PDF is password-protected |
| `NoArchivalSignature` | The PDF doesn't end with a document timestamp, or the XML has no signature with an archive timestamp |
| `ArchiveTimestampExpired` | The latest archive timestamp has already expired |
| `InvalidArchiveExtension` | The latest document timestamp (PDF) or the signature (XML) is not valid against the security context, or the timestamp has no signer or doesn't carry its authority's certificate. The error has the `validationResults` when they apply |
| `ArchivalExtensionValidationFailed` | The timestamp that was just issued didn't pass validation against the security context |
| `TimestampTierDisabled`, `TimestampTierRestricted` | The [timestamp tier](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension#timestamp-tier) of the security context is disabled or can't be used by your subscription |
| `SecurityContextNotFound` | The `securityContextId` doesn't exist |
| `TransactionLimitReached` | The subscription reached its limit of transactions for this operation (see [Billing](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension#billing)) |

The page [Error codes](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/error-codes) lists the most common codes of the API.

## Inspecting a file

The inspection runs the same checks as the extension, with the same error codes, and doesn't add a timestamp or change the file. A successful response
means the file passes the checks and returns the information of its active archive timestamp.

On .NET, call `IRestPkiService.InspectArchivalSignatureAsync()`:

```cs
var result = await restPkiService.InspectArchivalSignatureAsync(
	FileReference.FromFile(@"C:\AppData\Documents\contract.pdf"),
	securityContextId: new Guid("201856ce-273c-4058-a872-8937bd547d36")
);

var expires = result.ArchiveTimestampInfo.DateExpires;
if (expires - DateTimeOffset.Now < TimeSpan.FromDays(90)) {
	// time to extend the file
}
```

If calling the API directly, do:

```text
POST {endpoint}/api/signature/archival-inspection
{
	"file": {
		"content": "JVBERi0xLjcK...",
		"name": "contract.pdf",
		"mimeType": "application/pdf"
	},
	"securityContextId": "201856ce-273c-4058-a872-8937bd547d36"
}
```

The request takes the same two fields as the extension's: `file` and `securityContextId`. An abridged response, for a PDF:

```json
{
	"archiveTimestampInfo": {
		"timestampModel": { },
		"dateIssued": "2026-11-23T10:15:00-03:00",
		"dateExpires": "2029-06-30T23:59:59-03:00"
	},
	"signers": [
		{
			"signingTime": "2026-10-12T14:30:00-03:00",
			"signatureFieldName": "Signature1",
			"isDocumentTimestamp": false,
			"validationResults": null
		},
		{
			"signingTime": "2026-11-23T10:15:00-03:00",
			"signatureFieldName": "Signature2",
			"isDocumentTimestamp": true,
			"validationResults": {
				"passedChecks": [],
				"errors": [],
				"warnings": []
			}
		}
	]
}
```

| Field | Description |
| --- | --- |
| `archiveTimestampInfo` | The active archive timestamp of the file, with `dateIssued`, `dateExpires` and `timestampModel`. This is the timestamp the extension would extend |
| `signers` | The signers of the file, as in [signature inspection](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/signature-inspection#response). Only one has `validationResults`: in a PDF, the document timestamp at the end of the file; in an XML, the signature that has the active archive timestamp. The others have `null` |

The active archive timestamp is, in a PDF, the document timestamp at the end of the file and, in an XML, the latest archive timestamp of the last
signature that has one.

A file that doesn't pass the checks fails with the same errors listed [above](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/archival-extension#checks). A successful inspection doesn't guarantee that the
extension will succeed: it can still fail for reasons outside the file, such as a reached transaction limit or the timestamp authority being unavailable.
The inspection uses the same timestamp tier access check, so it fails with `TimestampTierDisabled` or `TimestampTierRestricted` when the extension would.

## The timestamp tier

The new archive timestamp is issued by a [timestamp tier](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/requesting-timestamps) of the instance. The request doesn't name it: Rest PKI
Core uses the one set on the [security context](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/security-contexts#settings) of the call. When the security context has no timestamp tier, Rest PKI
Core picks the tier from the roots it trusts (the ICP-Brasil tier, or the Lacuna Test one) and, failing that, the instance's default tier. If none can
be used, the call fails with `SecurityContextNotConfiguredForTimestamping`.

To control which tier extends your files, create a security context with the **Timestamp tier** you want and pass its ID in `securityContextId`.

## Billing

Each successful extension is counted as a **PDF archival signature extension** or an **XML archival signature extension** transaction, and also as a
**Timestamp** transaction, for the timestamp that was issued. The call fails when the subscription reached its limit of either. If the timestamp is
issued but the extension then fails, the timestamp is still billed.

An inspection is counted as one **Signature inspection** transaction, and only when it succeeds.

## Client libraries

The .NET library has the methods `ExtendArchivalSignatureV2Async()` and `InspectArchivalSignatureAsync()` from version 5.4.0 of the
[Lacuna.RestPkiCore.Client](https://www.nuget.org/packages/Lacuna.RestPkiCore.Client/) package. For the other languages, call the routes directly, as
described in [Calling the API directly](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/get-started#rest).

## Moving from the previous extension route

Earlier versions had `POST api/signature/archival-extension`, which extended only XML files and, in .NET, `ExtendArchivalSignatureAsync()`. Both are now
obsolete in favor of the routes above, and the old route answers `UnsupportedContentType` for any file that isn't XML. Use `POST api/v2/signature/archival-extension`
for PDF and XML files.

## See also

* [Signature inspection](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/signature-inspection)
* [PDF stamps](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/pdf-stamp)
* [Security contexts](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/security-contexts)
* [Requesting timestamps](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/requesting-timestamps)
* [Referencing files](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/file-referencing)
* [Error codes](https://docs.lacunasoftware.com/en-us/articles/rest-pki/core/integration/error-codes)
