{
  "openapi": "3.1.1",
  "info": {
    "title": "PulseSteer API",
    "description": "Send business events (sign-ups, payments, errors, bills, enquiries, analytics…) from your websites, apps and\nsystems into your PulseSteer dashboard, and report back on actions PulseSteer asks your systems to perform.\n\n**Authentication:** create an API key in the dashboard (Developers → API keys) and send it in the `X-Api-Key` header.\n\n**Tracking:** poll `GET /api/v1/events?since=…` and `GET /api/v1/actions?since=…` for changes. There is no push channel for API clients.\n\nFull developer guide: [/docs/api-guide.md](/docs/api-guide.md)",
    "version": "v1"
  },
  "servers": [
    {
      "url": "https://pulsesteer.com/"
    }
  ],
  "paths": {
    "/api/v1/actions/{id}/result": {
      "post": {
        "tags": [
          "Actions"
        ],
        "summary": "Report the outcome of an action delivered to your webhook.",
        "description": "When a webhook service is configured with \"Wait for callback\", the payload PulseSteer POSTs to you contains\r\n`callback.url` and a one-time `callback.token`. POST the result here when your system has finished.\r\nNo API key is needed: the token authorises the call and can be used once.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionCallback"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ActionCallback"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ActionCallback"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Outcome recorded.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionDto"
                }
              }
            }
          },
          "404": {
            "description": "Unknown action, already completed, or invalid token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions/{id}": {
      "get": {
        "tags": [
          "Actions"
        ],
        "summary": "Get the status of an action (for example one created from your events).",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ActionDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/actions": {
      "get": {
        "tags": [
          "Actions"
        ],
        "summary": "List actions that changed since a point in time – poll this to track progress.",
        "description": "The API has no push channel: poll this endpoint (e.g. every 30–60 seconds) with `since` set to the largest\r\n`updatedAt` you have seen. An action counts as changed when it is created, approved/rejected, executed or completed.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "Only actions created or updated after this time (ISO 8601). Omit for the most recent.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Optional status filter, e.g. `pendingApproval`, `awaitingCallback`, `succeeded`, `failed`.",
            "schema": {
              "$ref": "#/components/schemas/ActionStatus"
            }
          },
          {
            "name": "eventId",
            "in": "query",
            "description": "Only actions raised for this event.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "take",
            "in": "query",
            "description": "Maximum actions to return (1-200, default 50).",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ActionDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events": {
      "post": {
        "tags": [
          "Events"
        ],
        "summary": "Send one event.",
        "description": "Only `type` is required. If you send an `externalId` that was already received for the same business,\r\nthe call succeeds with `status: \"duplicate\"` and nothing new is stored, so retries are always safe.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IncomingEvent"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/IncomingEvent"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/IncomingEvent"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "The event was stored and queued for processing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IngestResult"
                }
              }
            }
          },
          "400": {
            "description": "The event failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "List recent events, newest first.",
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "description": "Only events received after this time (ISO 8601).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Filter by event type. Supports a trailing wildcard, e.g. `payment.*`.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "businessId",
            "in": "query",
            "description": "Filter by business (ignored for business-bound keys).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "take",
            "in": "query",
            "description": "Maximum events to return (1-200, default 50).",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32",
              "default": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events/batch": {
      "post": {
        "tags": [
          "Events"
        ],
        "summary": "Send up to 500 events in one call.",
        "description": "Each event is validated independently: valid events are stored even if others are rejected.\r\nCheck `errors` in the response for the index and reason of each rejected event.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/IncomingEvent"
                }
              }
            },
            "text/json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/IncomingEvent"
                }
              }
            },
            "application/*+json": {
              "schema": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/IncomingEvent"
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "The batch was processed (see counts for accepted / duplicate / rejected).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BatchIngestResult"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/events/{id}": {
      "get": {
        "tags": [
          "Events"
        ],
        "summary": "Get one event, including its processing status and AI analysis.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventDto"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/event-types": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "The catalogue of well-known event types with their default category and severity.",
        "description": "You may send any type that matches `^[a-z0-9_]+(\\.[a-z0-9_]+)*$`; known types just get better defaults.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/EventTypeInfo"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/me": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "summary": "Returns the identity behind the API key. Use it to verify your integration is configured.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WhoAmI"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ActionCallback": {
        "required": [
          "token"
        ],
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "success": {
            "type": "boolean"
          },
          "message": {
            "maxLength": 4000,
            "type": [
              "null",
              "string"
            ]
          },
          "data": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/JsonElement"
              }
            ]
          }
        },
        "description": "Body of `POST /api/v1/actions/{id}/result`, used by external systems to report an async outcome."
      },
      "ActionDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "eventId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "title": {
            "type": "string"
          },
          "serviceName": {
            "type": "string"
          },
          "handlerKey": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/ActionStatus"
          },
          "origin": {
            "$ref": "#/components/schemas/ActionOrigin"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ]
          },
          "confidence": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "error": {
            "type": [
              "null",
              "string"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "description": "Last time anything happened to the action (created, decided, executed or completed). Use as a polling cursor.",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          }
        },
        "description": "Action status returned by the API and pushed to dashboard circuits."
      },
      "ActionOrigin": {
        "type": "integer"
      },
      "ActionStatus": {
        "type": "integer"
      },
      "BatchError": {
        "required": [
          "index",
          "error"
        ],
        "type": "object",
        "properties": {
          "index": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "BatchIngestResult": {
        "type": "object",
        "properties": {
          "accepted": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "duplicates": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "rejected": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IngestResult"
            }
          },
          "errors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BatchError"
            }
          }
        }
      },
      "BusinessRef": {
        "required": [
          "id",
          "name"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          }
        }
      },
      "EventCategory": {
        "type": "integer"
      },
      "EventContact": {
        "type": "object",
        "properties": {
          "name": {
            "maxLength": 200,
            "type": [
              "null",
              "string"
            ]
          },
          "email": {
            "maxLength": 320,
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "EventDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "businessId": {
            "type": "string",
            "format": "uuid"
          },
          "businessName": {
            "type": [
              "null",
              "string"
            ]
          },
          "type": {
            "type": "string"
          },
          "category": {
            "$ref": "#/components/schemas/EventCategory"
          },
          "severity": {
            "$ref": "#/components/schemas/EventSeverity"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": [
              "null",
              "string"
            ]
          },
          "source": {
            "$ref": "#/components/schemas/EventSource"
          },
          "status": {
            "$ref": "#/components/schemas/EventStatus"
          },
          "externalId": {
            "type": [
              "null",
              "string"
            ]
          },
          "value": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "format": "double"
          },
          "unit": {
            "type": [
              "null",
              "string"
            ]
          },
          "currency": {
            "type": [
              "null",
              "string"
            ]
          },
          "contactName": {
            "type": [
              "null",
              "string"
            ]
          },
          "contactEmail": {
            "type": [
              "null",
              "string"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "data": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/JsonElement"
              }
            ]
          },
          "occurredAt": {
            "type": "string",
            "format": "date-time"
          },
          "receivedAt": {
            "type": "string",
            "format": "date-time"
          },
          "requiresAttention": {
            "type": "boolean"
          },
          "aiSummary": {
            "type": [
              "null",
              "string"
            ]
          },
          "aiSentiment": {
            "type": [
              "null",
              "string"
            ]
          }
        },
        "description": "Event shape returned by the read API and pushed to dashboard circuits."
      },
      "EventSeverity": {
        "type": "integer"
      },
      "EventSource": {
        "type": "integer",
        "description": "How the event arrived in the platform. Both paths share the same ingestion service."
      },
      "EventStatus": {
        "type": "integer"
      },
      "EventTypeInfo": {
        "required": [
          "type",
          "displayName",
          "category",
          "defaultSeverity",
          "description"
        ],
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "displayName": {
            "type": "string"
          },
          "category": {
            "$ref": "#/components/schemas/EventCategory"
          },
          "defaultSeverity": {
            "$ref": "#/components/schemas/EventSeverity"
          },
          "description": {
            "type": "string"
          },
          "exampleDataJson": {
            "type": [
              "null",
              "string"
            ]
          },
          "suggestedDepartment": {
            "type": "string",
            "default": "Operations"
          }
        }
      },
      "IncomingEvent": {
        "required": [
          "type"
        ],
        "type": "object",
        "properties": {
          "type": {
            "maxLength": 100,
            "pattern": "^[a-z0-9_]+(\\.[a-z0-9_]+)*$",
            "type": "string",
            "description": "Dotted lower-case event type, e.g. \"customer.signup\". See GET /api/v1/event-types for the catalogue."
          },
          "title": {
            "maxLength": 500,
            "type": [
              "null",
              "string"
            ],
            "description": "Short human readable headline. Defaults to the type's display name."
          },
          "description": {
            "maxLength": 20000,
            "type": [
              "null",
              "string"
            ]
          },
          "category": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "description": "Overrides the category implied by the type.",
                "$ref": "#/components/schemas/EventCategory"
              }
            ]
          },
          "severity": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "description": "Overrides the severity implied by the type.",
                "$ref": "#/components/schemas/EventSeverity"
              }
            ]
          },
          "occurredAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "When it happened in the source system. Defaults to now.",
            "format": "date-time"
          },
          "externalId": {
            "maxLength": 200,
            "type": [
              "null",
              "string"
            ],
            "description": "Your id for this event. Re-sending the same id for the same business is ignored (idempotent)."
          },
          "correlationId": {
            "maxLength": 200,
            "type": [
              "null",
              "string"
            ]
          },
          "value": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Optional numeric value (amount, count, duration...).",
            "format": "double"
          },
          "unit": {
            "maxLength": 50,
            "type": [
              "null",
              "string"
            ]
          },
          "currency": {
            "maxLength": 3,
            "type": [
              "null",
              "string"
            ],
            "description": "ISO 4217 code when decimal? IncomingEvent.Value is money."
          },
          "contact": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/EventContact"
              }
            ]
          },
          "url": {
            "maxLength": 2000,
            "type": [
              "null",
              "string"
            ]
          },
          "tags": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            }
          },
          "data": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "description": "Any JSON object. Stored as-is and available to rules, templates and the AI.",
                "$ref": "#/components/schemas/JsonElement"
              }
            ]
          },
          "businessId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Required only when the API key is not bound to a single business.",
            "format": "uuid"
          }
        },
        "description": "The payload accepted by `POST /api/v1/events`, and the shape every inbound connector produces.\r\nOnly string IncomingEvent.Type is required; everything else is optional."
      },
      "IngestResult": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "description": "\"accepted\" or \"duplicate\"."
          },
          "externalId": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "JsonElement": { },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": [
              "null",
              "string"
            ]
          },
          "title": {
            "type": [
              "null",
              "string"
            ]
          },
          "status": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "detail": {
            "type": [
              "null",
              "string"
            ]
          },
          "instance": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "WhoAmI": {
        "required": [
          "apiKeyName",
          "organisation",
          "boundBusinessId",
          "scopes",
          "businesses"
        ],
        "type": "object",
        "properties": {
          "apiKeyName": {
            "type": "string"
          },
          "organisation": {
            "type": "string"
          },
          "boundBusinessId": {
            "type": [
              "null",
              "string"
            ],
            "format": "uuid"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "businesses": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BusinessRef"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "Your PulseSteer API key, e.g. adk_1a2b3c4d5e6f_...",
        "name": "X-Api-Key",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "ApiKey": [ ]
    }
  ],
  "tags": [
    {
      "name": "Actions"
    },
    {
      "name": "Events"
    },
    {
      "name": "Discovery"
    }
  ]
}