# How it works

Source: https://smartpdf.ru/en/developers/docs/how-it-works

## Operation lifecycle

1. **Upload.** `POST /v1/upload` stores the file and returns a `file_id`. It’s valid for an hour, and during that hour you can use it in several operations.
2. **Start.** `POST /v1/pdf/<operation>` checks the parameters and the balance, charges the payment and queues the operation. The response is `202` and a `task_id`. If there isn’t enough money, you get `402` and nothing is charged.
3. **Processing.** The status changes `pending` → `processing` → `done` or `failed`. If processing fails, the payment is returned to the balance.
4. **Result.** `GET /v1/tasks/{task_id}/download` returns a download link; the link is valid for an hour.

## Task statuses

| status | Meaning |
|---|---|
| `pending` | The operation is in the queue. |
| `processing` | Being processed. For PDF to Word, page-by-page progress is reported in `progress` and `stage`. |
| `done` | Done — ready to download. |
| `failed` | Failed. `error` contains a human-readable reason (for example, a wrong password or a damaged PDF); the payment has been returned to the balance. |

## Queue

Operations of accounts on the Business plan are processed first, all others in order.

## File storage

- **Uploaded files** and their `file_id` — an hour, then they’re deleted.
- **Results** — depending on the account’s plan: Free — an hour, and the download link can be obtained only once; Pro — 7 days; Business — 30 days.
- **The download link** is valid for an hour; on Pro and Business, you can request a new one while the result is stored.
- Servers and backups are located in Moscow.

## Result names

A result is named `<original name>_smartpdf.<extension>`: `document.pdf` → `document_smartpdf.pdf`. Merging returns `merged_smartpdf.pdf`, and building a PDF from images returns `images_smartpdf.pdf`. PDF to JPG and splitting return a ZIP archive. The name comes in the `filename` field and in the `Content-Disposition` header.

## Watermark

Results obtained via the API and MCP have no watermark, on any plan.
