Check when a paper is ready

Read one document’s processing status until Focus has prepared it.

Use a key that reads one document

Use a key with Read the details of one document (documents:read). A key can hold only the permissions its application allows. To add this permission to an existing key, open Developer access, choose Edit application and select it, then choose Edit on the key and select it there.

Read the document

Copy the document ID from the id field of a list response. When the paper is open in Focus, the ID also follows #doc= in the reader’s address. With the key in FOCUS_API_KEY, read the document:

Bash
printf 'Authorization: Bearer %s\n' "$FOCUS_API_KEY" |
  curl --silent --show-error --fail-with-body --header @- \
    'https://couldfocus.com/api/v1/documents/f8fdec9a-2a99-40ef-80d3-9fa3d298a800'
JSON
{"data":{"id":"f8fdec9a-2a99-40ef-80d3-9fa3d298a800","title":"Place cells revisited","status":"processing","createdAt":"2026-11-28T16:50:03.217Z","updatedAt":"2026-11-28T16:50:03.217Z"}}
processing
Focus is preparing the document.
ready
The document opens in the reader.
failed
Preparation stopped. The document returns to processing if Focus prepares it again.

Focus can add status values within v1. Treat a value you don’t recognize as not ready.

Wait until it is ready

Focus sends no notifications, so check about once a minute. Each check is a new request: it uses one unit and counts toward the account rate. This script waits until the paper is ready or failed, waits through 429 and 503 responses that carry Retry-After, and stops on any other error.

Python
import json, os, time, urllib.error, urllib.request

DOCUMENT = "f8fdec9a-2a99-40ef-80d3-9fa3d298a800"
request = urllib.request.Request(
    "https://couldfocus.com/api/v1/documents/" + DOCUMENT,
    headers={"Authorization": "Bearer " + os.environ["FOCUS_API_KEY"]})
status = "processing"
while status not in ("ready", "failed"):
    try:
        with urllib.request.urlopen(request, timeout=20) as response:
            status = json.load(response)["data"]["status"]
    except urllib.error.HTTPError as error:
        retry = error.headers.get("Retry-After")
        if error.code not in (429, 503) or not retry:
            code = json.load(error)["code"]
            raise SystemExit(f"HTTP {error.code} ({code})")
    if status not in ("ready", "failed"):
        time.sleep(60)
print(status)

What can go wrong

A 404 document_not_found means the library has no document with that ID, for example after it was deleted. A personal key without documents:read returns 403 insufficient_scope.