# Sign API extensions

Extensions add to the API without changing how any SignatureAPI request behaves. In the
[OpenAPI document](https://api.signapi.lumin.example/v1/openapi.yaml) each one is marked `x-lumin-extension: true`.

## Markdown and HTML documents

A document can be written in Markdown or HTML instead of PDF or DOCX. Set `format` to `markdown`
or `html` and give the source inline as `content`, as a `url`, or as a stored template with
`template_id`. Sign API renders it to PDF when the envelope is created; signers on phones see it
as a responsive page.

```json
{
  "format": "markdown",
  "content": "# Offer letter\n\nDear {{name}}, ...\n\n[[signer_1]]",
  "data": { "name": "Alex Doe" }
}
```

`{{placeholders}}` are filled from `data`. A value can be plain text, or `{"markdown": "…"}`,
`{"html": "…"}` or `{"template_id": "…"}` to insert formatted content. Signature and input fields
are written inline in the source. Markdown follows eSignatures.com's Extended Markdown, so
templates written for it work unchanged. Sources may be up to 1 MB.

Uploads accept `text/markdown` and `text/html` too, so you can upload a source once and use its
URL in many envelopes.

## Templates

Store Markdown and HTML sources as templates and use them with `template_id`. Sign API lists each
template's placeholders and fields, and you can edit the source with find-and-replace, duplicate a
template with some placeholders filled, or preview it as a PDF.

- [List templates](https://docs.signapi.dev/api/ListTemplates): `GET /templates`
- [Create a template](https://docs.signapi.dev/api/CreateTemplate): `POST /templates`
- [Get a template](https://docs.signapi.dev/api/GetTemplate): `GET /templates/{templateId}`
- [Update a template](https://docs.signapi.dev/api/UpdateTemplate): `PATCH /templates/{templateId}`
- [Delete a template](https://docs.signapi.dev/api/DeleteTemplate): `DELETE /templates/{templateId}`
- [Duplicate a template](https://docs.signapi.dev/api/DuplicateTemplate): `POST /templates/{templateId}/duplicate`
- [Get template content](https://docs.signapi.dev/api/GetTemplateContent): `GET /templates/{templateId}/content`
- [Replace template content](https://docs.signapi.dev/api/ReplaceTemplateContent): `PUT /templates/{templateId}/content`
- [Edit template content](https://docs.signapi.dev/api/EditTemplateContent): `POST /templates/{templateId}/content/edits`
- [Preview a template](https://docs.signapi.dev/api/PreviewTemplate): `POST /templates/{templateId}/preview`
- [Get the balance](https://docs.signapi.dev/api/GetBalance): `GET /balance`

## File upload fields

A Markdown or HTML document can ask a signer to attach a PDF, PNG or JPEG file. The place appears
in the envelope as type `file_upload`, and its capture holds the file's details and a download link.

## Credit balance

[Get the balance](https://docs.signapi.dev/api/GetBalance) returns the prepaid balance and the price per envelope, so your
integration can check before it sends. A live envelope the balance cannot pay for is refused with
`402` [`insufficient_credits`](https://docs.signapi.dev/errors/insufficient_credits).

## More languages

`language` accepts 54 languages for the signing page, emails, the audit log and dates:
SignatureAPI's nine plus 45 more. The existing codes keep their meaning.

## Larger files

Every uploaded or fetched file may be up to 20 MB.
