Skip to content

Getting Started

Ostrakon is an event tracking service with OSP (One-Shot Password) authentication. This guide gets you up and running quickly.

  • A Ostrakon account
  • An API key or your OSP credentials

Registration takes no parameters. You get your first OSP right away:

Terminal window
curl -X POST https://ostrakon.example.com/api/v1/auth/register

Response:

{
"osp": "a1b2c3d4e5f6...",
"account_id": "550e8400-e29b-41d4-a716-446655440000"
}

Important: Save the osp! It is your only way to log in. It is shown only once.

Use your OSP to get an access token:

Terminal window
curl -X POST https://ostrakon.example.com/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"osp": "your-osp"}'

Response:

{
"access_token": "eyJ...",
"refresh_token": "eyJ...",
"expires_in": 900
}

The refresh token is also stored in an HttpOnly cookie for extra safety.

For programmatic access, create an API key:

Terminal window
curl -X POST https://ostrakon.example.com/api/v1/keys \
-H "Authorization: Bearer VOTRE_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "my-first-key",
"scopes": ["trigger:manage:*"]
}'

The response contains the full key (key, shaped like sk_...), shown only once: copy it.

Creating a trigger requires trigger:manage (trigger:read and trigger:hit are not enough: 403). trigger:manage also covers sending events and reading the statistics used below. For production, create a key with narrower scopes instead (see API Keys).

Triggers are containers for your events:

Terminal window
curl -X POST https://ostrakon.example.com/api/v1/triggers \
-H "X-API-Key: sk_votre_cle_api" \
-H "Content-Type: application/json" \
-d '{
"name": "Page Views",
"description": "Track page views",
"tags": ["analytics", "frontend"],
"color": "#3B82F6"
}'

The response contains the trigger id (a UUID): it is the {triggerId} in the next steps.

Track your first events:

Terminal window
curl -X POST https://ostrakon.example.com/api/v1/triggers/{triggerId}/events \
-H "X-API-Key: sk_votre_cle_api" \
-H "Content-Type: application/json" \
-d '{
"metadata": {
"page": "/home",
"userId": "user_123",
"browser": "Chrome"
}
}'

202 response: the event is accepted and will be written to the database within a second.

{ "success": true, "message": "event accepted" }

Fetch your trigger's stats (the last hour by default; from, to and interval adjust the window):

Terminal window
curl https://ostrakon.example.com/api/v1/triggers/{triggerId}/stats \
-H "X-API-Key: sk_votre_cle_api"

Response:

{
"trigger_id": "550e8400-e29b-41d4-a716-446655440000",
"from": "2024-01-15T09:30:00Z",
"to": "2024-01-15T10:30:00Z",
"total": 5,
"buckets": [{ "time": "2024-01-15T10:00:00Z", "count": 5 }]
}

A trigger is a logical container that groups similar events. For example:

  • "Page Views" for page views
  • "User Signups" for sign-ups
  • "API Calls" for API calls

An event is a single occurrence tied to a trigger. Each event can carry custom metadata.

Tenants let you organize your triggers into teams or organizations with members and roles.

See Organizations (Tenants).

A pane is a saved chart on the Overview of a trigger or a group. See Panes.