Write documents (upsert, patch, append, delete)
Operations apply in the order upsert, patch, append, delete and commit atomically for the namespace. A request is never split across two commits. A namespace is created by its first write, judgment, group or subscription.
Limits on the namespace:
- A namespace holds at most 100,000,000 live documents or 256 GB
stored (what storage bills). A write that would grow it past
either is
too_large, withdetails.limit(documentsorbytes),details.documentsanddetails.bytes(the current size), anddetails.max_documentsanddetails.max_bytes. Deletes, and updates that keep a document’s size or make it smaller, are never refused for size. The size checked can be a few seconds behind the namespace’s writes. - A namespace’s documents have at most 1,024 distinct attribute
names, counted from the first write that uses each until the
namespace is deleted. A write that adds a name past it is
too_large, withdetails.id(the document),details.path(attributes.<name>, the first new name in order),details.limit(attribute_names),details.max_attribute_namesanddetails.attribute_names(the current count). A namespace that had more names before the limit keeps them and adds none. - An organization creates at most 1,000 namespaces per UTC minute.
A write that would create
one more (including a write to a deleted namespace’s name) is
rate_limited, withRetry-Afterthe seconds until the next minute anddetails.limit. Writes to namespaces that exist are never refused for it. The same holds for every request that creates a namespace: a judgment, group or subscription create.
A first write under a template prefix whose judgments your plan no
longer includes (templates need Team or above) is plan_required, and
creates nothing: a frozen template applies to no new namespace.
Namespaces that exist keep writing and answering.
A document’s images go in its images, beside attributes and
state: each name holds one image or a list of them.
They are stored before the write commits, and the document holds
each image’s ImageReference instead. For example,
an upsert with "images": {"photo": "data:image/jpeg;base64,/9j/4AAQ..."}
leaves the document holding
"images": {"photo": {"digest": "sha256:e0db…", "type": "image/jpeg", "width": 1440, "height": 960}}.
To keep an image when you write a document back, send the reference
you read: nothing is stored or billed again. state is your JSON,
and nothing in it is ever an image.
The response does not carry references; get the document to read
them. A write whose images break a rule is refused whole, and stores
none of them: invalid_image, unknown_image, too_large or
image_erased (the bytes of an image erased from the namespace), with
details.id naming the document and details.path naming the image,
such as images.photo or images.pages[2] (for more than 16 images,
the 17th in name order). An upsert over the 1 MB state limit stores
none either. A write refused for a reason that depends on the
document it changes (such as more than 16 images after a patch) can
leave the images it sent stored, and bills none of them; the next
write that names such an image bills its bytes, once.
Authorizations
An organization API key. Keys carry a role (read_write or
read_only) and may be restricted to a namespace prefix such as
acme/*, or to one namespace such as acme/prod/tenant_1. A prefix
matches on a / boundary: acme/prod/tenant_1* covers
acme/prod/tenant_1 and everything under acme/prod/tenant_1/,
never acme/prod/tenant_12.
Headers
One key per logical request, reused only on its retries. A key
belongs to one request: within your organization, the same method,
path, query and body. For 24 hours after a successful response, a
request with the key and the same body gets that response back
verbatim, with Idempotent-Replayed: true, and runs nothing. Only a
successful response is kept, so the retry of a request that failed
runs again. While the first request runs or its response is kept,
the key with a different request is idempotency_key_reused (422).
A request sent while one with its key is still running is
rate_limited with Retry-After: 1, without running: retry it to
get the first one's response. In the rare case the key can't be
checked, the request runs as if it had none.
1 - 255Path Parameters
Body
- Option 1
- Option 2
- Option 3
- Option 4
At most 1,000 documents and 64 MB per request, across all operations, images included.
Block until every named judgment has an answer for a revision at or after the one this write created. An empty list is the same as leaving it out. The first 16 documents of the write are judged at interactive priority; the rest go to ordinary catch-up and usually come back pending.
A judgment, attribute or threshold name. Names are path segments in field references, so they never contain ..
1 - 128^[A-Za-z0-9_-]+$Response
The write is durable. With wait_for, answers are
included; on timeout the write is still committed and those answers
are pending, meaning only that they were not ready within the
wait. A get works freshness out from the stored answer, so it can
report the same answer as unavailable (never judged in this
incarnation, and nothing will judge it on its own) or stale (a
policy that will not judge this revision on its own).