Using Storage & KV Store

Store files and key-value data using Weavz's built-in Storage and KV Store integrations.

Weavz includes two built-in workspace integrations for persistent data: Storage for files and KV Store for key-value data. Both are accessed through the standard action execution API, can be configured as workspace integrations, and require no additional connections.

For the broader first-party setup flow, see Using Built-In Workspace Integrations.

The examples below assume you configured the built-in integrations with workspace-scoped persistence:

bash
curl -X POST https://api.weavz.io/api/v1/workspaces/YOUR_WORKSPACE_ID/integrations \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "alias": "storage",
    "settings": { "persistence": { "scope": "workspace" } }
  }'
 
curl -X POST https://api.weavz.io/api/v1/workspaces/YOUR_WORKSPACE_ID/integrations \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "kv-store",
    "alias": "kv-store",
    "settings": { "persistence": { "scope": "workspace" } }
  }'

For private per-user files or state, keep the default end_user scope and pass endUserId when executing actions.

Storage Integration

The Storage integration provides file CRUD operations in Weavz-managed persistent storage.

Write a File

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "actionName": "write_file",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "path": "reports/monthly.json",
      "content": "{\"revenue\": 50000, \"month\": \"January\"}"
    }
  }'

Read a File

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "actionName": "read_file",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "path": "reports/monthly.json"
    }
  }'

List Files

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "actionName": "list_files",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "prefix": "reports/"
    }
  }'

Delete a File

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "actionName": "delete_file",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "path": "reports/monthly.json"
    }
  }'

Storage Actions Summary

ActionInputDescription
write_filepath, contentWrite or overwrite a file
read_filepathRead file contents
list_filesprefixList files matching a prefix
delete_filepathDelete a file

KV Store Integration

The KV Store integration provides key-value operations for storing structured data.

Put a Value

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "kv-store",
    "actionName": "put",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "key": "user:settings:123",
      "value": "{\"theme\": \"dark\", \"notifications\": true}"
    }
  }'

Get a Value

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "kv-store",
    "actionName": "get",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "key": "user:settings:123"
    }
  }'

Delete a Value

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "kv-store",
    "actionName": "delete",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "key": "user:settings:123"
    }
  }'

List Operations

The KV Store supports list-based operations on a single key:

bash
# Add to a list
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "kv-store",
    "actionName": "add_to_list",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "key": "processed:emails",
      "value": "msg_abc123"
    }
  }'
 
# Remove from a list
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "kv-store",
    "actionName": "remove_from_list",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "input": {
      "key": "processed:emails",
      "value": "msg_abc123"
    }
  }'

KV Store Actions Summary

ActionInputDescription
putkey, valueStore a value
getkeyRetrieve a value
deletekeyDelete a key
add_to_listkey, valueAppend a value to a list
remove_from_listkey, valueRemove a value from a list

Persistence Scope

Storage, KV Store, Agent Memory, Agent Scratchpad, and Sequential Thinking read persistence policy from workspace integration settings. The action caller does not pass scope or externalId in input.

ScopeValueDescription
Current end userend_user (default)Private to the end user for the current request. Requires endUserId when running actions.
Shared workspaceworkspaceShared by all users and agents in the workspace.
Custom namespaceexternalScoped to one namespace key in the workspace. Configure the key as settings.persistence.externalId.

Connection strategy still controls which credentials an action uses; persistence scope controls who can read and write the stored state.

Current end user (default)

When you pass endUserId in the request, data is isolated per end user. This is the default persistence policy for stateful tools.

bash
curl -X POST https://api.weavz.io/api/v1/actions/execute \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "actionName": "write_file",
    "workspaceId": "YOUR_WORKSPACE_ID",
    "endUserId": "user_12345",
    "input": {
      "path": "preferences.json",
      "content": "{\"theme\": \"dark\"}"
    }
  }'

Files written by user_12345 are fully isolated from files written by user_67890. This is the recommended approach for multi-tenant applications where each end user should have their own storage namespace.

Custom namespace

Use external for state isolated by a tenant, session, project, or entity. Configure the namespace on the workspace integration:

bash
curl -X POST https://api.weavz.io/api/v1/workspaces/YOUR_WORKSPACE_ID/integrations \
  -H "Authorization: Bearer wvz_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "integrationName": "storage",
    "alias": "tenant_storage",
    "settings": {
      "persistence": { "scope": "external", "externalId": "tenant_456" }
    }
  }'

Calls through tenant_storage read and write the tenant_456 namespace. The same namespace key in different workspaces is isolated.

Practical Examples

Caching API Responses

typescript
const cacheKey = `cache:weather:${city}`
 
// Check cache
const cached = await client.actions.execute('kv-store', 'get', {
  workspaceId: 'YOUR_WORKSPACE_ID',
  input: { key: cacheKey },
})
 
if (cached.output.value) {
  const data = JSON.parse(cached.output.value)
  const age = Date.now() - new Date(data.cachedAt).getTime()
 
  // Use cache if less than 5 minutes old
  if (age < 300_000) return data.weather
}
 
// Fetch fresh data and cache it
const weather = await fetchWeatherApi(city)
await client.actions.execute('kv-store', 'put', {
  workspaceId: 'YOUR_WORKSPACE_ID',
  input: {
    key: cacheKey,
    value: JSON.stringify({ weather, cachedAt: new Date().toISOString() }),
  },
})

Tracking Processed Items

typescript
// Check if already processed
const processed = await client.actions.execute('kv-store', 'get', {
  workspaceId: 'YOUR_WORKSPACE_ID',
  input: { key: 'processed:webhooks' },
})
 
const list = JSON.parse(processed.output.value || '[]')
if (list.includes(webhookId)) return // Skip duplicate
 
// Process the webhook
await handleWebhook(payload)
 
// Mark as processed
await client.actions.execute('kv-store', 'add_to_list', {
  workspaceId: 'YOUR_WORKSPACE_ID',
  input: { key: 'processed:webhooks', value: webhookId },
})