POST /namespaces/:namespace/documents
Writes 1-100 documents. Conare splits each into passages, then embeds and indexes them. Writing an
existing id replaces the whole document: its text, metadata and user. The first write creates the
namespace.
Response
Request
documents(array, required): 1-100 documents, each id at most once.
id(string): 1-256 characters ofA-Z a-z 0-9 . _ : -, starting with a letter or digit. Generated if you leave it out.text(string, required): Up to 256 KiB, not blank.metadata(object): Values to filter on.user(string): Who the document belongs to. See Users.seq(integer): Your sequence number for the document, 0 to 2^53. See Sequence numbers.if_version(integer): Write only if the document is at this version.
Response
ids: The documents’ ids, in request order.versions: Their versions after the write, in the same order.results: What the write did with each document, in the same order.id: The document’s id.result:created,updated,unchangedorstale. See Results.version: Its version after the write.chunks: Its passages.chunks_embedded: The passages this write embedded.stored_seq: Withstale, theseqConare holds.
Results
- A document is
unchangedwhen its text, metadata anduserare the ones stored. Itsversionandupdated_atstay, andchunks_embeddedis 0. If it raisesseq, the newseqis stored and its version changes. - An
updateddocument embeds only the passages it didn’t already hold. The others keep their stored vectors. - When Conare’s embedding model changes, a document written under the old one is
updatedand embedded again, even if you send it as stored.
Metadata
Metadata values are strings, numbers, booleans or arrays of strings:- Up to 32 keys of 1-64 characters of
A-Z a-z 0-9 _ . -, starting with a letter.id,text,vectorandttl_at_msare reserved. - A string is up to 4 KiB, and an array holds up to 256 strings.
- A document holds up to 256 distinct values. A number or a short string counts as two, and an array
item, a boolean or a long string as one. A
usercounts as one, plus one per:in it.
Users
Setuser to say whose a document is, when one namespace holds many users’ documents. A
query can then keep to one user, or to a group of users: use : to group them, such
as tenant-7:u_42, and query tenant-7: for the whole group.
- A user is 1-128 characters of
A-Z a-z 0-9 . _ : @ -, starting with a letter or digit, with at most 8:. - It’s separate from metadata: a
usermetadata key is a different value, and a filter can’t match the document’suser. - A write without
userremoves the stored one.
Sequence numbers
Setseq to keep an older copy of a document from replacing a newer one, such as when two workers
sync the same source. Use a number that grows with each copy, such as the source’s last-modified
time in milliseconds:
Response
- A write with a lower
seqthan stored isstale: nothing is written, andstored_seqsays what Conare holds. - A write with an equal or higher
seqis written as usual, and stores itsseq. - A write without
seqis neverstale, and keeps the storedseq. if_versionis checked first.
Versions
A write that stores something new gives a document a largerversion. An unchanged write keeps
it, unless it raises seq. Versions only grow; they don’t count writes. Send the version back as
if_version to write only if the document hasn’t changed since you read it:
409 version_conflict. if_version: 0
writes only a document that doesn’t exist yet.
Behavior
- A request isn’t atomic. If it fails, some of its documents may already be written. Retry with the
same ids, which replace rather than duplicate. Without
if_version, a document already written comes backunchangedif it still holds the same content and embedding model, and isn’t embedded again. A retry withif_versioncan answer409 version_conflictbecause its first attempt landed: get the document to check. Send your own ids if you may retry: an id left out is generated again on each request. - Only
createdandupdateddocuments count as documents written in the console’s Usage. - A document is searchable as soon as its write returns.