# Document API

The Document API lets external applications convert documents between enabled
formats, inspect or sanitize document content, extract structured information,
and manage the short-lived jobs created for authenticated requests.

## Base URL

```text
https://api.document.service.m7.org
```

All versioned routes begin with `/v1`. Send JSON request bodies with
`Content-Type: application/json`.

Use the [production application](https://document.service.m7.org/) to convert and
preview documents, explore supported formats, and inspect your authenticated
conversion jobs.

## Authorization

This service uses its project-specific
[authorization process](https://m7.org/docs/api/api.document.m7.org/authorization.md). Send an M7 access token in the
`Authorization` header for protected routes:

```text
Authorization: Bearer ACCESS_TOKEN
```

| Caller | Supported use |
| --- | --- |
| No token | `/hello`, format discovery, and capability definitions. |
| Admitted M7 user or application | Reads accessible buckets and calls conversion, document and job routes with a required `bucket_id` and exact action capability. |
| Authorized organization workspace | Uses an organization principal's bucket membership, intersected with its live Management capability selection. |

Start with [Buckets and membership](https://m7.org/docs/api/api.document.m7.org/buckets.md). Every conversion, document
and job request requires a non-nil dashed `bucket_id`. Jobs are shared within
that authorized bucket; creator identity is provenance rather than a private
job boundary. Service admin/root status does not bypass public bucket checks.

The resource API uses Bearer validation and does not enforce DPoP proofs.
Organization acquisition has its own SSO-bound proof transport, explained in
[Caller and workspace context](https://m7.org/docs/api/api.document.m7.org/workspaces.md).

## Common response format

Successful responses use this envelope:

```json
{
  "status": 1,
  "comment": "RESULT_CODE",
  "data": {}
}
```

Failures return `status: 0`, a human-readable `comment`, and an empty `data`
object unless the error supplies more detail. Receiving-admission failures put their HTTP `code`, machine `reason`, and
`boundary: "roster"` under `data`. Handle the HTTP status separately from the
application `status`, and inspect diagnostic fields only where present.

## Format references

Where a request accepts a format or profile reference, send its stable `name`
or dashed UUID. Use the format-discovery endpoints to obtain the enabled
formats, conversion pairs, and available profiles before submitting a
conversion request.

## Pagination

`/v1/job/list` accepts one paging method at a time:

- `cursor`: an opaque value returned as `next_cursor`.
- `offset`: a zero-based row offset.
- `page_number`: a one-based page number.

The default `limit` is `3`; values are limited to `1` through `100`. A supplied
`cursor` takes precedence over `offset`, and `offset` takes precedence over
`page_number`.

## Guides

- [Authorization](https://m7.org/docs/api/api.document.m7.org/authorization.md)
- [Buckets and membership](https://m7.org/docs/api/api.document.m7.org/buckets.md)
- [Caller and workspace context](https://m7.org/docs/api/api.document.m7.org/workspaces.md)
- [`/hello`](https://m7.org/docs/api/api.document.m7.org/hello.md)
- [Format discovery](https://m7.org/docs/api/api.document.m7.org/format.md)
- [Convert a document](https://m7.org/docs/api/api.document.m7.org/convert.md)
- [Document operations](https://m7.org/docs/api/api.document.m7.org/document.md)
- [Extract document data](https://m7.org/docs/api/api.document.m7.org/document-extract.md)
- [Conversion jobs](https://m7.org/docs/api/api.document.m7.org/jobs.md)
