KosmoKrator

data

Upstash Redis Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Upstash Redis KosmoKrator integration.

7 functions 5 read 2 write API key auth

Lua Namespace

Agents call this integration through app.integrations.upstash.*. Use lua_read_doc("integrations.upstash") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Upstash Redis — Lua API Reference

get_key

Retrieve the value stored at a Redis key. Returns null if the key does not exist.

Parameters

NameTypeRequiredDescription
keystringyesThe Redis key to retrieve.

Examples

local result = app.integrations.upstash.get_key({
  key = "user:1234:session"
})

if result.value then
  print("Value: " .. result.value)
else
  print("Key not found")
end

set_key

Store a key-value pair in Redis. Optionally set a TTL (time-to-live) in seconds so the key expires automatically.

Parameters

NameTypeRequiredDescription
keystringyesThe Redis key to set.
valuestringyesThe value to store.
exintegernoTime-to-live in seconds. Key will be deleted automatically after this duration.

Examples

app.integrations.upstash.set_key({
  key = "config:theme",
  value = "dark"
})
-- With 60-second TTL
app.integrations.upstash.set_key({
  key = "cache:weather:amsterdam",
  value = '{"temp": 18, "condition": "cloudy"}',
  ex = 60
})

delete_key

Delete a key from Redis. Returns the number of keys that were removed.

Parameters

NameTypeRequiredDescription
keystringyesThe Redis key to delete.

Examples

local result = app.integrations.upstash.delete_key({
  key = "temp:data"
})

print("Deleted: " .. tostring(result.deleted))

list_keys

List Redis keys matching a glob-style pattern. Defaults to "*" to list all keys.

Parameters

NameTypeRequiredDescription
patternstringnoGlob-style pattern to match keys against. Default: "*".

Examples

local result = app.integrations.upstash.list_keys({
  pattern = "user:*"
})

print("Found " .. result.count .. " keys")
for _, key in ipairs(result.keys) do
  print("  " .. key)
end
-- List all keys
local result = app.integrations.upstash.list_keys()
print("Total keys: " .. result.count)

list_databases

List all Redis databases in the Upstash account. Returns database IDs, names, regions, and endpoints.

Parameters

None.

Examples

local databases = app.integrations.upstash.list_databases()

for _, db in ipairs(databases) do
  print(db.database_name .. " — " .. db.region .. " — " .. db.endpoint)
end

get_database

Get details for a specific Upstash Redis database by ID, including endpoint, region, and usage stats.

Parameters

NameTypeRequiredDescription
idstringyesThe Upstash database ID.

Examples

local db = app.integrations.upstash.get_database({
  id = "abc12345-xxxx-yyyy-zzzz"
})

print("Name: " .. db.database_name)
print("Region: " .. db.region)
print("Endpoint: " .. db.endpoint)

get_current_user

Get current team information from Upstash, including team name, members, and plan details.

Parameters

None.

Examples

local team = app.integrations.upstash.get_current_user()

print("Team: " .. team.name)
print("Plan: " .. (team.plan or "free"))

Multi-Account Usage

If you have multiple upstash accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.upstash.function_name({...})

-- Explicit default (portable across setups)
app.integrations.upstash.default.function_name({...})

-- Named accounts
app.integrations.upstash.production.function_name({...})
app.integrations.upstash.staging.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Upstash Redis — Lua API Reference

## get_key

Retrieve the value stored at a Redis key. Returns null if the key does not exist.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `key` | string | yes | The Redis key to retrieve. |

### Examples

```lua
local result = app.integrations.upstash.get_key({
  key = "user:1234:session"
})

if result.value then
  print("Value: " .. result.value)
else
  print("Key not found")
end
```

---

## set_key

Store a key-value pair in Redis. Optionally set a TTL (time-to-live) in seconds so the key expires automatically.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `key` | string | yes | The Redis key to set. |
| `value` | string | yes | The value to store. |
| `ex` | integer | no | Time-to-live in seconds. Key will be deleted automatically after this duration. |

### Examples

```lua
app.integrations.upstash.set_key({
  key = "config:theme",
  value = "dark"
})
```

```lua
-- With 60-second TTL
app.integrations.upstash.set_key({
  key = "cache:weather:amsterdam",
  value = '{"temp": 18, "condition": "cloudy"}',
  ex = 60
})
```

---

## delete_key

Delete a key from Redis. Returns the number of keys that were removed.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `key` | string | yes | The Redis key to delete. |

### Examples

```lua
local result = app.integrations.upstash.delete_key({
  key = "temp:data"
})

print("Deleted: " .. tostring(result.deleted))
```

---

## list_keys

List Redis keys matching a glob-style pattern. Defaults to `"*"` to list all keys.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pattern` | string | no | Glob-style pattern to match keys against. Default: `"*"`. |

### Examples

```lua
local result = app.integrations.upstash.list_keys({
  pattern = "user:*"
})

print("Found " .. result.count .. " keys")
for _, key in ipairs(result.keys) do
  print("  " .. key)
end
```

```lua
-- List all keys
local result = app.integrations.upstash.list_keys()
print("Total keys: " .. result.count)
```

---

## list_databases

List all Redis databases in the Upstash account. Returns database IDs, names, regions, and endpoints.

### Parameters

None.

### Examples

```lua
local databases = app.integrations.upstash.list_databases()

for _, db in ipairs(databases) do
  print(db.database_name .. " — " .. db.region .. " — " .. db.endpoint)
end
```

---

## get_database

Get details for a specific Upstash Redis database by ID, including endpoint, region, and usage stats.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The Upstash database ID. |

### Examples

```lua
local db = app.integrations.upstash.get_database({
  id = "abc12345-xxxx-yyyy-zzzz"
})

print("Name: " .. db.database_name)
print("Region: " .. db.region)
print("Endpoint: " .. db.endpoint)
```

---

## get_current_user

Get current team information from Upstash, including team name, members, and plan details.

### Parameters

None.

### Examples

```lua
local team = app.integrations.upstash.get_current_user()

print("Team: " .. team.name)
print("Plan: " .. (team.plan or "free"))
```

---

## Multi-Account Usage

If you have multiple upstash accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.upstash.function_name({...})

-- Explicit default (portable across setups)
app.integrations.upstash.default.function_name({...})

-- Named accounts
app.integrations.upstash.production.function_name({...})
app.integrations.upstash.staging.function_name({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.upstash.upstash_get_key({
  key = "example_key"
})
print(result)

Functions

upstash_get_key

Retrieve the value stored at a Redis key. Returns null if the key does not exist.

Operation
Read read
Full name
upstash.upstash_get_key
ParameterTypeRequiredDescription
key string yes The Redis key to retrieve.

upstash_set_key

Store a key-value pair in Redis. Optionally set a TTL (time-to-live) in seconds so the key expires automatically.

Operation
Write write
Full name
upstash.upstash_set_key
ParameterTypeRequiredDescription
key string yes The Redis key to set.
value string yes The value to store.
ex integer no Time-to-live in seconds (optional).

upstash_delete_key

Delete a key from Redis. Returns the number of keys that were removed.

Operation
Write write
Full name
upstash.upstash_delete_key
ParameterTypeRequiredDescription
key string yes The Redis key to delete.

upstash_list_keys

List Redis keys matching a glob-style pattern. Defaults to "*" to list all keys.

Operation
Read read
Full name
upstash.upstash_list_keys
ParameterTypeRequiredDescription
pattern string no Glob-style pattern to match keys against (default: "*").

upstash_list_databases

List all Redis databases in the Upstash account. Returns database IDs, names, regions, and endpoints.

Operation
Read read
Full name
upstash.upstash_list_databases
ParameterTypeRequiredDescription
No parameters.

upstash_get_database

Get details for a specific Upstash Redis database by ID, including endpoint, region, and usage stats.

Operation
Read read
Full name
upstash.upstash_get_database
ParameterTypeRequiredDescription
id string yes The Upstash database ID.

upstash_get_current_user

Get current team information from Upstash, including team name, members, and plan details.

Operation
Read read
Full name
upstash.upstash_get_current_user
ParameterTypeRequiredDescription
No parameters.