# PulseSteer Events API – Developer Guide

**Version:** v1 · **Format:** JSON over HTTPS · **Auth:** API key

PulseSteer collects *business events* from all of your websites, apps and systems into a single dashboard, analyses
them with AI and can act on them (reply to customers, raise GitHub issues, call your webhooks, create tasks…).
This guide explains everything a developer needs to connect a downstream site or business.

- Interactive reference: `https://<api-host>/docs`
- OpenAPI 3 document: `https://<api-host>/openapi/v1.json` (import into Postman, Insomnia, NSwag, openapi-generator…)
- This guide: `https://<api-host>/docs/api-guide.md`

---

## 1. Quick start

1. In the dashboard open **Developers → API keys → New API key**. Bind it to a business and keep the default scopes.
2. Copy the key (it is shown only once). It looks like `adk_1a2b3c4d5e6f_Zq8...`.
3. Send your first event:

```bash
curl -X POST https://<api-host>/api/v1/events \
  -H "X-Api-Key: $PULSESTEER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "type": "customer.signup", "title": "New user", "contact": { "email": "jo@example.com" } }'
```

```json
HTTP/1.1 202 Accepted
{ "eventId": "3f1c…", "status": "accepted", "externalId": null }
```

The event appears on the dashboard's live stream within a second or two.

---

## 2. Authentication

Send your key in the `X-Api-Key` header (or `Authorization: Bearer <key>`). Keys are tenant-scoped and may be
**bound to one business**; events sent with a bound key are attributed to that business automatically. Keys that are
not bound must include `businessId` in each event (find it on the business's *Details* tab).

| Scope              | Allows                                                             |
|--------------------|--------------------------------------------------------------------|
| `events:write`     | `POST /api/v1/events`, `POST /api/v1/events/batch`, `GET /events/{id}` |
| `events:read`      | `GET /api/v1/events`, `GET /api/v1/events/{id}`, `GET /api/v1/actions`, `GET /api/v1/actions/{id}` – reading and tracking (§6) |
| `actions:callback` | reserved for action status integrations                            |

Check a key with `GET /api/v1/me`:

```json
{ "apiKeyName": "Shop website", "organisation": "Casey Ventures", "boundBusinessId": "8b8b…",
  "scopes": ["events:write","actions:callback"], "businesses": [{ "id": "8b8b…", "name": "Acme Online Store" }] }
```

**Keep keys server-side.** Never embed them in browser JavaScript or mobile apps; send events from your backend.
Revoke a compromised key in the dashboard – it stops working immediately.

**Rate limit:** 600 requests per minute per key (HTTP `429` when exceeded). Use the batch endpoint for bulk data.

---

## 3. The event model

Only `type` is required.

| Field           | Type                 | Notes |
|-----------------|----------------------|-------|
| `type`          | string, **required** | Lower-case dotted name, `^[a-z0-9_]+(\.[a-z0-9_]+)*$`, e.g. `payment.received`. |
| `title`         | string ≤ 500         | Short headline. Defaults to the type's display name. |
| `description`   | string ≤ 20 000      | Free text: the enquiry body, error message, notes… |
| `category`      | enum                 | `customer`, `financial`, `technical`, `marketing`, `operations`, `task`, `analytics`, `website`, `authentication`, `other`. Defaults from the type. |
| `severity`      | enum                 | `info`, `low`, `medium`, `high`, `critical`. Defaults from the type. |
| `occurredAt`    | ISO 8601             | When it happened at source. Defaults to now. Cannot be > 1 day in the future. |
| `externalId`    | string ≤ 200         | **Your id. Makes the call idempotent** per business (see §5). |
| `correlationId` | string ≤ 200         | Group related events (e.g. an order id across `order.placed` / `payment.received`). |
| `value`         | number               | Amount, count, duration… |
| `unit`          | string ≤ 50          | e.g. `installs`, `ms`, `clicks`. |
| `currency`      | ISO 4217             | When `value` is money, e.g. `GBP`. |
| `contact`       | object               | `{ "name": "...", "email": "..." }` – the customer involved. Used for replies. |
| `url`           | string               | Link back to the item in your system. |
| `tags`          | string[]             | Free-form labels. |
| `data`          | object or array      | **Any JSON** (≤ 256 KB). Stored as-is; available to rules, templates (`{{data.field}}`) and the AI. |
| `businessId`    | uuid                 | Only for keys not bound to a business. |

### Well-known event types

239 well-known event types across 16 suggested departments. Generated from `EventTypeCatalog`; the live catalogue and example JSON payloads are available at `GET /api/v1/event-types`.

Choose a department type when setting up a department. In that department's context, rule suggestions and the developer catalogue default to the matching suggested-department group. General or All event types shows the full list; custom and cross-department event types are still accepted. Department names can differ from their saved type. API keys and connectors determine the actual originating department. HR, legal and facilities workflows usually use `operations`; department and event type distinguish them. The Website department includes `website` activity such as forms and records, and `authentication` activity such as login and registration. Existing category values are preserved.

Both real-time API delivery and polling can supply these events. Adding a catalogue entry supplies naming, default title/category/severity and example fields; a sending product or configured connector must still report the event. Example payloads are optional and dates are illustrative, not legal or tax deadlines. Senders can override category and severity.

Use dotted event names or wildcard families in rules, such as `employee.*`, `invoice.*` or `support.*`. Custom types remain supported. Existing event names and defaults are retained. `approval.approved` and `approval.rejected` describe decisions in external systems and do not change PulseSteer action approval status. `task.completed` describes connected work systems; PulseSteer's To Do list emits `todo.completed`.

For a website integration, create a department named Website and bind its API key to that department. Send `website.login`, `website.registered`, `website.contact_form_submitted` or `website.record_submitted` as those activities occur. Include the visitor's contact in the event's top-level `contact` object when a reply is needed; form or record details go in `data`. Example payloads use record and user references for field mapping.

#### Administration (10)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `account.approval_required` | task | medium | A new account or submission is waiting for approval. |
| `approval.approved` | task | info | An approval was granted in a connected system; this does not approve a PulseSteer action. |
| `approval.rejected` | task | low | An approval was rejected in a connected system; this does not reject a PulseSteer action. |
| `approval.requested` | task | medium | A connected system requested a human approval decision. |
| `document.approval_required` | task | medium | A document is ready for a human approval decision. |
| `document.approved` | task | info | A document was approved in its source system. |
| `document.received` | task | info | A document arrived for filing, processing or review. |
| `document.rejected` | task | low | A document was rejected or returned for revision. |
| `pulse.event` | task | medium | Something in your PulseSteer account needs attention: a failing connector, actions waiting for approval, actions that failed, or AI Automation paused (raised by PulseSteer). |
| `pulse.quota` | task | medium | Your organisation has used a set share of this month's update allowance (e.g. 80%, 90%) or reached it (raised by PulseSteer). |

#### Customer Support (16)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `customer.cancelled` | customer | medium | A subscription or account was cancelled. |
| `customer.complaint` | customer | high | A complaint that needs a response. |
| `customer.enquiry` | customer | medium | A question or request from a customer via a contact form or chat. |
| `customer.feedback_received` | customer | low | Private feedback or a survey response was received. |
| `customer.onboarding_completed` | customer | info | A customer completed onboarding. |
| `customer.onboarding_started` | customer | info | A new customer's onboarding process began. |
| `customer.renewal_due` | customer | medium | A customer relationship or service agreement is approaching renewal. |
| `customer.review` | customer | low | A public review or rating. |
| `customer.signup` | customer | info | A new user or customer account was created. |
| `customer.updated` | customer | info | Customer profile or contact details changed. |
| `email.received` | customer | medium | An inbound email to a business mailbox. |
| `support.response_overdue` | customer | high | A support ticket missed its configured response deadline. |
| `support.ticket_created` | customer | medium | A new support case needs triage or a response. |
| `support.ticket_escalated` | customer | high | A support case needs a higher level of attention. |
| `support.ticket_resolved` | customer | info | A support case was marked resolved. |
| `support.ticket_updated` | customer | info | A ticket received a reply, reassignment or status change. |

#### Data (11)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `data.anomaly_detected` | data | medium | A count or value changed unusually compared with normal – a sudden spike or drop. |
| `data.changed` | data | info | A record or value being watched has changed. |
| `data.check_failed` | data | high | A data check found rows that break one of its rules. |
| `data.check_passed` | data | info | A data check ran and every rule passed. |
| `data.duplicate_found` | data | low | Records that should be unique appear more than once. |
| `data.missing` | data | high | Data that should be there isn't: a required record, a table that should have rows, or a scheduled import that didn't arrive. |
| `data.source_unavailable` | data | high | A data source couldn't be reached, or a check's query failed to run, so the data couldn't be checked. |
| `data.stale` | data | medium | Data hasn't been updated within its expected window. |
| `data.summary` | data | info | A value or small result read from a data source and reported as it is – e.g. how many users there are, or yesterday's order total. |
| `data.threshold_breached` | data | medium | A value in the data crossed a configured limit, e.g. stock below 10 or an unprocessed backlog over 1,000. |
| `data.validation_failed` | data | medium | One or more records failed validation – a missing required field, a wrong format or an out-of-range value. |

#### Facilities (9)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `asset.assigned` | operations | info | Business equipment was assigned to an employee or location. |
| `asset.maintenance_due` | operations | medium | An asset reached its recorded maintenance date or usage threshold. |
| `asset.repair_required` | operations | high | An asset was reported faulty or requiring repair. |
| `asset.returned` | operations | info | Assigned equipment was returned. |
| `facility.incident_reported` | operations | high | A building or site incident was recorded. |
| `facility.inspection_due` | operations | medium | A site or equipment inspection is approaching its recorded date. |
| `facility.utility_usage_high` | operations | medium | A utility reading exceeded a configured usage threshold. |
| `safety.check_due` | operations | medium | A configured safety check reached its recorded due date. |
| `safety.incident_reported` | operations | high | A workplace safety incident or near miss was recorded. |

#### Finance (31)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `bill.due` | financial | medium | A supplier bill needs paying. |
| `bill.overdue` | financial | high | A supplier bill passed its recorded due date without payment. |
| `bill.paid` | financial | info | A supplier bill was settled. |
| `bill.received` | financial | medium | A supplier invoice or bill arrived for processing. |
| `expense.approved` | financial | info | An expense claim was approved for reimbursement. |
| `expense.reimbursement_paid` | financial | info | An approved expense reimbursement was paid. |
| `expense.rejected` | financial | low | An expense claim was rejected or returned for correction. |
| `expense.submitted` | financial | medium | An expense claim is ready for review. |
| `finance.budget_exceeded` | financial | high | Actual spending exceeded a configured budget. |
| `finance.cash_balance_low` | financial | high | A monitored account's available balance fell below a configured threshold. |
| `finance.filing_due` | financial | medium | A financial filing is approaching its recorded deadline. |
| `finance.reconciliation_failed` | financial | high | A reconciliation found unmatched entries or a balance difference. |
| `finance.tax_due` | financial | medium | A tax payment is approaching the due date recorded by the source system. |
| `invoice.created` | financial | info | A customer invoice was created. |
| `invoice.credit_note_issued` | financial | info | A credit note was issued against a customer invoice. |
| `invoice.disputed` | financial | high | A customer questioned an invoice or withheld payment. |
| `invoice.overdue` | financial | high | A customer invoice is past its due date. |
| `invoice.paid` | financial | info | An invoice was settled. |
| `invoice.sent` | financial | info | A customer invoice was issued or sent. |
| `payment.chargeback` | financial | high | A payment provider reported a chargeback or payment dispute. |
| `payment.due` | financial | medium | A payment is due according to its recorded schedule. |
| `payment.failed` | financial | high | A charge was declined or failed. |
| `payment.received` | financial | info | Money in: an order, invoice payment or subscription charge. |
| `payment.refunded` | financial | medium | A refund was made. |
| `payment.scheduled` | financial | info | A payment was scheduled for a future date. |
| `payroll.approved` | financial | info | A payroll run was approved. |
| `payroll.failed` | financial | high | A payroll run or payment failed. |
| `payroll.paid` | financial | info | A payroll run completed payment. |
| `payroll.prepared` | financial | info | A payroll run is ready for review. |
| `subscription.cancelled` | financial | medium | Recurring billing stopped for a subscription. |
| `subscription.renewed` | financial | info | A recurring subscription renewed. |

#### Human Resources (14)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `employee.absence_reported` | operations | medium | An absence was recorded and may require cover or follow-up. |
| `employee.certification_expiring` | operations | medium | A qualification or certification is approaching its recorded expiry date. |
| `employee.joined` | operations | info | A new employee started and may need onboarding. |
| `employee.leave_approved` | operations | info | An employee's leave request was approved. |
| `employee.leave_requested` | operations | medium | An employee submitted a leave request for review. |
| `employee.left` | operations | medium | An employee's employment ended and offboarding may be needed. |
| `employee.onboarding_completed` | operations | info | An employee completed the onboarding checklist. |
| `employee.review_due` | operations | medium | A scheduled employee review is due. |
| `employee.training_completed` | operations | info | An employee completed assigned training. |
| `employee.training_due` | operations | medium | Assigned training is approaching its recorded deadline. |
| `employee.updated` | operations | info | An employee's role, team or administrative details changed. |
| `recruitment.application_received` | operations | info | A candidate applied for an open vacancy. |
| `recruitment.interview_scheduled` | operations | info | A recruitment interview was scheduled. |
| `recruitment.offer_accepted` | operations | info | A candidate accepted an employment offer. |

#### Inventory & Logistics (13)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `return.processed` | operations | info | A return was completed with its recorded outcome. |
| `return.received` | operations | info | Returned items arrived for inspection or processing. |
| `return.requested` | operations | medium | A customer requested a product return. |
| `shipment.created` | operations | info | A shipment was prepared or booked. |
| `shipment.delayed` | operations | medium | A shipment is delayed or its expected delivery date changed. |
| `shipment.delivered` | operations | info | The carrier or recipient confirmed delivery. |
| `shipment.dispatched` | operations | info | A shipment left the business or was collected by a carrier. |
| `shipment.failed` | operations | high | A shipment could not be delivered. |
| `stock.adjusted` | operations | info | An inventory balance changed following a count or correction. |
| `stock.low` | operations | medium | Inventory below threshold. |
| `stock.out_of_stock` | operations | high | An inventory item has no available stock. |
| `stock.received` | operations | info | Goods were received into inventory. |
| `stock.reorder_due` | operations | medium | An item reached its configured reorder point. |

#### IT & Security (19)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `security.access_granted` | technical | info | Access to a system or resource was granted. |
| `security.access_requested` | technical | medium | A request for access to a system or resource needs review. |
| `security.access_revoked` | technical | info | Access to a system or resource was removed. |
| `security.login_failed` | technical | medium | Failed sign-in attempts reached a configured alert threshold. |
| `security.suspicious_login` | technical | high | A sign-in was flagged by the source system as suspicious. |
| `security.vulnerability_detected` | technical | high | A security tool reported a vulnerability requiring assessment. |
| `tech.backup_completed` | technical | info | A scheduled backup finished successfully. |
| `tech.backup_failed` | technical | high | A backup job failed or did not complete. |
| `tech.certificate_expiring` | technical | medium | A monitored certificate is approaching its expiry date. |
| `tech.deployment` | technical | info | A release was deployed. |
| `tech.domain_expiring` | technical | medium | A domain registration is approaching its recorded expiry date. |
| `tech.error` | technical | high | An unhandled exception or error log entry, or a failed monitoring check (site down, DNS problem). |
| `tech.info` | technical | info | A monitoring check completed successfully (website up, DNS check run). |
| `tech.integration_failed` | technical | high | A connected system failed a sync or API operation. |
| `tech.license_expiring` | technical | medium | A software licence or subscription is approaching renewal or expiry. |
| `tech.outage` | technical | critical | A site or service is down. |
| `tech.performance` | technical | medium | Slow responses or resource exhaustion. |
| `tech.recovered` | technical | info | A site or service is back up after an outage. |
| `tech.security` | technical | critical | A security related finding. |

#### Legal & Compliance (10)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `compliance.breach_reported` | operations | high | A potential compliance breach was reported for assessment. |
| `compliance.deadline_due` | operations | medium | A compliance obligation is approaching the deadline supplied by the source system. |
| `compliance.document_expiring` | operations | medium | An insurance policy, permit or other tracked document is approaching its recorded expiry date. |
| `compliance.review_due` | operations | medium | A configured compliance review is approaching its recorded deadline. |
| `contract.expired` | operations | high | A contract reached its recorded expiry date. |
| `contract.renewal_due` | operations | medium | A contract is approaching its recorded renewal or notice date. |
| `contract.signed` | operations | info | A contract or agreement was signed. |
| `privacy.access_request_received` | operations | medium | A request to access personal information was received. |
| `privacy.deletion_request_received` | operations | medium | A request to delete personal information was received. |
| `privacy.incident_reported` | operations | high | A potential personal-information incident was recorded for assessment. |

#### Management (9)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `analytics.conversion_summary` | analytics | info | Conversion counts and rates are available for a reporting period. |
| `analytics.traffic_summary` | analytics | info | Website visits for a period. |
| `app.downloads` | analytics | info | Install counts for a period (e.g. Google Play). |
| `kpi.target_missed` | analytics | medium | A measured KPI fell outside its configured target. |
| `management.decision_required` | task | medium | A decision needs an owner or management review. |
| `metric.snapshot` | analytics | info | Any numeric KPI reading (use value + unit). |
| `metric.threshold_breached` | analytics | medium | A metric crossed a configured upper or lower threshold. |
| `report.ready` | analytics | info | A scheduled business report is available. |
| `risk.identified` | operations | high | A business risk was recorded for review and ownership. |

#### Marketing (17)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `marketing.budget_exceeded` | marketing | high | A campaign exceeded its configured spending limit. |
| `marketing.campaign` | marketing | info | Results of an email/ad campaign. |
| `marketing.campaign_completed` | marketing | info | A marketing campaign finished and its results are ready. |
| `marketing.campaign_started` | marketing | info | A marketing campaign launched. |
| `marketing.conversion_recorded` | marketing | info | A conversion was attributed to a campaign. |
| `marketing.lead_captured` | marketing | info | A campaign captured a lead for qualification or handoff to sales. |
| `marketing.unsubscribed` | marketing | medium | A contact opted out of a marketing channel. |
| `seo.activity` | marketing | info | Something happened to your SEO: a recommendation from a third party (an SEO tool, agency or search engine), or a change made to SEO data such as titles, descriptions, keywords, redirects or the sitemap. |
| `seo.indexing_issue` | marketing | medium | A monitored page has an indexing or crawl issue. |
| `seo.rank_dropped` | marketing | medium | A tracked keyword's search position dropped beyond a configured threshold. |
| `seo.search_summary` | marketing | info | Clicks/impressions/top queries for a period (Google Search Console). |
| `social.comment_received` | marketing | low | Someone commented on one of your social-media posts. |
| `social.followers_summary` | marketing | info | A daily follower count for a social-media account, with the change since the previous count. |
| `social.mention_received` | marketing | low | A public social-media mention of the business was detected. |
| `social.message_received` | marketing | medium | A message arrived through a connected social channel. |
| `social.post_failed` | marketing | medium | A social-media post could not be published. |
| `social.post_published` | marketing | info | A social-media post was published. |

#### Operations (18)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `booking.cancelled` | operations | medium | An appointment or reservation was cancelled. |
| `booking.completed` | operations | info | An appointment or reservation was completed. |
| `booking.created` | operations | info | An appointment or reservation was made. |
| `booking.no_show` | operations | medium | A customer did not attend a scheduled appointment. |
| `booking.reminder_due` | operations | low | A booking reached its configured reminder time. |
| `booking.updated` | operations | info | An appointment or reservation changed. |
| `operations.job_completed` | operations | info | A work order or operational job was completed. |
| `operations.job_delayed` | operations | medium | A work order or operational job is behind schedule. |
| `operations.job_started` | operations | info | A work order or operational job began. |
| `order.cancelled` | operations | medium | An order was cancelled. |
| `order.confirmed` | operations | info | An order was accepted or confirmed for fulfilment. |
| `order.fulfilled` | operations | info | An order's goods or services were fulfilled. |
| `order.fulfilment_started` | operations | info | Work began on picking, packing or fulfilling an order. |
| `order.placed` | operations | info | A new order needs fulfilment. |
| `production.batch_completed` | operations | info | A production batch finished. |
| `production.batch_failed` | operations | high | A production batch was stopped or rejected. |
| `quality.check_failed` | operations | high | A product, service or process failed a quality check. |
| `quality.issue_reported` | operations | high | A quality defect or nonconformance was reported. |

#### Procurement (9)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `purchase.delivery_overdue` | operations | high | A purchase order has not arrived by its expected delivery date. |
| `purchase.order_acknowledged` | operations | info | A supplier confirmed receipt or acceptance of a purchase order. |
| `purchase.order_sent` | operations | info | A purchase order was issued to a supplier. |
| `purchase.request_approved` | operations | info | A purchase request was approved. |
| `purchase.requested` | operations | medium | A team requested a purchase or supplier commitment. |
| `supplier.contract_expiring` | operations | medium | A supplier agreement is approaching its recorded expiry date. |
| `supplier.created` | operations | info | A supplier record was added. |
| `supplier.performance_issue` | operations | high | A supplier quality, delivery or service issue was recorded. |
| `supplier.updated` | operations | medium | A supplier's recorded details changed and may need verification. |

#### Projects & Delivery (13)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `project.budget_exceeded` | operations | high | Recorded project costs exceeded its budget. |
| `project.completed` | operations | info | A project or delivery engagement was completed. |
| `project.created` | operations | info | A new project or delivery engagement was opened. |
| `project.delayed` | operations | high | A project is forecast to miss its delivery date. |
| `project.milestone_completed` | operations | info | A project milestone was achieved. |
| `project.milestone_due` | operations | medium | A project milestone is approaching its planned date. |
| `task.assigned` | task | info | A task was assigned to a person or team. |
| `task.completed` | task | info | A task in a connected system was completed; PulseSteer's own list emits todo.completed. |
| `task.created` | task | info | A task was created in a connected work system. |
| `task.due` | task | medium | A task reached its configured due date. |
| `task.overdue` | task | high | A task passed its recorded deadline without completion. |
| `task.review_required` | task | medium | Something needs a human decision. |
| `todo.completed` | task | info | Someone ticked off a to-do on the To Do list (raised by PulseSteer). |

#### Sales (15)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `lead.assigned` | customer | info | A lead has been assigned to a salesperson or team. |
| `lead.created` | customer | info | A potential customer entered the sales pipeline. |
| `lead.disqualified` | customer | low | A lead was closed without becoming an opportunity. |
| `lead.follow_up_due` | customer | medium | A sales lead needs a follow-up at the configured time. |
| `lead.qualified` | customer | info | A lead meets the business's qualification criteria. |
| `opportunity.created` | customer | info | A qualified sales opportunity was opened. |
| `opportunity.lost` | customer | low | An opportunity was closed without a sale. |
| `opportunity.stage_changed` | customer | info | A deal moved to a different sales stage. |
| `opportunity.stalled` | customer | medium | An opportunity has not progressed within the configured period. |
| `opportunity.won` | customer | info | A sales opportunity was accepted and can be handed to delivery. |
| `quote.accepted` | customer | info | A customer accepted a quotation. |
| `quote.declined` | customer | low | A customer declined a quotation. |
| `quote.expired` | customer | medium | A quotation reached its validity date without acceptance. |
| `quote.requested` | customer | medium | A customer requested pricing or a proposal. |
| `quote.sent` | customer | info | A quotation or proposal was sent to a customer. |

#### Website (25)

| Event type | Category | Default severity | Use for |
|---|---|---|---|
| `website.account_locked` | authentication | medium | A website account was locked by the source system and may need review. |
| `website.checkout_abandoned` | website | low | An unfinished website checkout passed the source system's configured abandonment threshold. |
| `website.checkout_started` | website | info | A visitor started a website checkout flow. |
| `website.comment_submitted` | website | low | A visitor or user submitted a comment through the website. |
| `website.contact_form_submitted` | website | medium | A visitor submitted a website contact form. |
| `website.download_requested` | website | info | A visitor requested a file or resource download through the website. |
| `website.email_verified` | authentication | info | A website account's email address was verified. |
| `website.file_upload_failed` | website | low | A website file upload could not be completed. |
| `website.file_uploaded` | website | info | A user uploaded a file through the website. |
| `website.form_submitted` | website | info | A website form other than a dedicated contact or registration form was submitted. |
| `website.form_validation_failed` | website | low | A submitted website form did not pass validation. |
| `website.login` | authentication | info | A user successfully signed in to the website. |
| `website.login_failed` | authentication | low | A website sign-in attempt failed; threshold-based security alerts use security.login_failed. |
| `website.logout` | authentication | info | A user signed out of the website. |
| `website.newsletter_subscribed` | website | info | A visitor subscribed to a newsletter through the website. |
| `website.newsletter_unsubscribed` | website | info | A contact unsubscribed from a newsletter through the website. |
| `website.page_viewed` | website | info | A visitor viewed a website page. |
| `website.password_reset_completed` | authentication | info | A website account's password reset was completed. |
| `website.password_reset_requested` | authentication | info | A password reset was requested for a website account. |
| `website.record_deleted` | website | medium | A record was deleted or withdrawn through the website. |
| `website.record_submitted` | website | medium | A user submitted or created a record through the website, such as a listing, application or request. |
| `website.record_updated` | website | info | A user updated a record through the website. |
| `website.registered` | authentication | info | A visitor successfully registered a website account. |
| `website.registration_failed` | authentication | low | A website account registration could not be completed. |
| `website.search_performed` | website | info | A visitor performed a search on the website. |


---

## 4. Endpoints

### `POST /api/v1/events` – send one event

Request body: an event (see §3). Responses:

| Status | Body | Meaning |
|--------|------|---------|
| `202` | `{ "eventId", "status": "accepted", "externalId" }` | Stored and queued for processing. |
| `202` | `{ "eventId", "status": "duplicate", "externalId" }` | Same `externalId` already received – nothing stored. |
| `400` | Problem details | Validation failed (`errors` / `detail` explain why). |
| `401` | Problem details | Missing / invalid / revoked key. |
| `403` | – | Key lacks `events:write`. |
| `429` | – | Rate limited. Back off and retry. |

### `POST /api/v1/events/batch` – send up to 500 events

Body: a JSON array of events. Each event is validated independently; valid ones are stored even if others fail.

```json
{
  "accepted": 2, "duplicates": 1, "rejected": 1,
  "results": [ { "eventId": "…", "status": "accepted", "externalId": "o-1" }, … ],
  "errors":  [ { "index": 3, "error": "data must be a JSON object or array." } ]
}
```

### `GET /api/v1/events` – list events (scope `events:read`)

Query: `since` (ISO time, received after), `type` (exact, or prefix with `*` e.g. `payment.*`), `businessId`, `take` (1–200, default 50).
Returns newest first. Each item includes processing `status` (`received` → `processing` → `processed`/`failed`) and
AI fields (`aiSummary`, `aiSentiment`, `requiresAttention`) once analysed.

### `GET /api/v1/events/{id}` – one event

### `GET /api/v1/event-types` – the catalogue (no auth)

### `GET /api/v1/me` – who am I

### `GET /api/v1/actions` – actions changed since a time (scope `events:read`)

Query: `since`, `status`, `eventId`, `take` (1–200). See §6.

### `GET /api/v1/actions/{id}` – status of an action

### `POST /api/v1/actions/{id}/result` – report an action's outcome (see §7)

---

## 5. Idempotency and retries

Always send an `externalId` that is stable for the thing you are reporting (order id, invoice number, log entry id,
`signup-<userId>`, `installs-2026-10-08`…). Then:

- Retrying after a timeout is safe – a repeat returns `status: "duplicate"` with the original `eventId`.
- Periodic jobs can resend overlapping windows without creating duplicates.

Recommended retry policy for `5xx`, `429` and network errors: exponential back-off (1s, 2s, 4s… up to ~5 minutes).
Do not retry `400`/`401`/`403`.

---

## 6. Tracking changes (polling)

The API is plain request/response: there is **no push channel** (no WebSockets/SignalR) for external systems. Live
updates exist only inside the PulseSteer dashboard. To follow what happens to your events and the actions they trigger,
poll with a key that has the `events:read` scope – every 30–60 seconds is plenty.

| Call | Returns | Cursor |
|------|---------|--------|
| `GET /api/v1/events?since=<time>&take=200` | Events **received** after `since`, newest first | `receivedAt` of the first item |
| `GET /api/v1/actions?since=<time>` | Actions **created, approved/rejected, executed or completed** after `since`, oldest change first. Optional `status` and `eventId` filters. | largest `updatedAt` |
| `GET /api/v1/events/{id}` | One event: processing `status`, `aiSummary`, `requiresAttention`… | – |
| `GET /api/v1/actions/{id}` | One action | – |

Action shape: `{ id, eventId, title, serviceName, handlerKey, status, origin, reason, confidence, error, createdAt, updatedAt, completedAt }`.
Statuses: `proposed`, `pendingApproval`, `approved`, `rejected`, `executing`, `succeeded`, `failed`, `awaitingCallback`.

```js
const headers = { "X-Api-Key": process.env.PULSESTEER_API_KEY };
const res = await fetch(`https://<api-host>/api/v1/actions?since=${encodeURIComponent(cursor)}`, { headers });
for (const action of await res.json()) {
  handle(action);                       // e.g. update your own records
  cursor = action.updatedAt;            // results are ordered by updatedAt
}
```

Keys bound to a business only ever see that business's events and actions.

**The other direction – PulseSteer polls you.** If your system holds data PulseSteer should collect, you do not need to call
the API at all: expose an endpoint and add a *JSON feed* connector (§8). PulseSteer polls it on a schedule.

---

## 7. Webhooks: letting PulseSteer act on your systems

A dashboard user can configure a **Call webhook** service and rules such as *"when `account.approval_required`
arrives, prepare a webhook call for my approval"*. When the action runs, PulseSteer POSTs to your endpoint:

```json
{
  "actionId": "3d67f751-…",
  "operation": "approve-account",
  "title": "Approve new account",
  "reason": "Rule 'Approve sign-ups' matched account.approval_required",
  "payload": { "accountId": "u_123" },
  "event": { …the triggering event… },
  "callback": { "url": "https://<api-host>/api/v1/actions/3d67f751-…/result", "token": "KR0x…" },
  "sentAt": "2026-10-09T15:48:39Z"
}
```

**Verify the signature.** If a signing secret is configured, the header `X-PulseSteer-Signature: sha256=<hex>` contains
the HMAC-SHA256 of the raw request body using the secret. Compare in constant time and reject mismatches.

```python
import hmac, hashlib
expected = "sha256=" + hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, request.headers["X-PulseSteer-Signature"]): abort(401)
```

**Respond quickly** with any `2xx`. Non-2xx marks the action *Failed* (a user can retry it).

**Asynchronous completion.** If the service is set to *Wait for callback*, the action stays *In progress* until you
report the outcome (no API key required – the one-time token authorises the call):

```bash
curl -X POST "<callback.url>" -H "Content-Type: application/json" \
  -d '{ "token": "<callback.token>", "success": true, "message": "Account approved", "data": { "approvedBy": "system" } }'
```

`200` → recorded. `404` → unknown action, wrong token, or already completed (tokens are single-use).

---

## 8. Pull integrations (connectors)

Connectors are configured in the dashboard (**Connectors → Add connector**) and need no code on your side.

- **Email inbox (IMAP)** – reads a mailbox such as support@ every few minutes; each new email becomes an
  `email.received` event (`contact` = sender, `title` = subject, `description` = body, `data.messageId`, recipients,
  attachments…). Emails already loaded are tracked with the IMAP UID cursor (`UIDVALIDITY` + last UID, stored in the
  connector's state) and de-duplicated on the Message-ID (`externalId = "email:<Message-ID>"`). Optionally mark imported
  mail as read or move it to a folder. Reply threading: email actions accept `inReplyTo: "{{data.messageId}}"`.
- **Uptime monitor**, **Google Search Console**, **Google Play** – see the setup wizards in the dashboard.

### JSON feed connector

If your system cannot call out, expose a `GET` endpoint and add a **JSON feed** connector in the dashboard. Return a JSON
array of events (same shape as §3) or `{ "events": [ … ] }`. PulseSteer appends `?since=<ISO time of last run>` and
de-duplicates by `externalId`, so returning the last N items each time is fine.

---

## 9. Code samples

**JavaScript (Node 18+)**
```js
await fetch(`${PULSESTEER_URL}/api/v1/events`, {
  method: "POST",
  headers: { "X-Api-Key": process.env.PULSESTEER_API_KEY, "Content-Type": "application/json" },
  body: JSON.stringify({ type: "order.placed", externalId: `order-${order.id}`, value: order.total, currency: "GBP",
                         contact: { name: order.name, email: order.email }, data: { items: order.items.length } })
});
```

**C#**
```csharp
var http = new HttpClient { BaseAddress = new Uri(pulsesteerUrl) };
http.DefaultRequestHeaders.Add("X-Api-Key", apiKey);
await http.PostAsJsonAsync("/api/v1/events", new {
    type = "tech.error", title = ex.Message, description = ex.ToString(), severity = "high",
    externalId = $"err-{Activity.Current?.TraceId}", data = new { path = ctx.Request.Path.Value } });
```

**Python**
```python
requests.post(f"{PULSESTEER_URL}/api/v1/events", headers={"X-Api-Key": KEY}, timeout=10, json={
    "type": "bill.due", "title": "AWS invoice", "value": 182.40, "currency": "USD",
    "externalId": "aws-2026-10", "data": {"supplier": "AWS", "dueDate": "2026-11-02"}}).raise_for_status()
```

**PHP**
```php
$ch = curl_init("$pulsesteerUrl/api/v1/events");
curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["X-Api-Key: $key", "Content-Type: application/json"],
  CURLOPT_POSTFIELDS => json_encode(["type" => "customer.enquiry", "title" => $subject, "description" => $message,
                                     "contact" => ["name" => $name, "email" => $email]])]);
curl_exec($ch);
```

---

## 10. Best practices

- **One key per site/system**, bound to its business. Name keys after where they are used. Rotate by creating a new key, deploying it, then revoking the old one.
- **Send facts, not opinions.** Put raw details in `data`; PulseSteer's AI does the summarising and prioritising.
- **Use `severity` honestly.** Rules and the AI use it to decide what needs attention.
- **Use `contact.email`** for anything a person might want to reply to – email actions can use `{{event.contactEmail}}`.
- **Send summaries for high-volume metrics** (e.g. one `analytics.traffic_summary` per day) rather than one event per page view.
- **Never send secrets or card numbers** in events.

## 11. Errors

All errors use RFC 9457 *problem details*:

```json
{ "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1", "title": "Invalid event", "status": 400,
  "detail": "businessId is required because this API key is not bound to a business." }
```
