Skip to main content
Categories provide a simple classification layer for events in Eventify. Each category has only a name field, keeping the resource lightweight and easy to manage. Events reference a category via their category_id foreign key, and the category object is included as an eager-loaded relation whenever you fetch event data through the Events API. Use the five endpoints below to list, retrieve, create, update, and delete categories.

The category object

integer
Auto-incremented primary key uniquely identifying the category.
string
Human-readable display name for the category (e.g. "Technology", "Music", "Sports").
datetime
ISO 8601 datetime string set automatically when the record is first created.
datetime
ISO 8601 datetime string updated automatically whenever the record is modified.

GET /api/category

Returns an array of all category records in the database. No filtering, pagination, or sorting parameters are supported — the full collection is always returned.
Response — 200 OK
Returns an empty array [] with status 200 when no categories exist.

GET /api/category/{id}

Returns a single category identified by its integer id. Path parameter
integer
required
The unique identifier of the category to retrieve.
Response — 200 OK
Error responses

POST /api/category

Creates a new category. The only required field is name. Returns the created category object with HTTP 201 Created. Request body
string
required
Display name for the new category. Maximum 255 characters. Must be a non-empty string.
Response — 201 Created
Error responses

PUT /api/category/{id}

Updates an existing category. The name field is optional — if omitted, the existing value is preserved. The record is located by id before any update is applied. Path parameter
integer
required
The unique identifier of the category to update.
Request body
string
New display name for the category. Maximum 255 characters. If provided, must be a non-empty string.
Response — 200 OK
Error responses

DELETE /api/category/{id}

Permanently deletes the category with the given ID. Path parameter
integer
required
The unique identifier of the category to delete.
Response — 200 OK
Error responses
Deleting a category that is currently referenced by one or more events will set those events’ category_id to null (cascade set null behaviour defined in the events migration). Verify that no events are using a category before deleting it if referential integrity matters to your application.