REST API

Complete reference for the Elephantasm REST API public endpoints.

Base URL

https://api.elephantasm.com/api

All endpoints are prefixed with /api. The SDKs handle this automatically.


Authentication

All endpoints (except health check) require a Bearer token:

curl https://api.elephantasm.com/api/animas \
  -H "Authorization: Bearer sk_live_..."

API keys are created in the Elephantasm dashboard. Keys use the sk_live_ prefix.


Endpoints

GET /health

Health check endpoint. No authentication required.

curl https://api.elephantasm.com/api/health

Response 200:

{
  "status": "healthy",
  "timestamp": "2026-02-04T12:00:00Z",
  "checks": {
    "database": "healthy"
  }
}

POST /animas — Create Anima

Create a new anima (agent entity).

curl -X POST https://api.elephantasm.com/api/animas \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{"name": "my-agent", "description": "Customer support bot"}'

Request Body

NameTypeRequiredDescription
namestringrequiredHuman-readable name (max 255 chars).
descriptionstringoptionalOptional description.
metaobjectoptionalArbitrary metadata.

Response 201

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "my-agent",
  "description": "Customer support bot",
  "meta": null,
  "user_id": "...",
  "is_deleted": false,
  "created_at": "2026-02-04T12:00:00Z",
  "updated_at": "2026-02-04T12:00:00Z"
}

GET /animas/:anima_id

Get an anima by ID.

curl https://api.elephantasm.com/api/animas/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer sk_live_..."

Path Parameters

NameTypeRequiredDescription
anima_idUUIDrequiredAnima identifier.

Response 200

Returns the anima object (same schema as POST response).

Returns 404 if the anima doesn't exist or belongs to a different user.


POST /events — Create Event

Create an event (capture an interaction for memory synthesis). This is the backend endpoint for extract().

curl -X POST https://api.elephantasm.com/api/events \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "anima_id": "550e8400-e29b-41d4-a716-446655440000",
    "event_type": "message.in",
    "content": "What is the weather in San Francisco?",
    "role": "user",
    "session_id": "conv-123"
  }'

Request Body

NameTypeRequiredDescription
anima_idUUIDrequiredTarget anima ID.
event_typestringrequiredEvent type: message.in, message.out, tool.call, tool.result, system.
contentstringrequiredEvent content body.
rolestringoptionalMessage role: user, assistant, system, tool.
authorstringoptionalWho produced this event.
summarystringoptionalOptional summary.
occurred_atstringoptionalISO 8601 timestamp. Defaults to now.
session_idstringoptionalSession grouping identifier.
metaobjectoptionalArbitrary metadata (default: {}).
source_uristringoptionalSource system identifier.
dedupe_keystringoptionalCustom deduplication key.
importance_scorenumberoptionalPriority hint, 0.0–1.0.

Response 201

{
  "id": "...",
  "anima_id": "550e8400-e29b-41d4-a716-446655440000",
  "event_type": "message.in",
  "content": "What is the weather in San Francisco?",
  "role": "user",
  "author": null,
  "summary": null,
  "occurred_at": "2026-02-04T12:00:00Z",
  "session_id": "conv-123",
  "meta": {},
  "source_uri": null,
  "dedupe_key": "a1b2c3d4...",
  "importance_score": null,
  "is_deleted": false,
  "created_at": "2026-02-04T12:00:00Z",
  "updated_at": "2026-02-04T12:00:00Z"
}

Returns 409 if a duplicate dedupe_key already exists (safe to retry).


GET /animas/:anima_id/memory-packs/latest

Get the latest compiled memory pack for an anima. This is the backend endpoint for inject().

curl "https://api.elephantasm.com/api/animas/550e8400.../memory-packs/latest?preset=conversational" \
  -H "Authorization: Bearer sk_live_..."

Path Parameters

NameTypeRequiredDescription
anima_idUUIDrequiredAnima identifier.

Query Parameters

NameTypeRequiredDescription
querystringoptionalSemantic search query for memory retrieval.
presetstringoptionalCompilation preset: conversational, self_determined.

Response 200

Returns a memory pack object or null if no packs exist.

{
  "id": "...",
  "anima_id": "550e8400-e29b-41d4-a716-446655440000",
  "query": null,
  "preset_name": "conversational",
  "session_memory_count": 5,
  "knowledge_count": 3,
  "long_term_memory_count": 8,
  "has_identity": true,
  "token_count": 2847,
  "max_tokens": 4000,
  "content": {
    "context": "## Long-Term Memory Context\n\n...",
    "identity": { "prose": "..." },
    "session_memories": [...],
    "knowledge": [...],
    "long_term_memories": [...],
    "temporal_context": { "formatted": "Last interaction: 2 hours ago..." }
  },
  "compiled_at": "2026-02-04T12:00:00Z",
  "created_at": "2026-02-04T12:00:00Z"
}

The content.context field contains the pre-formatted string that as_prompt() / asPrompt() returns in the SDKs.


GET /subscriptions/usage

Get current subscription usage statistics.

curl https://api.elephantasm.com/api/subscriptions/usage \
  -H "Authorization: Bearer sk_live_..."

Response 200

Returns current usage metrics for your subscription plan.


Error Responses

All errors follow a consistent format:

{
  "detail": "Human-readable error description"
}
StatusMeaningWhen
401Authentication failedMissing or invalid API key
404Not foundResource doesn't exist or RLS isolation
409ConflictDuplicate dedupe_key on event creation
422Validation errorInvalid request parameters
429Rate limitedToo many requests or plan limit exceeded
5xxServer errorInternal errors

The SDKs map these HTTP status codes to typed exceptions/errors automatically. Use the Python SDK or TypeScript SDK for a better developer experience.