Skip to content

Object API and Capability Edge

blobgw serves the trusted internal object API. blobgw-edge is the externally facing layer in front of it. The edge authorizes each request with a short-lived Ed25519 capability token.

blobgw HTTP API

Data routes are versioned under /v1. Operational routes sit at the root.

MethodPathDescription
PUT/v1/objects/{ref...}Store the request body under ref. The Content-Type header, which defaults to application/octet-stream, drives the compression policy. Returns 201 with object info JSON.
GET/v1/objects/{ref...}Stream the object bytes.
HEAD/v1/objects/{ref...}Object metadata as headers.
DELETE/v1/objects/{ref...}Delete one object. Returns 204.
GET/v1/objects?prefix=&after=&limit=List objects as a JSON array. When more results remain, the response carries an X-Blobgw-Next-Cursor header. Pass it back as after.
DELETE/v1/objects?prefix=Bulk-delete by prefix. Returns {"deleted": N}. An empty prefix is rejected with 400.
POST/v1/stagedStart a stage-then-finalize upload (see below).
POST/v1/finalizeFinalize a staged upload: {"ref": "..."}.
GET/healthz, /readyzLiveness and readiness. Readiness checks the configured backends.
GET/metricsPrometheus-format request counters.
GET/admin/usage?domain=Per-domain rollup of physical bytes, logical deduplicated bytes, and compression ratio.
POST/admin/backfill-packs?domain=Maintenance job that refreshes pack-size accounting.
POST/admin/gc?domain=On-demand GC for one tenant. Returns 501 unless tenant routing is configured.

Object info JSON contains ref, domain, content_hash (SHA-256 of the full object), size, content_type, created_at, version, and, when present, user_meta. GET and HEAD set Content-Type, Content-Length, and a quoted ETag taken from the content hash. HEAD also returns X-Blobgw-Domain, X-Blobgw-Created-At, X-Blobgw-Version, X-Blobgw-Pending, and X-Blobgw-User-Meta (JSON). The last one is omitted when an object has no user metadata.

Error responses use a {"error": "..."} body. Not-found errors return 404 and invalid refs return 400. Finalizing a ref that isn’t staged, or a failed integrity check, returns 409.

Tenant routing

Without -tenant-config, a gateway serves a single domain (-domain). Requests may omit a domain, but any explicit X-Blobgw-Domain that doesn’t match -domain is rejected.

With -tenant-config, every data request must send exactly one X-Blobgw-Domain header that names a configured tenant. A missing or unknown tenant fails closed. There is no fallback to -domain. Successful responses echo X-Blobgw-Domain so clients can verify where data landed. This header selects storage but does not authenticate the caller. See Operations.

Python client

blobgw-client is a synchronous client with no runtime dependencies. It requires Python 3.10+ and is licensed under Apache-2.0. It targets the trusted object API.

from blobgw_client import BlobGWClient, BlobStorageServiceAdapter
client = BlobGWClient("http://127.0.0.1:8080") # timeout=60.0 by default
client.put("documents/hello.txt", b"hello", "text/plain")
assert client.get("documents/hello.txt") == b"hello"
info = client.head("documents/hello.txt") # ObjectInfo
client.exists("documents/hello.txt") # bool
objects = client.list("documents/") # follows cursors to completion
page, cursor = client.list_page("documents/", limit=100)
client.delete("documents/hello.txt")
client.delete_prefix("documents/") # returns count deleted
adapter = BlobStorageServiceAdapter(client)
adapter.store_file("documents/hello.txt", b"hello", "text/plain")

get_stream() streams a large object. Errors raise BlobGWError, with NotFound and IntegrityError as subclasses. The client is stateless and thread-safe. Async applications can call it through asyncio.to_thread.

Install instructions are in the Quickstart.

Stage-then-finalize (presigned) uploads

For large or client-direct uploads, blobgw issues a pending ref and a short-lived upload URL. The client uploads the raw bytes to that URL, and finalize then chunks and deduplicates the staged bytes and binds the ref to them.

staged = client.mint_ref(
"uploads/report.pdf",
content_type="application/pdf",
ttl_seconds=900,
content_hash="<sha256 hex>", # optional integrity gate
size=1048576, # optional integrity gate
)
# HTTP PUT the raw bytes to staged.upload_url, then:
info = client.finalize(staged.ref)
  • POST /v1/staged takes ref (generated if omitted), content_type, max_size, ttl_seconds (default 15 minutes), and the optional content_hash and size. It returns ref, upload_url, staging_key, and expires_at.
  • If you set content_hash or size, finalize returns 409 (IntegrityError in Python) when the staged bytes don’t match.
  • finalize is idempotent.
  • Real presigned URLs require -staging s3, which uses -staging-bucket or falls back to -s3-bucket. The default -staging memory returns an unreachable mem:// URL and is only meant for tests. -staging none turns staging off.
  • A sweeper reclaims staged uploads that are never finalized once they are older than -staging-ttl (default 24h).

blobgw-edge: capability gateway

blobgw-edge owns the external trust boundary. It mints and verifies capabilities, isolates tenants, and enforces quotas, rate limits, revocation, and audit. It streams upload and download bytes to and from a per-tenant gateway, so content still deduplicates within each tenant. Internal blobgw never sees the tokens.

Capabilities

A capability is an Ed25519-signed grant for one operation on one ref within one tenant. It has an expiry and a unique jti. It can also carry a maximum size, a required content type, and an expected content hash. The token format is <base64url(claims)>.<base64url(signature)>. A key ID in the claims selects the verification key, which allows key rotation.

Allowed operations are PUT, GET, HEAD, DELETE, STAGE, and FINALIZE.

Routes

MethodPathDescription
POST/capabilitiesMint a capability for the asserted identity.
POST/revokeRevoke a token by jti, with an optional expires_at. Requires an asserted identity.
PUT / GET / HEAD / DELETE/blob/{ref...}Data path. The token goes in ?cap= or in Authorization: Bearer.
POST/staged/{ref...}Mint a presigned staging upload (STAGE capability).
POST/finalize/{ref...}Finalize a staged upload (FINALIZE capability).
GET/healthzLiveness.

/capabilities reads the tenant and subject from identity headers set by your authenticating proxy: X-Auth-Tenant-ID and X-Scitrera-User. The tenant comes only from that asserted identity or from a verified token, so a caller cannot reach another tenant’s namespace.

Mint request body:

{
"op": "PUT",
"ref": "docs/report.pdf",
"max_size": 10485760,
"content_type": "application/pdf",
"content_hash": "<sha256 hex, optional>",
"ttl_seconds": 300,
"require_auth": false,
"match_mode": "exact"
}

The response contains token, capability_url (for example /blob/docs/report.pdf?cap=...), op, ref, tenant, and expires_at.

  • Shareable tokens (require_auth: false, the default under -default-require-auth=false) work as bearer URLs. Their TTL is capped by -shareable-max-ttl (default 5m).
  • Auth-bound tokens (require_auth: true) also check the live identity headers on every data request. match_mode is exact (tenant and subject) or same-tenant. Their TTL is capped by -auth-bound-max-ttl (default 60m).

Key edge flags

Run blobgw-edge -help to see every flag.

FlagDefaultPurpose
-addr:8090Listen address
-audienceblobgw-edgeCapability audience (this edge’s identity)
-key-seed-hexempty32-byte hex Ed25519 seed. Empty generates an ephemeral key, so tokens stop verifying after a restart.
-backendlocallocal (development) or s3, which routes each tenant to its own bucket through -tenant-config
-index / -index-database-urlmemory / $BLOBGW_DATABASE_URLShared dedup and ref index (memory or postgres)
-policy / -database-urlmemory / $BLOBGW_EDGE_DATABASE_URLStore for quota, rate-limit, and revocation state (memory or postgres)
-default-ttl15mDefault capability TTL
-existence-modetrustedconfidential refuses HEAD existence checks
-max-object-size0Global upload ceiling (0 = unlimited)
-quota-max-bytes, -quota-max-objects0Per-tenant quotas (0 = unlimited)
-rate-per-sec, -rate-burst0Per-key token-bucket rate limit (0 = off)
-revocation-ttl24hHow long a revoked jti is kept. Keep this at least as long as your maximum capability TTL.

Use -policy postgres wherever revocations and quotas need to survive restarts.