# Format discovery

Discover the enabled document formats, conversion pairs, and profiles before
submitting a conversion request. These read-only routes do not require a token
and do not accept request fields.

## Routes

| Route | Method | Success result |
| --- | --- | --- |
| `/v1/format/input/list` | `ANY` (use `GET`) | Enabled input formats in `data.items`. |
| `/v1/format/output/list` | `ANY` (use `GET`) | Enabled output formats in `data.items`. |
| `/v1/format/matrix` | `ANY` (use `GET`) | Available input and output formats, conversion pairs, and profiles. |

## List input or output formats

Each item returned by either list route has these fields:

| Field | Type | Description |
| --- | --- | --- |
| `id` | String | Dashed UUID for the format. |
| `name` | String | Stable format reference accepted by request fields. |
| `label` | String | Display name. |
| `enabled` | Boolean | Always `true` in these public lists. |
| `supports_input` | Boolean | Whether the format can be an input. |
| `supports_output` | Boolean | Whether the format can be an output. |
| `sort_order` | Integer | Display order. |
| `meta` | Object or `null` | Format metadata. |

```bash
curl -sS https://api.document.service.m7.org/v1/format/input/list
```

```json
{
  "status": 1,
  "comment": "INPUT_FORMAT_LIST",
  "data": {
    "items": [
      {
        "id": "FORMAT_UUID",
        "name": "markdown",
        "label": "Markdown",
        "enabled": true,
        "supports_input": true,
        "supports_output": false,
        "sort_order": 10,
        "meta": {
          "extensions": ["md", "markdown"],
          "mime_types": ["text/markdown", "text/x-markdown"]
        }
      }
    ]
  }
}
```

## Get the conversion matrix

`/v1/format/matrix` returns these arrays:

| Field | Item type | Description |
| --- | --- | --- |
| `inputs` | Format | Enabled input formats. |
| `outputs` | Format | Enabled output formats. |
| `conversions` | Conversion | Enabled pairs that can be submitted to `/v1/convert/*`. |
| `profiles` | Profile | Active profiles that can be supplied as `profile`. |

A conversion item contains `id`, `name`, `input_format`, `output_format`,
`enabled`, `sort_order`, and `meta`. The input and output fields are format
names. A profile item contains `id`, `name`, `label`, `active`,
`conversion_rules`, `input_formats`, and `output_formats`; membership items
contain `id`, `name`, `label`, and `sort_order`.

```bash
curl -sS https://api.document.service.m7.org/v1/format/matrix
```

Use an `input_format` and `output_format` pair listed in `conversions`. Format
availability can change, so do not hard-code a catalog obtained from another
environment.
