# FixMyScan agent manual > FixMyScan turns scanned books into clean, searchable PDFs for e-readers. AI apps use it through a remote MCP server; developers use a REST API. Both do the same things for the same FixMyScan account. ## What it does - In: a scanned book, PDF or DjVu, up to 1,000 pages and 1 GB. - Out: one PDF. Pages cropped to the text block (covers and picture pages stay whole), straightened, sharp black and white (`bw`, best on e-ink) or gentle greyscale (`grey`), two-page spreads split into single pages, searchable text added. - Searchable text in 19 languages, as Tesseract codes: `ara`, `chi_tra`, `deu`, `ell`, `eng`, `fra`, `frk`, `grc`, `ita`, `lat`, `nld`, `pol`, `por`, `rus`, `san`, `spa`, `swe`, `tam`, `ukr`. `auto` detects the language. - A book converts in the background. Every call answers at once with the book's id; you then poll it, or (API only) get a webhook. - Files are deleted 24 hours after a book is ready. Download links work for an hour; ask for the book again for a fresh one. ## Which to use - Acting for a person inside an AI app (ChatGPT, Claude, Gemini, Grok and other MCP clients): the MCP server. The person signs in to FixMyScan once and presses Allow. - Your own code, scripts or back end: the REST API with an API key. ## Cost - The MCP server and the API cost nothing extra; they use the person's FixMyScan plan. - Without a plan, books convert from free pages that come back every 30 days. A book longer than the pages left converts its first pages. When none are left, the tool result or API response gives the date more come back. - Plans: https://fixmyscan.com/pricing. Personal is $79.99 a year or $9.99 a week, up to 1,000 pages a book and 5,000 pages a rolling 7 days. Team plans start at $348 a year. ## MCP server - Address: `https://mcp.fixmyscan.com/mcp` - Transport: Streamable HTTP, stateless, JSON responses. - Every request needs an OAuth access token. Without one the server answers `401` with `WWW-Authenticate: Bearer resource_metadata="https://mcp.fixmyscan.com/.well-known/oauth-protected-resource/mcp", scope="books"`. - Setup steps for each app: https://fixmyscan.com/ai ### OAuth 2.1 - Protected resource metadata (RFC 9728): https://mcp.fixmyscan.com/.well-known/oauth-protected-resource/mcp - Authorization server metadata (RFC 8414): https://mcp.fixmyscan.com/.well-known/oauth-authorization-server - Issuer `https://mcp.fixmyscan.com`. Endpoints: `/oauth/authorize`, `/oauth/token`, `/oauth/register` (dynamic client registration, RFC 7591), `/oauth/revoke`. - Client ID metadata documents are supported: a `client_id` that is an https URL is fetched (it must answer within 6 seconds). - Authorization code grant with PKCE `S256` only, plus refresh tokens. One scope: `books`. Token endpoint auth: `none`, `client_secret_post` or `client_secret_basic`. - The person signs in with Google or a 6-digit email code, then presses Allow. - Access tokens last an hour and are bound to the resource `https://mcp.fixmyscan.com/mcp`. Refresh tokens rotate and last 30 days; a refresh token used twice revokes the whole family. - The person can disconnect an app at any time under Connected apps on https://app.fixmyscan.com/account. ### Tools Every tool returns plain text for the person and `structuredContent` with the same facts. Book ids are called `scan_id` and look like `job_...`. `fix_scan`: convert a book. Use it when the person wants to fix, clean up, OCR or convert a scan for a Kindle, Kobo, reMarkable or tablet. - Give exactly one source: - `file`: a file the person attached in the chat (`download_url`, `file_id`, optional `mime_type`, `file_name`). ChatGPT passes attachments this way (`openai/fileParams`). - `source_url`: a public https link to the PDF or DjVu file. - `upload_id`: from `create_upload_link`, once the person has uploaded. - Options: `trim_margins` (default `true`), `split_spreads` (default `true`), `output` (`bw` or `grey`, default `bw`), `language` (`auto` or a code above, default `auto`). - `idempotency_key` (optional, up to 128 characters): repeat it on a retry so the book starts once. Without it, the same person, file and options already find the first book. - Returns a `scan_id` at once. Then poll `get_scan_status`. `create_upload_link`: no parameters. Use it when you cannot pass the person's file: no attachment, a file too large to attach, or an app other than ChatGPT (FixMyScan receives attachments only from ChatGPT). Show the person the link (`upload_url`, on app.fixmyscan.com). It works for one hour and one file. When they say it is uploaded, call `fix_scan` or `preview_scan` with the `upload_id`. `preview_scan`: before-and-after images of 3 pages of the person's own book, before converting. Free. Same sources as `fix_scan`, or the `scan_id` of a book not yet converted. Options: `trim_margins`, `split_spreads`, `output`. The first call answers at once; call again with the `scan_id` after about ten seconds for the images. To convert after the preview, call `fix_scan` with `upload_id` set to the `scan_id`. `get_scan_status`: `scan_id` (required). The book's stage, pages done of the total, and the download link once it is ready. While a book is converting, call it again every 10 to 20 seconds. Read-only. `list_my_scans`: no parameters. The person's books from the last 24 hours, newest first, with download links for finished ones. Use it when you need a `scan_id`. Read-only. `cancel_scan`: `scan_id` (required). Stop a book that is converting or waiting. Only when the person asks. A cancelled book does not count as used. `delete_scan`: `scan_id` (required). Delete the upload and every file made from it now, rather than after 24 hours. Only when the person asks. It cannot be undone. ### The usual flow 1. ChatGPT with an attachment: `fix_scan` with `file`. With a link: `fix_scan` with `source_url`. Otherwise: `create_upload_link`, show the link, wait for the person, then `fix_scan` with `upload_id`. 2. Poll `get_scan_status` with the `scan_id` until the state is `ready`, `failed`, `refused`, `cancelled` or `expired`. 3. Give the person the download link. When a tool fails, its text says why in plain words; `structuredContent.error` holds the code (see Errors below). ## REST API - Base URL: `https://api.fixmyscan.com/v1` - OpenAPI 3.1 document: https://api.fixmyscan.com/openapi.json. It lists the same operations under their long form, `https://app.fixmyscan.com/api/v1/public/...`; both addresses work. - JSON in and out. ### Get a key 1. Sign in at https://app.fixmyscan.com (Google or an email code). 2. Open https://app.fixmyscan.com/account, find API keys, type a name and press Make a key. 3. Copy the key (`fms_live_...`) and the webhook secret (`whsec_...`). Both are shown once. Up to 10 keys per account; deleting a key stops code that uses it. Send the key on every request: ``` Authorization: Bearer fms_live_... ``` ### Endpoints | Method and path | Does | | --- | --- | | `POST /v1/uploads` | Make a book and a presigned upload URL for its file | | `POST /v1/books` | Start a book from `source_url` or `upload_id`, with an optional `webhook_url` | | `POST /v1/previews` | Before and after of 3 pages. Free | | `GET /v1/books` | The account's books from the last 24 hours, newest first (up to 20) | | `GET /v1/books/{id}` | State, progress, the preview when there is one, and `download_url` once ready | | `POST /v1/books/{id}/cancel` | Stop a book that is converting or waiting. It does not count as used | | `DELETE /v1/books/{id}` | Delete the upload and every file made from it now | ### Start a book from a link ```sh curl https://api.fixmyscan.com/v1/books \ -H "Authorization: Bearer $FIXMYSCAN_KEY" \ -H "Idempotency-Key: 7d1c0e2a-book-1" \ --json '{ "source_url": "https://example.org/scans/old-book.pdf", "webhook_url": "https://example.com/hooks/fixmyscan" }' ``` `202 Accepted`, the book: ```json { "id": "job_4mNq2c9WkqfK8xY0Tt3bPLh1sR4", "title": "old book", "state": "inspecting", "message": "Reading the book.", "pages": null, "pages_done": null, "pages_total": null, "first_pages_only": false, "download_url": null, "preview": null, "error": null, "upgrade_url": null, "created_at": "2026-11-06T10:12:03+00:00", "expires_at": "2026-11-07T10:12:03+00:00" } ``` `POST /v1/books` body fields: - `source_url`: a public https link to the PDF or DjVu file (standard port, no user name or password). Or - `upload_id`: from `POST /v1/uploads`, after the PUT. Exactly one of the two. - `trim_margins` (default `true`): crop each page to its text block. - `split_spreads` (default `true`): split scans of two facing pages. - `output`: `bw` (default) or `grey`. - `language`: `auto` (default) or a code from the list above. - `webhook_url`: an https URL posted once when the book ends. Unknown fields are refused. ### Upload a file instead 1. Ask for an upload URL. `size` is the file's exact size in bytes; the URL is signed for it. ```sh curl https://api.fixmyscan.com/v1/uploads \ -H "Authorization: Bearer $FIXMYSCAN_KEY" \ --json '{"filename": "old-book.pdf", "size": 48213504}' ``` `201 Created`: ```json { "upload_id": "job_4mNq2c9WkqfK8xY0Tt3bPLh1sR4", "upload": { "method": "PUT", "url": "https://...", "headers": {"content-type": "application/pdf"}, "expires_at": "2026-11-06T11:12:03+00:00" } } ``` 2. PUT the bytes to `upload.url` within the hour, with exactly the headers in `upload.headers` (they vary; do not hard-code them). ```sh curl -X PUT "$UPLOAD_URL" -H "content-type: application/pdf" --data-binary @old-book.pdf ``` 3. Start it: `POST /v1/books` with `{"upload_id": "job_..."}` and any options. Before the PUT has landed the answer is `409 not_uploaded`. ### Preview first ```sh curl https://api.fixmyscan.com/v1/previews \ -H "Authorization: Bearer $FIXMYSCAN_KEY" \ --json '{"upload_id": "job_4mNq2c9WkqfK8xY0Tt3bPLh1sR4"}' ``` Answers `202` with the book. Poll `GET /v1/books/{id}` until `preview` fills in: a list of `{"page": 12, "images": {"before": "https://...", "after": "https://..."}}` (JPEG links that work for an hour). The body takes `source_url` or `upload_id` plus `trim_margins`, `split_spreads` and `output`. To convert the whole book, `POST /v1/books` with `upload_id` set to the book's id. ### Read, cancel, delete ```sh curl https://api.fixmyscan.com/v1/books/job_4mNq2c9WkqfK8xY0Tt3bPLh1sR4 \ -H "Authorization: Bearer $FIXMYSCAN_KEY" ``` While converting, `state` is `processing`, with `pages_done` of `pages_total` and a `message` such as `"Adding searchable text: page 120 of 312."`. When `state` is `ready`, `download_url` holds the PDF (works for an hour; read the book again for a new link). ```sh curl -X POST https://api.fixmyscan.com/v1/books/job_4mNq2c9WkqfK8xY0Tt3bPLh1sR4/cancel \ -H "Authorization: Bearer $FIXMYSCAN_KEY" curl -X DELETE https://api.fixmyscan.com/v1/books/job_4mNq2c9WkqfK8xY0Tt3bPLh1sR4 \ -H "Authorization: Bearer $FIXMYSCAN_KEY" ``` Both answer `200` with `{"id": "...", "state": "cancelled" | "deleted", "message": "..."}`. ### The book object - `id`: `job_...` - `title`: from the file name, or null. - `state`: `awaiting_upload`, `inspecting`, `ready_for_crop`, `awaiting_authorization`, `queued`, `processing`, `validating`, `ready`, `failed`, `refused`, `cancelled` or `expired`. Final states: `ready`, `failed`, `refused`, `cancelled`, `expired`. - `message`: one plain sentence for people. - `pages`, `pages_done`, `pages_total`: `pages_total` is what this conversion makes (100 for a first-pages book). - `first_pages_only`: true when only the book's first pages are converted, from the free pages. - `allowance`: `{"pages_left": ..., "renews_at": ...}`, the account's free pages in the rolling 30 days and when more come back; null with a plan. - `download_url`: the finished PDF, or null. - `preview`: the before-and-after pages, or null. - `error`: `{"code": "..."}` when the book failed or was refused, else null. - `upgrade_url`: https://fixmyscan.com/pricing when a plan would let the book start. - `created_at`; `expires_at`: when the files are deleted. ### Idempotency Send `Idempotency-Key` (up to 128 characters) on `POST /v1/books` and repeat it on a retry: the book starts once and the retry returns the same book. Without the header, the same account, link and options also find the first book. A book already on its way is never refused on a retry. ### Errors Errors from FixMyScan look like this; a 402 adds `upgrade_url`, and `allowance` when free pages come back on a date: ```json {"error": {"code": "subscription_required", "message": "…"}, "upgrade_url": "https://fixmyscan.com/pricing"} ``` | Status | Code | Means | | --- | --- | --- | | 401 | `unauthorized` | No key sent | | 401 | `invalid_key` | The key is not valid or was deleted | | 402 | `subscription_required` | No free pages left; see `allowance.renews_at` and `upgrade_url` | | 404 | `not_found` | No such book for this key's account | | 409 | `not_uploaded` | The PUT to the upload URL has not landed yet | | 409 | `already_finished` | Cancel on a book that is already ready | | 409 | `still_converting` | Delete on a converting book; cancel it first | | 409 | `conflict` | The book could not be stopped just now; try again | | 413 | `too_large` | The file is over the upload limit (1 GB) | | 422 | `invalid_source` | Not exactly one of `source_url` or `upload_id` | | 422 | `invalid_source_url` | The link is not a public https address | | 422 | `invalid_webhook_url` | The webhook URL is not a public https address | | 422 | `invalid_language` | Not `auto` or a listed code | | 422 | `invalid_output` | Not `bw` or `grey` | | 429 | `rate_limited` | Too many requests for this key; wait `Retry-After` seconds | | 507 | `storage_full` | Uploads are paused for a moment; try again later | A body that fails schema validation (a wrong type, an unknown field) answers `422` in the framework's own shape, `{"detail": [...]}`. ### Rate limits 120 requests a minute per key. Over it: `429` with `Retry-After` in seconds. ### Webhooks A book started with `webhook_url` gets one POST when it ends. ```json { "id": "evt_...", "type": "book.ready", "created": 1762424100, "data": { "id": "job_...", "state": "ready", "download_url": "https://...", "...": "the book object" } } ``` - `type`: `book.ready`, or `book.failed` (the conversion failed, the file could not be read, or the book was refused). A cancelled book sends nothing. - Headers: `content-type: application/json`, `user-agent: FixMyScan-Webhooks/1.0`, `FixMyScan-Signature: t=,v1=`. - Answer any 2xx. Anything else, a timeout (10 seconds) or a redirect is retried after 30 s, 2 min, 10 min, 1 h and 6 h, then given up. Redirects are not followed. - `download_url` in the event works for an hour; fetch the book with `GET /v1/books/{id}` for a fresh one. Verify the signature before trusting the body: 1. Read the raw request body as bytes, before any JSON parsing. 2. Split `FixMyScan-Signature` on `,` and each part on the first `=`, giving `t` and `v1`. 3. Compute HMAC-SHA256 with your webhook secret (`whsec_...`, the whole string, as UTF-8) as the key, over `.`. Hex-encode it. 4. Compare it with `v1` in constant time. 5. Reject it if `t` is more than 5 minutes from your clock. ```python import hashlib, hmac, time def verify(secret: str, body: bytes, header: str, tolerance: int = 300) -> bool: parts = dict(p.split("=", 1) for p in header.split(",")) t = int(parts["t"]) if abs(time.time() - t) > tolerance: return False expected = hmac.new(secret.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest() return hmac.compare_digest(expected, parts["v1"]) ``` Each key has its own webhook secret, shown once beside the key when it is made. ## Limits - PDF or DjVu, up to 1,000 pages and 1 GB a book. Out: PDF. - Books without a plan: see Cost. - Fair use on Personal: 5,000 pages a rolling 7 days. - On Personal, one book converts at a time; the next waits its turn. - Files are deleted 24 hours after a book is ready, or straight away with delete. - Source links and webhook URLs must be public https addresses on the standard port. ## Links - Setup in AI apps: https://fixmyscan.com/ai - API page: https://fixmyscan.com/api - Pricing: https://fixmyscan.com/pricing - OpenAPI: https://api.fixmyscan.com/openapi.json - Account and keys: https://app.fixmyscan.com/account - Support: support@fixmyscan.com