Skip to main content
This walkthrough takes you from a fresh API key to a working chat round-trip in five minutes.

0. Prerequisites

  • A workspace with at least one published agent (use Studio to create one if you don’t have any).
  • A workspace API key (see Authentication).
Export the key once so the snippets below are copy-pasteable:
export GENNIA_API_KEY="gsk_your_key_here"

1. Verify the key

The health endpoint validates the key and returns the workspace it’s bound to.
curl "https://api.gennia.ai/public/api/v1/health" \
  -H "X-Api-Key: $GENNIA_API_KEY"
Response
{
  "status": "ok",
  "workspacePublicId": "9c3a4d22-1a8d-4b3f-9b1e-7a0f0c4f3e21",
  "apiKeyPublicId": "7f2b1c44-6e90-4d2a-83b5-c1f2d3a4b5c6"
}
A non-ok response — or any 401 — means stop. Re-check Authentication before continuing.

2. List your agents

curl "https://api.gennia.ai/public/api/v1/agents" \
  -H "X-Api-Key: $GENNIA_API_KEY"
The response is paginated. Save the publicId of an agent that has status: "published" — you’ll need it next.
Response (trimmed)
{
  "items": [
    {
      "publicId": "1b2c3d4e-5f60-4a7b-8c9d-0e1f2a3b4c5d",
      "name": "Support Bot",
      "status": "published",
      "description": "Answers questions about billing and account access."
    }
  ],
  "page": 1,
  "limit": 20,
  "total": 1,
  "totalPages": 1
}

3. Send a message

curl "https://api.gennia.ai/public/api/v1/agents/$AGENT_ID/messages" \
  -H "X-Api-Key: $GENNIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hi, can you summarize my account status?",
    "externalUserId": "user_42"
  }'
The endpoint blocks until the agent finishes (or timeoutSeconds expires — default is 60 seconds). The response contains the reply text, the conversation ID, token usage, and cost.
Response (trimmed)
{
  "conversationId": "9c3a4d22-1a8d-4b3f-9b1e-7a0f0c4f3e21",
  "messages": [
    {
      "role": "assistant",
      "content": "Your account is active and you have 4,500 credits remaining…"
    }
  ],
  "usage": {
    "inputTokens": 245,
    "outputTokens": 89,
    "totalCost": 0.0023
  }
}

4. Continue the conversation

Pass back the conversationId from step 3 to keep the same thread:
curl "https://api.gennia.ai/public/api/v1/agents/$AGENT_ID/messages" \
  -H "X-Api-Key: $GENNIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"content\": \"What about my next renewal?\",
    \"conversationId\": \"$CONVERSATION_ID\"
  }"

5. Streaming responses

For interactive UIs, use the SSE endpoint instead of the blocking one. Same body shape; response is text/event-stream.
curl -N "https://api.gennia.ai/public/api/v1/agents/$AGENT_ID/messages/stream" \
  -H "X-Api-Key: $GENNIA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "Tell me a long story"}'
You’ll receive a stream of events: conversation-id, repeated text-delta, then debug-info with token usage and cost.

Next

Conventions

Pagination, error format, common headers.

Full reference

Every endpoint with try-it-out and schemas. Browse under “Endpoints” in the sidebar.