Getting Started
Ostrakon is an event tracking service with OSP (One-Shot Password) authentication. This guide gets you up and running quickly.
Prerequisites
Section titled “Prerequisites”- A Ostrakon account
- An API key or your OSP credentials
Quick Start
Section titled “Quick Start”1. Create an account
Section titled “1. Create an account”Registration takes no parameters. You get your first OSP right away:
curl -X POST https://ostrakon.example.com/api/v1/auth/registerResponse:
{ "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.
2. Log in
Section titled “2. Log in”Use your OSP to get an access token:
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.
3. Create an API key
Section titled “3. Create an API key”For programmatic access, create an API key:
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).
4. Create a Trigger
Section titled “4. Create a Trigger”Triggers are containers for your events:
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.
5. Send an event
Section titled “5. Send an event”Track your first events:
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" }6. View the statistics
Section titled “6. View the statistics”Fetch your trigger's stats (the last hour by default; from, to and interval adjust the 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 }]}Key concepts
Section titled “Key concepts”Triggers
Section titled “Triggers”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
Events
Section titled “Events”An event is a single occurrence tied to a trigger. Each event can carry custom metadata.
Tenants
Section titled “Tenants”Tenants let you organize your triggers into teams or organizations with members and roles.
A pane is a saved chart on the Overview of a trigger or a group. See Panes.
Next steps
Section titled “Next steps”- Authentication - Understand the OSP system
- API Keys - Manage your API keys
- Triggers & Events - Dive deeper into triggers
- Organizations (Tenants) - Teams, roles and invitations
- Panes - Saved charts on triggers and groups
- Real-time Events - Streaming with SSE