Large documents
Documents over a few megabytes go to object storage first and are named by key when converting. The document never passes through the API, so the request body limit stops being the ceiling on document size, which matters most for scans, the largest files anyone has.
1. Ask for somewhere to put it
curl -X POST https://quirelabs.com/api/folio/v1/uploads \
-H "Authorization: Bearer $FOLIO_KEY" \
-H "content-type: application/json" \
-d '{"filename": "contract.pdf"}'
{
"key": "uploads/<organization>/<uuid>/contract.pdf",
"url": "https://…",
"expiresIn": 900,
"retainedForSeconds": 3600
}
The URL is good for fifteen minutes.
2. Upload straight to it
curl -X PUT "$URL" --data-binary @contract.pdf
3. Convert by key
curl -X POST https://quirelabs.com/api/folio/v1/convert \
-H "Authorization: Bearer $FOLIO_KEY" \
-H "content-type: application/json" \
-d "{\"key\": \"$KEY\"}"
The response is identical to sending the document in the body.
All three together
const upload = await fetch('https://quirelabs.com/api/folio/v1/uploads', {
method: 'POST',
headers: { authorization: bearer, 'content-type': 'application/json' },
body: JSON.stringify({ filename: 'contract.pdf' }),
}).then((response) => response.json());
await fetch(upload.url, { method: 'PUT', body: document });
const result = await fetch('https://quirelabs.com/api/folio/v1/convert', {
method: 'POST',
headers: { authorization: bearer, 'content-type': 'application/json' },
body: JSON.stringify({ key: upload.key }),
}).then((response) => response.json());
What happens to the document
It is deleted the moment it has been converted, before the response reaches you. Anything uploaded but never converted is removed within the hour, so an abandoned upload does not linger either.
Keys are namespaced per organization and checked on read. A key belonging to
someone else answers 404, the same as one that never existed.