Endpoints on Autocode run statelessly. This means that unlike in a traditional server environment, any data stored in-memory as a variable or even in the file system under tmp/ is not guaranteed to persist across executions.
tmp/
However, many apps require state, and while you're welcome to use any third-party solution you'd like such as Airtable, Postgres, or Box, Autocode provides a simple key-value store API called utils.kv. It's scoped to your user account so that only you can access data you store, and it's convenient for persisting simple data across function executions. You can even set a TTL to have data automatically expire! You can use it like this:
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN}); await lib.utils.kv.set({ key: 'somekey', value: 'stored value' }); let storedValue = await lib.utils.kv.get({ key: 'somekey' }); console.log(storedValue); // prints 'stored value'
Because storage is tied to your user account rather than to a specific token or app, you should be wary of conflicts around two different apps relying on the same key for storage. For more examples, check out the API documentation page.
You can store a maximum of 1024 key-value pairs at a time. Keys may be up to 1kb in size, and values may be up to 18kb.