PUT/documents/{documentId}/baseline-stages/{baselineId}/segments/{segmentIndex}
Stage one rotation baseline segment
Operation documents.baselineStages.segments.stage
Description
Stages one segment of the baseline, in index order: the server verifies its signed write header and envelope and that it starts every peer where the staged segments left it. The final segment is never staged; it travels in the rotating request. Sending the same index with the same ciphertext again is acknowledged without a write, an index that is not the stage's next returns 409 document_baseline_stage_segment_out_of_order naming the next one, and a segment that would take the stage past its byte or span cap returns 409 document_baseline_stage_too_large.
Authentication
Requires a signed-in session: the client sends its session token as a bearer token in the Authorization header.
Parameters
| Name | In | Type | Details |
|---|---|---|---|
documentId | path | string | required
|
baselineId | path | string | required
|
segmentIndex | path | integer | required
|
Request body
application/jsonDocumentSyncOutgoingUpdate
One encrypted Loro update a client uploads, with its signed write header.
12 fields
baselineIdstringoptional- lowercase UUID v4
baselineSegmentCountintegeroptional- 1 to 4,096
On a baseline's final segment only, how many segments the baseline has. Signed in the content-record metadata.
baselineSegmentIndexintegeroptional- 0 to 4,095
The segment's place in its baseline, from zero. Signed in the content-record metadata. A request sends a baseline's segments together, in index order.
baselineSegmentsDigeststringoptional- exactly 64 characters
- lowercase hexadecimal
On a baseline's final segment only, the digest of the segments before it: a hash chain over each one's index, update id, metadata hash and ciphertext hash, started from the document and baseline ids. Signed in the content-record metadata, so a reader that holds every segment can tell none was dropped, replaced or reordered.
coversThroughUpdateIdstringoptional- lowercase UUID v4
On a baseline's final segment, its author's processed cursor: every update committed up to this one was imported into the baseline or void for the author, so the segments must cover only later updates. Signed in the content-record metadata; absent means every committed update must be covered. Required on a baseline that declares no operations, the one empty segment of an author who voided every update through the cursor.
dependencyVersionVectorstringrequired- 1 to 16,777,216 characters
Version vector of the operations the update depends on outside itself: one past each peer's latest such operation, as Loro decodes the payload's start frontiers. Signed in the content-record metadata. The server refuses an update that depends on an operation it has not committed (
document_sync_dependency_uncommitted), and a reader voids one whose payload depends on other operations. A baseline segment depends only on its baseline's earlier segments.encryptedDatastringrequired- 1 to 16,777,216 characters
Base64 ciphertext of the update under the document content key.
idstringrequired- lowercase UUID v4
Client-chosen update id; a retry with the same id is accepted only if the ciphertext and header are identical.
partialEndVersionVectorstringrequired- 1 to 16,777,216 characters
Version vector the update brings the document to. It must declare at least one operation past
partialStartVersionVector, except on the one segment of an empty baseline, which signscoversThroughUpdateId.partialStartVersionVectorstringrequired- 1 to 16,777,216 characters
Version vector the update starts from.
plaintextHashstringrequired- not empty
Hash of the plaintext update, committed by the write header.
writeHeaderobject with any fieldsrequiredSigned write header binding the ciphertext to the document, access manifest, content-key epoch, target hash, and writer.
Other fields are allowed.
Responses
200 OK
application/jsonDocumentBaselineStageStatusResponse
A rotation baseline stage as the server holds it.
7 fields
baselineIdstringrequired- lowercase UUID v4
The staged baseline's id.
contentKeyCommitmentstringrequired- exactly 64 characters
- lowercase hexadecimal
Commitment of the content key the stage is for.
contentKeyEpochintegerrequired- greater than 0
Content-key epoch the stage is for.
expiresAtstringrequired- not empty
When the stage expires unless another segment or header arrives first, as an ISO 8601 instant.
nextSegmentIndexintegerrequired- 0 to 4,095
Index the next staged segment must carry, and the index of the final segment a rotating request sends to commit the stage now.
segmentsDigeststringrequired- exactly 64 characters
- lowercase hexadecimal
The baseline digest over the segments staged so far: what a final segment sent now must sign as
baselineSegmentsDigest.stagedBytesintegerrequired- at least 0
Bytes the stage stores so far: each staged segment's ciphertext, signed vectors, plaintext hash and write header. A stage holds at most 1 GiB.
Other fields are allowed.
Other responses
| Status | Meaning | Body |
|---|---|---|
| 400 | Bad Request |
|
| 401 | Unauthorized |
|
| 402 | Payment Required |
|
| 403 | Forbidden |
|
| 404 | Not Found |
|
| 409 | Conflict |
|
| 413 | A serialized staged segment is limited to 16777216 bytes |
|
| 500 | Internal Server Error |
|
| 503 | Service Unavailable |
|
Additional rules
The server also enforces these rules, which the schema above cannot express.
baselineIdandbaselineSegmentIndexmust be absent together or both present;baselineSegmentCountandbaselineSegmentsDigestappear only together and only with them, marking a baseline's final segment; only a final segment may carrycoversThroughUpdateId.