Setu Recipes: reusable digital workers across every app.Browse templates

Integrations / Upstash Redis

Upstash Redis

Redis over HTTP through the Upstash REST API: read and write keys, scan by pattern, work with hashes and counters, set expiries, or run any Redis command on your own Upstash database. You give the database's REST address and its REST token.

10 actions API key 5 read3 write2 destructive Calls upstash.io

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "upstash" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

This toolkit uses a single credential and requests no scopes.

Actions

Count keysreadupstash.dbsizeCount the keys in the database (Redis DBSIZE).

No input.

TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.dbsize",
  input: {},
});
Delete keydestructiveupstash.delete_keyDelete a key and its value (Redis DEL). Returns 1 when the key existed and 0 when it did not.
InputTypeDescription
keystringRequiredThe Redis key
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.delete_key",
  input: {
    "key": "<key>"
  },
  confirm: true,
});
Get keyreadupstash.getRead the string value of a key (Redis GET). The value is null when the key does not exist.
InputTypeDescription
keystringRequiredThe Redis key
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.get",
  input: {
    "key": "<key>"
  },
});
Get hashreadupstash.hgetallRead every field and value of a hash key (Redis HGETALL). The result is a flat list: field, value, field, value, and so on.
InputTypeDescription
keystringRequiredThe Redis key
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.hgetall",
  input: {
    "key": "<key>"
  },
});
Increment counterwriteupstash.incrAdd 1 to the integer stored at a key, creating it at 1 if missing (Redis INCR). Returns the new value.
InputTypeDescription
keystringRequiredThe Redis key
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.incr",
  input: {
    "key": "<key>"
  },
});
Run any Redis commanddestructiveupstash.run_commandRun any Redis command given as a list, command name first, for example ["LRANGE", "queue", 0, 9] or ["HSET", "user:1", "plan", "pro"]. This can read, change or delete data, including FLUSHALL, so it is treated as destructive and needs confirmation: prefer the specific actions. Blocking commands (BLPOP...), WATCH and most connection commands are not supported over HTTP.
InputTypeDescription
commandarray of string,numberRequiredThe command and its arguments, each a string or number; the command name is the first item
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.run_command",
  input: {
    "command": []
  },
  confirm: true,
});
Scan keysreadupstash.scanList keys matching a glob pattern, one page at a time (Redis SCAN, safe on large databases, unlike KEYS). Start with cursor 0; call again with the returned cursor until it is 0. A page may be empty or hold more keys than usual.
InputTypeDescription
cursorstringRequiredCursor: "0" to start, then the cursor returned by the previous call
matchstringRequiredGlob pattern, e.g. user:* (use * for every key)
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.scan",
  input: {
    "cursor": "<cursor>",
    "match": "<match>"
  },
});
Set keywriteupstash.setSet a key to a string value with no expiry (Redis SET). Overwrites any existing value.
InputTypeDescription
keystringRequiredThe Redis key
valuestringRequiredThe string value to store
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.set",
  input: {
    "key": "<key>",
    "value": "<value>"
  },
});
Set key with expirywriteupstash.set_with_expirySet a key to a string value that expires after a number of seconds (Redis SETEX). Overwrites any existing value.
InputTypeDescription
keystringRequiredThe Redis key
secondsintegerRequiredSeconds until the key expires
valuestringRequiredThe string value to store
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.set_with_expiry",
  input: {
    "key": "<key>",
    "seconds": 1,
    "value": "<value>"
  },
});
Get key time to livereadupstash.ttlGet the seconds left before a key expires (Redis TTL): -1 when the key never expires, -2 when it does not exist.
InputTypeDescription
keystringRequiredThe Redis key
TypeScript
await setu.execute({
  userId: "user_1",
  action: "upstash.ttl",
  input: {
    "key": "<key>"
  },
});