> ## Documentation Index
> Fetch the complete documentation index at: https://developer.eka.care/llms.txt
> Use this file to discover all available pages before exploring further.

# Fire an event

> Starts one run per active rule on the event, for the given scope.



## OpenAPI

````yaml api-reference/doc-tool/ipd-api/protocol-openapi.json post /protocol/workflow/events
openapi: 3.1.0
info:
  title: Eka Protocol API
  version: '1.0'
  description: >-
    Hospital workflows for IPD: rules, the tasks they create, and the forms
    filled on an admission.
servers:
  - description: Production
    url: https://api.eka.care
  - description: Stage/Sandbox
    url: https://api.dev.eka.care
security: []
tags:
  - name: Tasks
    description: >-
      Workflow tasks at a hospital. Rules create them; users claim, release,
      complete and cancel them here. Task documents are also readable live from
      Firestore (`protocol/{bid}/tasks`) through `@orbi/protocol-sdk`; every
      change goes through this API.
  - name: Forms
    description: >-
      Forms filled on an entity (today: an admission, the IPD Forms tab) and
      what happened to each.
  - name: Rules
    description: >-
      Hospital workflow rules: events → conditions → tasks. Each save is a new
      version, compiled to a workflow.
  - name: Catalog
    description: The events and fields rules are written against.
  - name: Events
    description: 'Fire an event for a scope: every active rule on it starts a run.'
  - name: SA forms
    description: >-
      The hospital's SA forms (its own and the system ones), with versions and
      archiving.
  - name: SA form drafts
    description: SA forms saved before they are ready. Not offered in IPD until published.
  - name: AI drafts
    description: Draft an SA form from a prompt or a file with AI.
paths:
  /protocol/workflow/events:
    post:
      tags:
        - Events
      summary: Fire an event
      description: Starts one run per active rule on the event, for the given scope.
      operationId: postEvents
      parameters:
        - name: auth
          in: header
          required: true
          description: >-
            The access token. The gateway verifies it and passes the user and
            the business on.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                event:
                  type: string
                  minLength: 1
                scope:
                  type: object
                  properties:
                    type:
                      type: string
                      enum:
                        - ADMISSION
                        - DISCHARGE
                    id:
                      type: string
                      minLength: 1
                  required:
                    - type
                    - id
                  additionalProperties: false
                meta:
                  type: object
                  additionalProperties:
                    type:
                      - string
                      - number
                      - boolean
                rule_ids:
                  type: array
                  items:
                    type: string
                    minLength: 1
                  maxItems: 50
              required:
                - event
                - scope
              additionalProperties: false
      responses:
        '200':
          description: Success.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    const: success
                  data:
                    $ref: '#/components/schemas/FireResult'
                required:
                  - status
                  - data
        '401':
          description: No signed-in user, or no business on the session.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '409':
          description: Not in a state for this.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: The request failed validation; `details` names each invalid path.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    FireResult:
      type: object
      properties:
        event_id:
          type: string
        closes_scope:
          type: boolean
        rules_found:
          type: number
        runs:
          type: array
          items:
            $ref: '#/components/schemas/FireRun'
        cancelled:
          type: array
          items:
            type: string
        facts:
          $ref: '#/components/schemas/Facts'
        facts_missing:
          type: array
          items:
            type: string
      required:
        - event_id
        - closes_scope
        - rules_found
        - runs
        - cancelled
    Error:
      type: object
      properties:
        status:
          type: string
          const: error
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
            details:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: string
                  message:
                    type: string
                required:
                  - path
                  - message
          required:
            - code
            - message
      required:
        - status
        - error
    FireRun:
      type: object
      properties:
        workflow_name:
          type: string
        version:
          type: number
        rule_id:
          type: string
        rule_name:
          type: string
        run_id:
          anyOf:
            - type: string
            - type: 'null'
        error:
          type: string
      required:
        - workflow_name
        - version
        - rule_id
        - rule_name
        - run_id
    Facts:
      type: object
      properties: {}
      additionalProperties:
        $ref: '#/components/schemas/FactValue'
    FactValue:
      anyOf:
        - anyOf:
            - type: string
            - type: number
            - type: boolean
              const: false
            - type: boolean
              const: true
            - type: array
              items:
                type: string
        - type: 'null'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.