# Server API

Source: https://mroffice.ai/en/developers/embed/server-api

All with Authorization: Bearer <secret key>, from your server only (no browser CORS).

Create calls (POST /files, /sessions, /documents/{key}/save, /events/{id}/redeliver and the jobs) take an Idempotency-Key header: a retry with the same key answers the first result instead of doing the work twice.

| Request | Does |
| --- | --- |
| POST /api/v1/embed/files?name=… | Uploads a file (raw body); answers upload_id, valid 24 h. |
| POST /api/v1/embed/sessions | Mints a session token for you (same rules as your own); with file.data_base64 and file.name it stores the file in the same call. |
| GET /api/v1/embed/documents | The app's documents, newest first, a page at a time (limit, starting_after, has_more). |
| GET /api/v1/embed/documents/{key} | The document's version, open sessions, last save. |
| GET /api/v1/embed/documents/{key}/content[?version=N] | The saved file (newest by default). |
| POST /api/v1/embed/documents/{key}/save | Saves now; answers the save, the callback follows. |
| DELETE /api/v1/embed/documents/{key} | Ends its sessions and deletes our copy. |
| GET /api/v1/embed/saves/{id} | One save's status. |
| GET /api/v1/embed/events | Every event the webhooks send, kept 30 days, newest first; filter by type, document_key, created[gte] and created[lte]. |
| GET /api/v1/embed/events/{id}/deliveries | The event's webhook attempts: status code, latency, error, next retry. |
| POST /api/v1/embed/events/{id}/redeliver | Sends the event's webhook again now (idempotent). |

Errors are JSON: { "error": { "code": "embed_…", "message": "…", "retryable": true } } with a 4xx or 5xx status. retryable says whether the same request may succeed later, and a 429 or 503 says when in Retry-After; responses carry RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset.

Every route, schema and error is in the OpenAPI 3.1 document:

```bash
curl https://mroffice.ai/api/v1/embed/openapi.json
```
