Publish eventLabs 0.5.0
This commit is contained in:
101
docs/API.md
Normal file
101
docs/API.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# eventLabs REST API
|
||||
|
||||
The authenticated API namespace is `eventlabs/v1`. On a site with REST rewrites, prefix routes below with `https://events.example.com/wp-json/eventlabs/v1`. With plain permalinks, send the full route in the `rest_route` query parameter.
|
||||
|
||||
```sh
|
||||
curl --get --user "$EVENTLABS_USER:$EVENTLABS_APP_PASSWORD" \
|
||||
--data-urlencode "rest_route=/eventlabs/v1/schema" "$WORDPRESS_URL/"
|
||||
```
|
||||
|
||||
Use HTTP Basic authentication with a WordPress username and Application Password over HTTPS. Administrators and users with the **eventLabs Integration** role can use these routes. The integration credential grants eventLabs access for the WordPress site. A workspace ID identifies a record's owner in burnWorks. Apply workspace authorization in the calling service.
|
||||
|
||||
## Routes
|
||||
|
||||
| Method | Route | Behavior |
|
||||
| --- | --- | --- |
|
||||
| GET | `/schema` | JSON schemas for native writes, the burnWorks event and club payloads, and configured custom event fields. |
|
||||
| GET | `/{resource}` | List events, venues, organizers, or series. |
|
||||
| POST | `/{resource}` | Create a native record. |
|
||||
| GET, PATCH | `/{resource}/{id}` | Read or update one WordPress record. |
|
||||
| GET, PUT | `/{resource}/external/{source}/{external_id}` | Read or upsert a record by a stable integration ID. |
|
||||
| GET | `/events/{id}/occurrences` | List indexed occurrences with UTC start and end times. |
|
||||
| GET | `/categories`, `/tags` | Look up WordPress term IDs. |
|
||||
| GET | `/burnworks/workspaces/{workspace_id}/clubs` | List named clubs and sub-clubs for a workspace. |
|
||||
| PUT | `/burnworks/workspaces/{workspace_id}/clubs/{club_id}` | Register a club or update its display name, kind, and status. |
|
||||
| GET, PUT | `/burnworks/workspaces/{workspace_id}/events/{event_id}` | Read or publish the WordPress copy of a burnWorks event. |
|
||||
|
||||
`{resource}` is `events`, `venues`, `organizers`, or `series`. All write requests use `Content-Type: application/json`. Native resource, occurrence, and term lists return `items` and a continuation field. Follow `next_after_id` with `after_id`, `next_after_start` with `after_start`, or `next_page` with `page`. A null continuation marks the end. The default limit is 50 and the maximum is 100. Resource lists accept the inclusive UTC `modified_since` timestamp.
|
||||
|
||||
## Create or update an event
|
||||
|
||||
```sh
|
||||
curl --user "$EVENTLABS_USER:$EVENTLABS_APP_PASSWORD" \
|
||||
--request POST --header 'Content-Type: application/json' \
|
||||
--data '{
|
||||
"title": "Garden workshop",
|
||||
"description": "<p>Bring gardening gloves.</p>",
|
||||
"post_status": "draft",
|
||||
"schedule": {
|
||||
"start_date": "2026-12-05",
|
||||
"start_time": "10:00",
|
||||
"end_date": "2026-12-05",
|
||||
"end_time": "12:00",
|
||||
"timezone": "America/New_York",
|
||||
"all_day": false,
|
||||
"repeat": "none"
|
||||
},
|
||||
"cost": "Free",
|
||||
"metadata": {"source": "club-website"}
|
||||
}' "$WORDPRESS_URL/wp-json/eventlabs/v1/events"
|
||||
```
|
||||
|
||||
- Dates use `YYYY-MM-DD`. Timed schedules accept `HH:MM` or `HH:MM:SS`, with an IANA time zone or UTC. All-day start and end dates are inclusive.
|
||||
- Repeat modes are `none`, `daily`, `weekly`, `monthly`, and `yearly`. Use `interval`, `weekdays` (Monday = 1), `monthly` (`day` or `weekday`), `count`, `until`, `include`, and `exclude` for the rule. The calendar indexes recurring dates through a rolling two-year future window.
|
||||
- `venue`, `organizer`, `series`, `categories`, and `tags` are arrays of WordPress IDs. An empty array clears a relationship. `featured_media` is a WordPress image attachment ID or `0` to clear it.
|
||||
- `post_status` controls WordPress visibility. Writable values are `draft`, `pending`, `private`, and `publish`. The separate event `status` accepts `scheduled`, `postponed`, `cancelled`, and `moved_online`. The `hidden` flag removes an event from calendar listings.
|
||||
- `fields` carries configured eventLabs custom fields. `metadata` carries a JSON object for integration data. The response includes `id`, `post_status`, `url_public`, `revision`, and the saved schedule and relationships.
|
||||
- Venue and organizer `latitude` and `longitude` come from the saved address. Set `lookup_address: true` to retry geocoding. The response reports the result in `geocode`.
|
||||
|
||||
## Stable IDs and retries
|
||||
|
||||
`PUT /{resource}/external/{source}/{external_id}` creates a record on the first successful request and returns `201`. Later writes to the same identity return `200` with the same WordPress ID. Use lowercase letters, numbers, hyphens, or underscores for `source`. The external ID accepts letters, numbers, dots, underscores, colons, and hyphens. Source names `burnworks` and `calendar-migration` are reserved for their own workflows.
|
||||
|
||||
An item response has an `ETag`. Send that value as `If-Match` to make a write conditional on the current revision. Re-read the record after `412`. Use `If-None-Match: *` on an external PUT to create a record only when the identity is new.
|
||||
|
||||
| HTTP status | Meaning |
|
||||
| --- | --- |
|
||||
| 400 | Invalid JSON, request fields, or source identity. |
|
||||
| 401 / 403 | The request lacks an authorized eventLabs account. |
|
||||
| 404 | The requested record is unavailable. |
|
||||
| 409 | A burnWorks source version is older or repeats a version with different data. |
|
||||
| 410 | The record mapped to this external ID was permanently deleted. |
|
||||
| 412 | The revision or create-only condition failed. |
|
||||
| 422 | The event schedule or a linked record is invalid. |
|
||||
| 503 | Another write holds the record lock. Retry the request. |
|
||||
|
||||
Errors use the WordPress REST shape `{"code":"…","message":"…","data":{"status":400}}`. Successful native write responses carry an ETag and use private, no-store caching.
|
||||
|
||||
## Club and sub-club scope
|
||||
|
||||
Register a club before publishing its events. Use the exact UUIDs from burnWorks. For example, send this body to `PUT /burnworks/workspaces/{workspace_id}/clubs/{club_id}`:
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Young Gardeners",
|
||||
"kind": "subclub",
|
||||
"status": "active",
|
||||
"workspace_name": "Field Club"
|
||||
}
|
||||
```
|
||||
|
||||
`kind` accepts `organization` and `subclub`. `status` accepts `active` and `archived` and defaults to `active`. `workspace_name` is optional and labels that workspace in the Elementor picker. The club listing returns the saved name, kind, status, and `scope`.
|
||||
|
||||
Event responses include `sub_club`, the hidden assignment in `workspace_id:club_id` form, and `club`, the directory record including its kind. New local events have a blank assignment. Set or clear it on a native event with PATCH. The burnWorks event route sets it from `club_id` for synced events. Events sent before a directory update are grouped by their IDs and receive a provisional label until the club is named.
|
||||
|
||||
Elementor **Event Calendar** and **Event List** offer a **Club or sub-club** selector. A workspace choice includes its clubs. A club choice matches that exact workspace and club. For shortcodes, pass `scope="<workspace_uuid>"` or `scope="<workspace_uuid>:<club_uuid>"` to `[burn_events]`.
|
||||
|
||||
See the [burnWorks integration handoff](BURNWORKS-INTEGRATION.md) for the complete event payload and the publication gate.
|
||||
|
||||
## Public feed
|
||||
|
||||
`GET /wp-json/burn-events/v1/events` returns upcoming public occurrences with an event ID, title, public URL, and UTC start and end times. It accepts `limit` (1–50), `page`, `search`, and `category` (slug).
|
||||
Reference in New Issue
Block a user