eavz

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 integrations for persistent data: Storage for files and KV Store for key-value data. Both are accessed through the standard action execution API — no additional connections required.

Storage Integration

The Storage integration provides file CRUD operations backed by S3-compatible object 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

Data Scoping

Storage and KV Store actions include a scope input property that controls data isolation. The default scope is end_user, which isolates data per end user within the workspace when endUserId is provided.

ScopeValueDescription
End User Boundend_user (default)Isolated per end user. Requires endUserId in the request.
Workspace BoundworkspaceShared across the entire workspace.
External ID BoundexternalScoped to a custom externalId value within the workspace.

End-User Scoping (Default)

When you pass endUserId in the request, data is isolated per end user. You can omit scope — it defaults to end_user.

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\"}",
      "scope": "end_user"
    }
  }'

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.

External ID Scoping

Set scope to "external" and provide an externalId to create custom scopes — useful for isolating data per tenant, session, or entity:

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": "config.json",
      "content": "{\"setting\": \"value\"}",
      "scope": "external",
      "externalId": "tenant_456"
    }
  }'

With external ID scoping, files from different tenants are fully isolated within the workspace — tenant_456/config.json and tenant_789/config.json are completely separate, and the same externalId in different workspaces is also 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 },
})