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.
| Method | Path | Description |
|---|---|---|
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/staged | Start a stage-then-finalize upload (see below). |
POST | /v1/finalize | Finalize a staged upload: {"ref": "..."}. |
GET | /healthz, /readyz | Liveness and readiness. Readiness checks the configured backends. |
GET | /metrics | Prometheus-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 defaultclient.put("documents/hello.txt", b"hello", "text/plain")assert client.get("documents/hello.txt") == b"hello"info = client.head("documents/hello.txt") # ObjectInfoclient.exists("documents/hello.txt") # boolobjects = client.list("documents/") # follows cursors to completionpage, 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/stagedtakesref(generated if omitted),content_type,max_size,ttl_seconds(default 15 minutes), and the optionalcontent_hashandsize. It returnsref,upload_url,staging_key, andexpires_at.- If you set
content_hashorsize, finalize returns409(IntegrityErrorin Python) when the staged bytes don’t match. finalizeis idempotent.- Real presigned URLs require
-staging s3, which uses-staging-bucketor falls back to-s3-bucket. The default-staging memoryreturns an unreachablemem://URL and is only meant for tests.-staging noneturns staging off. - A sweeper reclaims staged uploads that are never finalized once they are older than
-staging-ttl(default24h).
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
| Method | Path | Description |
|---|---|---|
POST | /capabilities | Mint a capability for the asserted identity. |
POST | /revoke | Revoke 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 | /healthz | Liveness. |
/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(default5m). - Auth-bound tokens (
require_auth: true) also check the live identity headers on every data request.match_modeisexact(tenant and subject) orsame-tenant. Their TTL is capped by-auth-bound-max-ttl(default60m).
Key edge flags
Run blobgw-edge -help to see every flag.
| Flag | Default | Purpose |
|---|---|---|
-addr | :8090 | Listen address |
-audience | blobgw-edge | Capability audience (this edge’s identity) |
-key-seed-hex | empty | 32-byte hex Ed25519 seed. Empty generates an ephemeral key, so tokens stop verifying after a restart. |
-backend | local | local (development) or s3, which routes each tenant to its own bucket through -tenant-config |
-index / -index-database-url | memory / $BLOBGW_DATABASE_URL | Shared dedup and ref index (memory or postgres) |
-policy / -database-url | memory / $BLOBGW_EDGE_DATABASE_URL | Store for quota, rate-limit, and revocation state (memory or postgres) |
-default-ttl | 15m | Default capability TTL |
-existence-mode | trusted | confidential refuses HEAD existence checks |
-max-object-size | 0 | Global upload ceiling (0 = unlimited) |
-quota-max-bytes, -quota-max-objects | 0 | Per-tenant quotas (0 = unlimited) |
-rate-per-sec, -rate-burst | 0 | Per-key token-bucket rate limit (0 = off) |
-revocation-ttl | 24h | How 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.