Skip to content

rypt docs

rypt is an HTTP API that encrypts and decrypts with keys it holds for you, in Google Cloud. A Software (software) or Hardware (hsm) key is a Cloud KMS key of its own. A Free (free) or Extra wrapped (wrapped) key is a set of data keys, one per key version, stored wrapped under one shared Cloud KMS root key at the HSM protection level. Key material stays inside rypt and Cloud KMS: no call returns it, and you cannot import your own.

It offers two modes, five operations in all:

  • Direct: encrypt and decrypt take the data itself, 1 to 65,536 bytes of plaintext a call. On a Hardware key, plaintext and aad together may be at most 8,176 bytes.
  • Envelope: wrap and unwrap take a data key, which you use to encrypt your data on your own machine. wrap can generate the data key for you.

The fifth, rewrap, works in both modes: it moves a ciphertext or a wrapped data key to the key's current version. Direct or envelope explains how to choose.

You call the HTTP API from your own code, or from Go with the client library github.com/x6c-co/rypt. From a shell, rypt-cli encrypts and decrypts files of any size, and age-plugin-rypt lets age encrypt to a rypt key, which in turn protects sops files and the restic passwords kept in them.

rypt is not zero-knowledge. In direct mode your plaintext travels to rypt in the request, and decrypt sends it back; on Software and Hardware keys it also goes to Cloud KMS, where the encryption runs. In envelope mode your data stays with you, but rypt sees every data key it wraps or unwraps for you, and on Software and Hardware keys so does Cloud KMS. rypt holds the keys that decrypt your data, and can use them.

The security model sets out what rypt sees, what it keeps and what it does not claim.

The API is at https://api.rypt.dev. Every endpoint is under /v1, except that the health check, /v1/healthz, is also served at /healthz.

Request and response bodies are JSON. Send Content-Type: application/json with every request body: a body without a JSON content type is refused with 415 unsupported_media_type.

Binary fields (plaintext, ciphertext, aad, dek, wrapped) are standard base64, the alphabet with + and /, with = padding, in requests and in responses. URL-safe or unpadded base64 is refused with 400 invalid_base64. Sizes are counted after decoding, but a request body over 128 KiB is refused whatever its fields hold: see limits.

Every response carries an x-request-id header. A failed request answers with a JSON body of error, message and request_id; errors lists every code.

Send an API token as a bearer token:

Authorization: Bearer ry_K3pQ7xTa_...

An API token is 44 characters: ry_, an 8-character prefix, _, and a 32-character secret, all letters and digits.

You issue API tokens in the dashboard, on the API tokens page. Only a dashboard session can issue, restrict or revoke one. The token is shown once, when it is issued, and cannot be recovered: if you lose it, revoke that API token and issue another. Storage says how rypt keeps it.

An API token works only with keys in its own container. A new API token has no actions unless you choose some when you issue it, and it needs the read action even to list keys. decrypt and unwrap overlap: read what each action covers before you rely on actions. Access control also covers key lists and firewalls.

A missing, malformed, wrong or revoked API token gets 401 unauthorized, and the response does not say which. From outside an API token's firewall, a request gets 403 ip_not_allowed instead, whatever its secret. A dashboard session cannot run the five operations: they answer it with 403 api_token_required.

A key's tier is chosen when the key is created and cannot be changed.

Tier API id Where encryption runs Versions Operations a month
Free free In rypt, with AES-256-GCM, under a data key wrapped by the root key 1, the only one it keeps 10,000, then only decrypt and unwrap
Extra wrapped wrapped In rypt, the same way as Free 1 included, then billed 50,000 included, then billed
Software software In Cloud KMS, on a key at the SOFTWARE protection level 3 included, then billed 100,000 included, then billed
Hardware hsm In Cloud KMS, on a key at the HSM protection level 2 included, then billed 250,000 included, then billed

Prices are on rypt.dev.

Before you store anything:

  • A Free key allows 10,000 operations a UTC calendar month. At that cap it refuses encrypt, wrap, rewrap and rotation with 429 ops_cap_reached until the month ends, while decrypt and unwrap go on, so the cap never stops you reading your data back. Paid keys are not capped: operations past the included number are billed. See the Free tier's monthly cap.
  • A paid key needs the tenant's billing in good standing to be created, to make new ciphertext, to be rotated and to have a version retired. See billing refusals.
  • A paid key keeps every version until you retire it, by hand or by setting the key to keep at most a number of versions. Its fee includes some versions, and from December 1, 2026 each version beyond them is billed by the day. See what extra versions cost.
  • A Free key keeps one version, so every rotation retires the version everything until then was encrypted under. That version keeps decrypting for 7 days and is then destroyed, so rewrap what you need within those 7 days. See rotation.

This encrypts and decrypts hello world with a Free key, using curl and jq.

  1. Sign in at dashboard.rypt.dev. Your first sign-in creates your tenant.
  2. Open Encryption keys and press Create key.
  3. Enter a Name, pick free under Tier, and press Create key.
  4. Open the key by its name in the list, and copy its Key id.

A tenant can hold one Free key, and a Free key pending deletion still holds that place. If the free option is disabled, the tenant already has one, perhaps in another container: use that key (restore it from its page first if it is pending deletion), and issue the API token in its container. See one Free key per tenant.

  1. Open API tokens and press Issue API token.
  2. Enter a Name. Under What it may do, in the Use keys group, tick encrypt and decrypt.
  3. Press Issue API token.
  4. Press Copy token and store the token. Tick I have stored this token. and press Done.

The key and the API token must be in the same container. Both pages act on the container chosen in the Container menu of the navigation. A new tenant has one, named Default.

Put both values in your shell:

export RYPT_TOKEN='ry_K3pQ7xTa_...'                       # the token
export KEY_ID='0f1e2d3c-4b5a-6978-8796-a5b4c3d2e1f0'      # your Key id

aGVsbG8gd29ybGQ= is hello world in base64 (printf 'hello world' | base64).

curl -sS -X POST "https://api.rypt.dev/v1/keys/$KEY_ID/encrypt" \
  -H "Authorization: Bearer $RYPT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"plaintext": "aGVsbG8gd29ybGQ="}' | tee encrypted.json

The response has one field:

{"ciphertext":"...base64..."}

Store the ciphertext: rypt keeps no copy of it. It names the key version it was made under, so decrypt needs only it and the key, plus the same aad if you sent one.

CIPHERTEXT=$(jq -r .ciphertext encrypted.json)
curl -sS -X POST "https://api.rypt.dev/v1/keys/$KEY_ID/decrypt" \
  -H "Authorization: Bearer $RYPT_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"ciphertext\": \"$CIPHERTEXT\"}"
{"plaintext":"aGVsbG8gd29ybGQ="}

To print the text, pipe that response through jq -r .plaintext | base64 --decode, which prints hello world. Each call was one operation of the key's monthly 10,000.

Response Cause
401 unauthorized RYPT_TOKEN is not the full token, or the API token was revoked.
403 action_not_allowed The API token was not given that action. Add it with Restrict on the API tokens page.
403 api_token_required The bearer token is a dashboard session, not an API token.
404 not_found KEY_ID is wrong, or the key is in another container than the API token.
409 key_pending_deletion The key was deleted. Press Restore on its page.

rypt-cli installs rypt, a command that encrypts and decrypts files of any size in envelope mode. For each file it has rypt wrap a new data key, encrypts the file on your machine under it, and keeps the wrapped data key in the header of the .rypt file it writes: the file does not reach rypt, but its data key does, so this is not zero-knowledge. It calls wrap and unwrap, so its API token needs those two actions, which the quickstart's API token does not have: the API token it needs shows how to issue one.

export RYPT_KEY_ID="$KEY_ID"
rypt encrypt notes.txt
rypt decrypt -o - notes.txt.rypt

The first command writes notes.txt.rypt, and the second prints what notes.txt holds. Each is one operation.

  • Direct or envelope: which mode to use, and what reaches rypt in each.
  • Access control: containers, firewalls, key lists, and what an API token may do.
  • Additional authenticated data: binding a ciphertext to its context with aad.
  • Limits: payload sizes, the Free tier's cap, and the rate limit.
  • Rotation: what a rotation does to existing ciphertext on each tier.
  • Audit log: what rypt records for each key, and how to read it.
  • Security model: what rypt sees and stores, and what it does not claim.
  • rypt-cli: the rypt command, which encrypts files of any size in envelope mode.
  • age-plugin-rypt: age files encrypted to a rypt key, with an offline recovery key.
  • sops: sops files whose data key a rypt key protects.
  • restic: a restic repository's password kept in such a sops file.
  • Errors: the error body and every code.
  • API reference: every endpoint, request and response.
  • OpenAPI document: the machine-readable description, as YAML or JSON.