API Reference
Welcome to the StateBase API reference. This documentation covers all REST endpoints for building production-ready AI agents with state management, memory, and complete audit trails.Base URL
Authentication
StateBase uses API keys for authentication. Include your API key in theX-API-Key header:
Getting Your API Key
- Sign up at app.statebase.org
- Navigate to Settings → API Keys
- Click Create New Key
- Copy and store securely (keys are only shown once)
API Key Format
SDKs
We provide official SDKs for Python and TypeScript:SDK Usage
Core Concepts
StateBase is built on four core primitives:1. Sessions
Containers for agent conversations. Each session has:- Unique ID
- Mutable state (JSON object)
- TTL (time-to-live)
- Associated memories and turns
2. Turns
Individual interactions between user and agent. Each turn captures:- User input
- Agent output
- Reasoning (why the agent made this decision)
- State snapshots (before/after)
3. Memory
Long-term knowledge that persists across sessions. Memories are:- Searchable via semantic similarity
- Tagged and categorized
- User-scoped or global
4. Traces
Audit trail of all operations. Every API call creates a trace with:- Action type
- Actor (who made the change)
- Timestamp
- Details (what changed)
Request Format
AllPOST, PATCH, and PUT requests must use JSON:
Response Format
All responses are JSON with a consistent structure:Success Response
List Response
Error Response
Error Codes
| HTTP Status | Error Code | Description |
|---|---|---|
| 400 | invalid_request | Missing or invalid parameters |
| 401 | authentication_failed | Invalid or missing API key |
| 403 | permission_denied | API key lacks required permissions |
| 404 | resource_not_found | Session, turn, or memory doesn’t exist |
| 413 | payload_too_large | Request body exceeds size limit |
| 429 | rate_limit_exceeded | Too many requests (see rate limits below) |
| 500 | internal_error | Server error (contact support if persists) |
| 503 | service_unavailable | Temporary outage (retry with backoff) |
Rate Limits
Rate limits are applied per API key:| Tier | Requests/Minute | Burst Limit |
|---|---|---|
| Free | 100 | 200 |
| Pro | 1,000 | 2,000 |
| Enterprise | Custom | Custom |
Rate Limit Headers
Every response includes rate limit information:| Header | Description |
|---|---|
X-RateLimit-Limit | Max requests per minute |
X-RateLimit-Remaining | Remaining requests in current window |
X-RateLimit-Reset | Unix timestamp when limit resets |
Handling Rate Limits
When you exceed the rate limit, you’ll receive a429 response:
Pagination
List endpoints support cursor-based pagination:Pagination Parameters
| Parameter | Type | Description |
|---|---|---|
limit | integer | Max items per page (default: 20, max: 100) |
starting_after | string | ID to start after (for next page) |
Pagination Response
Idempotency
To safely retry requests without duplicating operations, use idempotency keys:- If request succeeds, response is cached for 24 hours
- If you retry with same key, cached response is returned
- No duplicate sessions are created
POST and PATCH endpoints
Webhooks
Subscribe to real-time events:Webhook Payload
Verifying Webhooks
Verify webhook signatures to ensure they’re from StateBase:Versioning
The API is versioned via the URL path:v1
Breaking changes: We’ll release new versions (v2, v3) for breaking changes. Old versions are supported for 12 months after deprecation.
Data Residency
Choose where your data is stored:| Region | Endpoint | Location |
|---|---|---|
| US | api.statebase.org | United States (default) |
| EU | eu.api.statebase.org | European Union |
| APAC | apac.api.statebase.org | Asia-Pacific |
Support
- Documentation: docs.statebase.org
- Discord: discord.gg/statebase
- Email: support@statebase.org
- Status: status.statebase.org
Quick Start
Here’s a complete example to get you started:Next Steps
- Sessions API: Create and manage sessions
- Turns API: Log conversations
- Memory API: Store long-term knowledge
- Traces API: Audit and debugging
- Quickstart Guide: Build your first agent
Ready to build? Start with the Quickstart Guide or explore the Patterns section for production-ready examples.