API Reference

Tenant Management

Build multi-tenant applications with isolated memory stores for each of your customers. One API key controls all tenants, with billing rolled up to your organization.

Tenant Isolation

Each tenant has completely isolated memory data

Auto-Creation

Tenants are created automatically on first API call

Shared Pool Billing

All usage counts against your organizations plan

Base URL

$https://memory.hypersparkai.com//api/v1/tenants
GET/api/v1/tenants

List Tenants

Retrieve all tenant organizations under your parent organization with usage statistics.

Headers

HeaderValueRequired
AuthorizationBearer <api_key>Yes

Example Request

curl -X GET "https://memory.hypersparkai.com//api/v1/tenants" \
  -H "Authorization: Bearer hsmem_your_api_key"

Response

{
  "success": true,
  "tenants": [
    {
      "id": "org_abc123xyz",
      "name": "Acme Corporation",
      "slug": "acme-corp",
      "displayName": "Acme Corporation",
      "status": "active",
      "queryLimit": null,
      "queriesThisPeriod": 1523,
      "memoryCount": 4521,
      "lastActiveAt": "2024-12-30T14:22:00Z",
      "createdAt": "2024-01-15T10:30:00Z"
    }
  ],
  "total": 1
}
POST/api/v1/tenantsadmin

Create Tenant

Create a new tenant organization under your parent organization.

Request Body

ParameterTypeRequiredDescription
namestringYesDisplay name (max 100 chars)
slugstringNoURL-friendly ID (lowercase, hyphens, max 50 chars)

Example Request

curl -X POST "https://memory.hypersparkai.com//api/v1/tenants" \
  -H "Authorization: Bearer hsmem_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corporation",
    "slug": "acme-corp"
  }'

Response

{
  "success": true,
  "tenant": {
    "id": "org_abc123xyz",
    "name": "Acme Corporation",
    "slug": "acme-corp",
    "displayName": "Acme Corporation",
    "status": "active",
    "queryLimit": null,
    "memoryCount": 0,
    "userCount": 0,
    "createdAt": "2024-12-31T10:30:00Z",
    "updatedAt": "2024-12-31T10:30:00Z"
  },
  "tenantId": "org_abc123xyz"
}
GET/api/v1/tenants/:tenantId

Get Tenant Details

Retrieve detailed information about a specific tenant organization.

Path Parameters

ParameterTypeDescription
tenantIdstringThe unique tenant organization ID

Example Request

curl -X GET "https://memory.hypersparkai.com//api/v1/tenants/org_abc123xyz" \
  -H "Authorization: Bearer hsmem_your_api_key"

Response

{
  "success": true,
  "tenant": {
    "id": "org_abc123xyz",
    "name": "Acme Corporation",
    "slug": "acme-corp",
    "displayName": "Acme Corporation",
    "status": "active",
    "queryLimit": 10000,
    "usageResetDay": 1,
    "notes": "Enterprise customer - priority support",
    "parentOrganizationId": "org_parent123",
    "orgType": "tenant",
    "memoryCount": 4521,
    "userCount": 45,
    "lastActivity": "2024-12-30T14:22:00Z",
    "lastActiveAt": "2024-12-30T14:22:00Z",
    "createdAt": "2024-01-15T10:30:00Z",
    "updatedAt": "2024-12-30T14:22:00Z"
  }
}
PATCH/api/v1/tenants/:tenantIdadmin

Update Tenant

Update a tenant organization's name or slug.

Request Body

ParameterTypeDescription
namestringNew display name (max 100 chars)
slugstringNew URL-friendly identifier

Example Request

curl -X PATCH "https://memory.hypersparkai.com//api/v1/tenants/org_abc123xyz" \
  -H "Authorization: Bearer hsmem_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Corp International"
  }'

Response

{
  "success": true,
  "tenant": {
    "id": "org_abc123xyz",
    "name": "Acme Corp International",
    "slug": "acme-corp",
    "displayName": "Acme Corp International",
    "status": "active",
    ...
  }
}
DELETE/api/v1/tenants/:tenantIdadmin

Delete Tenant

Permanently delete a tenant organization and all its associated data.

Example Request

curl -X DELETE "https://memory.hypersparkai.com//api/v1/tenants/org_abc123xyz" \
  -H "Authorization: Bearer hsmem_your_api_key"

Response

Returns HTTP 204 No Content on success.

Automatic Tenant Creation

You don't need to explicitly create tenants before using them. When you pass a new tenantId to any memory endpoint (like /api/v1/memory/ingest), the tenant is automatically created on first use.

// First call with new tenantId auto-creates the tenant
await fetch('https://memory.hypersparkai.com//api/v1/memory/ingest', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer hsmem_your_api_key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    tenantId: 'my-new-customer',  // Created automatically!
    userId: 'user_123',
    messages: [{ role: 'user', content: 'Hello world' }]
  })
});

Error Responses

StatusErrorDescription
401UnauthorizedInvalid or missing API key
403ForbiddenMissing admin scope or no access to tenant
404Not FoundTenant does not exist
429Query Limit ExceededTenant has exceeded its per-tenant query limit