API Documentation
Log events programmatically using the That Happened API
Authentication
All API requests require authentication using a Bearer token. Generate an API key in your Settings page after signing in.
Include the API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Log an Occurrence
Create a new occurrence for an event type.
POST
/api/v1/event_types/:id/occurrences
Request Body
JSON object with optional fields:
| Field | Type | Description |
|---|---|---|
occurred_at |
string (ISO 8601) | When the event occurred. Defaults to current time if not provided. |
attributes |
object | Key-value pairs for custom attributes. Keys are the attribute definition keys. |
Example Request
curl -X POST https://that-happened.dokku.zakfu.com/api/v1/event_types/123/occurrences \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"occurred_at": "2026-01-31T14:30:00Z",
"attributes": {
"mood": "happy",
"notes": "Great day!"
}
}'
Success Response (201 Created)
{
"id": 456,
"occurred_at": "2026-01-31T14:30:00Z",
"attributes": {
"mood": "happy",
"notes": "Great day!"
}
}
Error Response (422 Unprocessable Entity)
{
"errors": [
"Mood is required",
"Duration must be a valid duration (HH:MM:SS or MM:SS format)"
]
}
Other Error Responses
| Status | Description |
|---|---|
| 401 | Missing or invalid API key |
| 404 | Event type not found (or doesn't belong to you) |
Finding Your Event Type ID
The event type ID is shown in the URL when viewing an event type. For example, if you're on
https://that-happened.dokku.zakfu.com/event_types/123,
the ID is 123.
Attribute Value Formats
When providing attribute values, use the following formats based on the attribute type:
| Type | Format | Example |
|---|---|---|
| string | Any text | "My note" |
| text | Any text (longer content) | "Longer description..." |
| number | Integer or decimal | "42" or "3.14" |
| boolean | "true" or "false" | "true" |
| enum | One of the defined options | "happy" |
| duration | HH:MM:SS or MM:SS | "1:30:00" or "45:00" |