Tearleads

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

NameInTypeDetails
documentIdpathstringrequired
  • pattern ^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
baselineIdpathstringrequired
  • lowercase UUID v4
segmentIndexpathintegerrequired
  • 0 to 4,094

Request body

application/jsonDocumentSyncOutgoingUpdate

One encrypted Loro update a client uploads, with its signed write header.

12 fields
  • baselineIdstringoptional
    • lowercase UUID v4

    The rotation baseline the update is a segment of: an ordered group of updates that together carry the document's whole history at the epoch a rotation opened. Signed in the content-record metadata; absent for an ordinary update.

  • 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 signs coversThroughUpdateId.

  • 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 fieldsrequired

    Signed 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

StatusMeaningBody
400Bad Request

application/jsonErrorResponse

401Unauthorized

application/jsonSessionFailureResponse

402Payment Required

application/jsonPaymentRequiredErrorResponse

403Forbidden

application/jsonErrorResponse

404Not Found

application/jsonDocumentBaselineStageNotFoundErrorResponse

409Conflict

application/jsonDocumentBaselineStageConflictErrorResponse

413A serialized staged segment is limited to 16777216 bytes

application/jsonErrorResponse

500Internal Server Error

application/jsonErrorResponse

503Service Unavailable

application/jsonErrorResponse

Additional rules

The server also enforces these rules, which the schema above cannot express.

  • baselineId and baselineSegmentIndex must be absent together or both present; baselineSegmentCount and baselineSegmentsDigest appear only together and only with them, marking a baseline's final segment; only a final segment may carry coversThroughUpdateId.