Skip to content

Complete a chunked upload

POST
/attachment-uploads/{id}/complete
curl --request POST \
--url https://api.engram.page/attachment-uploads/example/complete \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "base_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08" }'

Assembles the parts into a live attachment and answers like POST /api/attachments. Returns 409 missing_parts (with the part numbers) while any part is missing, the session staying resumable, and 402 attachments_quota_exceeded when the file no longer fits the quota, the session then being dropped. Safe to retry: once committed, a repeat complete returns the same attachment (404 if it was since deleted or overwritten). An optional base_hash makes the commit compare-and-swap, as on POST /api/attachments: a stale one returns 409 version_conflict, the session staying open so a complete with the current hash commits it without re-uploading.

id
required
string

Upload id

Optional compare-and-swap guard

Media typeapplication/json
AttachmentUploadCompleteRequest
object
base_hash
AttachmentBaseHash

The content_hash you last read for this attachment. If it changed since, the write returns 409 version_conflict instead of overwriting.

string
nullable

Example

{
"base_hash": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
}

Uploaded

Media typeapplication/json
AttachmentResponse
object
attachment
required
AttachmentMeta
object
content_hash

Opaque content fingerprint. Stable for identical bytes and scoped to the owning account. Compare against a local copy to decide whether an upload is needed; re-uploading matching bytes is accepted but does no work.

string
nullable
created_at
string format: date-time
nullable
id
string format: uuid
nullable
mime_type
string
nullable
mtime

Client mtime (epoch seconds)

number format: float
path
required
string
size_bytes
integer
updated_at
string format: date-time
nullable

Example

{
"attachment": {
"path": "assets/diagram.png"
}
}

Quota exceeded

Media typeapplication/json
LimitError
object
current
integer
nullable
error
required
string
limit
One of:
integer
limit_key
string
nullable
reason
required
string
tier
string
nullable
upgrade_url
string
nullable

Example

{
"error": "limit_exceeded",
"limit_key": "vaults_cap",
"reason": "vaults_cap_exceeded",
"tier": "free"
}

No such upload

Media typeapplication/json
Error
object
errors
One of:
string

Example generated

{
"errors": {}
}

missing_parts, or version_conflict on a stale base_hash

Media typeapplication/json
One of:
AttachmentUploadMissingParts
object
error
required
string
missing
required
Array<integer>

Example

{
"error": "missing_parts"
}

Storage backend failure

Media typeapplication/json
MessageError
object
code

Stable machine-readable reason, where one is defined.

string
error
required
string

Example

{
"code": "blob_missing",
"error": "not found"
}

rotation_in_progress: an encryption key rotation holds the account; retry after retry-after seconds.

Media typeapplication/json
MessageError
object
code

Stable machine-readable reason, where one is defined.

string
error
required
string

Example

{
"code": "blob_missing",
"error": "not found"
}