Skip to main content

Key-value stores

A key-value store holds records by key. A record can be any content: JSON, text, an image, a PDF. Every run's default store has its INPUT (what the run started with) and often an OUTPUT, screenshots or saved state.

In the Console​

Open a run's Key-value store tab, or Storage → Key-value stores and a store.

  • Filter keys and pick a key to see its value; images are previewed. Download saves a record.
  • Load more fetches further keys when the store has more than 1,000.
  • Upload record stores a file under the key you choose, up to 100 MB. If the key exists, the record is replaced.
  • Delete removes a record for good. Actors that read that key will no longer find it.

Records​

RequestWhat it does
GET /api/v3/key-value-stores/:store/records/:keyThe record's bytes, with its content type
PUT /api/v3/key-value-stores/:store/records/:keyStore the body under the request's Content-Type
DELETE /api/v3/key-value-stores/:store/records/:keyDelete the record

Keys use letters, digits and !-_.'(), up to 256 characters. A record can be up to 100 MB (413 payload_too_large above that).

Write and read a JSON record
curl -s -X PUT "https://lantfly.com/api/v3/key-value-stores/my-state/records/progress" \
-H "Authorization: Bearer $LANTFLY_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "last_page": 12 }'

curl -s "https://lantfly.com/api/v3/key-value-stores/my-state/records/progress" \
-H "Authorization: Bearer $LANTFLY_TOKEN"
Upload a file
curl -s -X PUT "https://lantfly.com/api/v3/key-value-stores/$STORE_ID/records/report.pdf" \
-H "Authorization: Bearer $LANTFLY_TOKEN" \
-H "Content-Type: application/pdf" \
--data-binary @report.pdf

List keys​

GET /api/v3/key-value-stores/:store/keys returns keys in order:

Response
{
"data": [
{ "key": "INPUT", "size": 64, "content_type": "application/json" },
{ "key": "OUTPUT", "size": 512, "content_type": "application/json" }
],
"meta": { "count": 2, "limit": 1000, "is_truncated": false, "next_exclusive_start_key": null }
}

Up to 1,000 keys per call (limit). When meta.is_truncated is true, call again with exclusive_start_key set to meta.next_exclusive_start_key.

Each store has a keys_public_url: a signed link to its key list that works without a token. It expires after 7 days by default. A single record can also be opened with its own ?signature= link, which has no expiry of its own.

To withdraw every link already handed out, store links and record links alike:

Invalidate all public links of a store
curl -s -X POST "https://lantfly.com/api/v3/key-value-stores/$STORE_ID/rotate-signing-key" \
-H "Authorization: Bearer $LANTFLY_TOKEN"

With General resource access set to let anyone with the ID read (see Storage), keys and records can be read with the store ID alone.

Create, rename and delete​

RequestWhat it does
POST /api/v3/key-value-stores { "name": "…" }Get or create a named store
PATCH /api/v3/key-value-stores/:store { "name": "…" }Name or rename it; null makes it unnamed
DELETE /api/v3/key-value-stores/:storeDelete it and its records