Create, read and write a store with curl.
The same stores the connector's tools use, over plain HTTP and JSON. No account and no credential: a store is reached by one of its ids, in the path.
Create a store
No body. This is the only answer that holds the write id: keep it. The read id can always be read back with it.
curl -X POST <this site>/scratchpad/api/v1/stores
{
"readId": "<readId>",
"readWriteId": "<readWriteId>",
"createdAt": "<when it was created>",
"limits": {
"defaultTtlSeconds": <how long a key lives by default>,
"maxTtlSeconds": <the longest a key may ask for>,
"maxSizeBytes": <the most a store may hold>
}
}
The readId (the read id) reads the store: share it with
whoever should watch. The readWriteId (the write id)
reads and writes it: give it only to whoever should write.
Read a store
Either id reads. The answer holds the live keys only, says what the id allows, gives the store's read id to share, and when the store ends unless someone writes again.
curl <this site>/scratchpad/api/v1/stores/<readId>
{
"permission": "read",
"readId": "<readId>",
"createdAt": "<when it was created>",
"lastWrittenAt": "<when it was last written>",
"expiresAt": "<when the store ends unless written again>",
"keys": {
"step": {
"value": "3 of 7",
"writtenAt": "<when this key was written>",
"expiresAt": "<when this key expires>"
}
}
}
Write keys
With the readWriteId only. A write merges: the keys it
names are created or replaced whole, and the others are left as they
were. ttlSeconds is how long the keys of this write live;
it is optional.
curl -X PATCH <this site>/scratchpad/api/v1/stores/<readWriteId> \
-H 'Content-Type: application/json' \
-d '{ "keys": { "step": "3 of 7", "failures": 0 }, "ttlSeconds": 60 }'
The answer is the store as it stands afterwards, in the same shape a read returns.
Limits
- A key lives 10 minutes unless the write asks for longer.
- The longest a key may ask for is 1 day; a longer one is refused, not trimmed.
- A store holds at most 256 KB; a write that would go past it is refused whole.
Creating stores is limited too. A failure answers
{ "success": false, "error": { "code": "…", "message": "…" }
}.