> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/rest-api/identity-api/identity-api-reference/digital-signatures/signer.md). Agents can also search and read this documentation through its [MCP server](https://docs.facephi.com/~gitbook/mcp).

# Signer

This service runs the complete digital signing flow and immediately returns a `202 Accepted` response. The service processes the signing operation **asynchronously**.

Implements Basic Electronic Signature (AdES - BES), providing a robust and reliable solution with significant advantages in regulatory compliance, security, interoperability, and ease of use.

#### Asynchronous callback

When the operation completes—whether successful or unsuccessful—the service sends a POST request to the URL specified in the `callbackUrl`parameter. If `callbackHeaders`are provided, they are included in the callback request.

* **Successful signing**: Content-Type `multipart/form-data`. Returns the signed PDF document as an attachment.
* **Failed signing**: Content-Type `application/json`. Returns an error object with `operationId` and an `error`.

{% hint style="warning" %}
Only the image formats **JPEG** and **PNG** are supported for signature visualization. Other formats will result in an error.
{% endhint %}

{% hint style="info" %}
**Security recommendation:** Always consume this API from your backend infrastructure rather than frontend applications. This approach protects sensitive data, prevents credential exposure, and ensures documents are handled securely throughout the signing process.
{% endhint %}

### Endpoint

```
POST /signer
```

### Headers

| Name          | Type   | Required | Description                       |
| ------------- | ------ | -------- | --------------------------------- |
| **x-api-key** | string | **Yes**  | API key for access authorization. |

### Request body

**Content-Type:** `application/json`

#### Parameters

| Parameter         | Type      | Required | Description                                                                                                                                                                                                                                    |
| ----------------- | --------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `document`        | string    | **Yes**  | PDF document to be digitally signed, encoded in **Base64** (RFC4648).                                                                                                                                                                          |
| `images`          | string\[] | No       | Array of signature visualization images to embed in the document. Each image must be encoded in **Base64**. Supported formats: **JPEG**, **PNG**.                                                                                              |
| `image`           | string    | No       | **Deprecated.** Use the `images` array instead. Single image to embed as a signature visualization, encoded in **Base64**.                                                                                                                     |
| `page`            | integer   | No       | Zero-indexed target page number for signature placement. **Default:** `0` (first page).                                                                                                                                                        |
| `position`        | string    | No       | Coordinates of the signature rectangle in pixels at 72 DPI: bottom-left X, bottom-left Y, top-right X, top-right Y. For A4 pages, valid ranges: X: 0-595, Y: 0-842. Format: `x1,y1,x2,y2`. **Default:** `"135,210,480,300"`                    |
| `timezone`        | string    | No       | IANA time zone identifier for the date/time format in signature metadata. Examples: `America/Lima`, `Europe/Madrid`, `Asia/Tokyo`. **Default:** `"UTC"`                                                                                        |
| `signature`       | string\[] | No       | Custom text lines to display alongside the signature image. Supports dynamic placeholders: `$(date)s` is replaced with the current timestamp formatted according to `dateFormat` and `timezone`. Each array element represents a line of text. |
| `dateFormat`      | string    | No       | Date/time format string following the ISO 8601 standard with strftime directives. Supports `%z` for the time zone offset. Example: `%d/%m/%Y %H:%M:%S%z`. **Default:** `"%Y/%m/%d %H:%M:%S%z"`                                                 |
| `callbackUrl`     | string    | **Yes**  | Webhook URL for receiving the signed document or error notification. The service will asynchronously send the results to this endpoint via POST.                                                                                               |
| `callbackHeaders` | string    | No       | Optional HTTP headers to include in the callback request. Format: key=value pairs separated by semicolons. Example: `Authorization=Bearer token;X-Custom=value`                                                                                |

#### Request example

```json
{
  "document": "JVBERi0xLjUKJbXtrvsKNCAwIG9iag...",
  "images": ["iVBORw0KGgoAAAANSUhEUgAAAEoAAABK..."],
  "page": 0,
  "position": "135,210,480,300",
  "timezone": "America/Lima",
  "signature": ["ID - 9999999", "Date - $(date)s"],
  "dateFormat": "%d/%m/%Y %H:%M:%S%z",
  "callbackUrl": "https://example.com/callback",
  "callbackHeaders": "Authorization=Bearer token123;Content-Type=application/json"
}
```

{% hint style="warning" %}
**Maximum request size: 6 MB.** The Base64-encoded PDF and signature images (`document`, `images` and `image`) count toward this limit together, with \~33% overhead compared to the original files (maximum \~4.5 MB total for the original files). For large documents, compress the PDF before sending it. If the limit is exceeded, the gateway responds `413` without processing the request. See [Request size limit](https://docs.facephi.com/pages/bc7bee9358079d52bafa44ad281828eb424e96fe#l%C3%ADmite-de-tama%C3%B1o-de-la-solicitud).
{% endhint %}

### Responses

#### `202` Accepted

The request was accepted, and the signing operation is being processed asynchronously. The result will be sent to the provided callback URL.

#### Callback — Successful signature

Content-Type: `multipart/form-data`

The signed PDF document is returned as an attachment.

#### Callback — Failed signature

Content-Type: `application/json`

```json
{
  "operationId": "910e181e-305c-4d9b-b42b-f177bf3b06ef",
  "error": "image: formato desconocido"
}
```

#### `400` Bad Request

```json
{
  "status": 400,
  "title": "Bad Request",
  "detail": "Invalid request.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400",
  "errors": []
}
```

#### `401` Unauthorized

```json
{
  "message": "Unauthorized"
}
```

#### `403` Forbidden

```json
{
  "Message": "User is not authorized to access this resource with an explicit deny"
}
```

#### `413` Payload Too Large

The request exceeds the maximum allowed size. The gateway rejects it **without processing it**: the response does not include `serviceResultCode` or `serviceTransactionId`. See [Request size limit](https://docs.facephi.com/pages/bc7bee9358079d52bafa44ad281828eb424e96fe#l%C3%ADmite-de-tama%C3%B1o-de-la-solicitud).

Request larger than 6 MB and up to 10 MB (`Content-Type: application/json`):

```json
{
  "message": "Request Too Long"
}
```

Request larger than 10 MB (10,485,760 bytes) (`Content-Type: text; charset=utf-8`, plain text, not JSON):

```
HTTP content length exceeded 10485760 bytes.
```

#### `502` Bad Gateway

```json
{
  "status": 502,
  "title": "Bad Gateway",
  "detail": "Server got an invalid response.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502"
}
```

#### `504` Gateway Timeout

```json
{
  "message": "Endpoint request timed out"
}
```
