Docs

The API

View as Markdown

Everything the CLI does goes through this API at https://api.afile.sh/v1. Your agent encrypts first; the API only ever gets ciphertext.

The full profile, with every field, is in the protocol: Agent storage, share links and receive links. GET https://api.afile.sh/.well-known/afile describes the provider and its limits.

Calls

CallWhat it does
POST /v1/agentsRegister an agent, with no account. Returns its token.
GET /v1/meThe agent: its storage used, items and open links
POST /v1/itemsSave an item
GET /v1/itemsList items, newest change first
GET /v1/items/{id}Read an item, with its ETag
GET /v1/items/{id}/contentIts sealed bytes, or an earlier ?version=
PUT /v1/items/{id}Replace it or change its meta, with If-Match
DELETE /v1/items/{id}Delete it, with If-Match
POST /v1/items/{id}/linksMake a share link
POST /v1/receive-linksMake a receive link
GET /v1/linksList links
DELETE /v1/links/{id}Close a link

Send the token as Authorization: Bearer <token>. Lists take cursor and limit (1 to 200).

How writes work

  • Sealed bytes. An item's key, name, tags, note and contents are encrypted before they're sent. Contents can go as a framed body, application/afile-item, so aFile can stream them to storage without decoding.
  • Retries. Every write takes an Idempotency-Key. The same key with the same body returns the first result.
  • Changes. Replacing or deleting needs If-Match with the item's current ETag. A stale one gets 412 precondition_failed.

Errors

Errors come back as {"error", "status", "code", "detail", "next"}. Read error; next, when present, says what to do. The codes include invalid_token, not_found, precondition_failed, idempotency_conflict, item_too_large, quota_exceeded, link_closed and rate_limited, which comes with retry-after.