# Docs

Documents of Praecise Spaces Docs, for the person a product calls for. Read [calling Spaces](calling-spaces.md) first.

- `GET https://inbox.praecise.com/api/spaces/docs/templates`: The templates the account can start a document from
- `POST https://inbox.praecise.com/api/spaces/docs`: Make a document: empty, or from a template, text, Markdown or a file (takes an `Idempotency-Key`)
- `GET https://inbox.praecise.com/api/spaces/docs`: The documents this product can reach for the account
- `GET https://inbox.praecise.com/api/spaces/docs/{id}`: One document: its reference, address, version and the account's role
- `GET https://inbox.praecise.com/api/spaces/docs/{id}/content`: The text as it is saved now: text, markdown, html or tree
- `GET https://inbox.praecise.com/api/spaces/docs/{id}/export`: The document as a file: pdf, docx, md, html or txt
- `PUT https://inbox.praecise.com/api/spaces/docs/{id}`: Save a new version from the version the caller read (takes an `Idempotency-Key`)
- `GET https://inbox.praecise.com/api/spaces/docs/{id}/people`: Who the document is shared with
- `PUT https://inbox.praecise.com/api/spaces/docs/{id}/people`: Give, change or remove what a person or the organisation may do (takes an `Idempotency-Key`)
- `DELETE https://inbox.praecise.com/api/spaces/docs/{id}`: Move a document the product made to the bin (takes an `Idempotency-Key`)

## Saving

A save names the version the caller read (`version`). If the document moved on, the answer is 409 `version_conflict` and nothing is lost: read it again and merge. Two saves from one version: exactly one wins.

## Files

`create_document` takes `file: { name, content_type, data }` with `data` in base64: Word (.docx), Markdown, HTML or plain text become a document. `export_document` answers `pdf`, `docx`, `md`, `html` or `txt`; `pdf` answers 501 `not_configured` where the deployment has no PDF renderer.

## What a product may do

A product reaches the documents it made and the ones the owner gave it on Docs' own page. It trashes only a document it made.
