:::open-api-operation
---
operation:
  kind: operation
  method: get
  path: /consignments/{consignmentId}/events
  operationId: streamConsignmentEvents
  summary: Follow a consignment
  deprecated: false
  tags:
    - Events
  parameters:
    - name: consignmentId
      in: path
      required: true
      schema:
        types:
          - string
        format: uuid
    - name: Last-Event-ID
      in: header
      description: Resume after the event you last saw.
      required: false
      schema:
        types:
          - string
  responses:
    - status: "200"
      description: The stream, until you close it.
      content:
        - type: text/event-stream
          schema:
            name: ConsignmentEvent
            ref: "#/components/schemas/ConsignmentEvent"
            types:
              - object
            description: One thing that happened to a consignment.
            properties:
              - name: id
                required: true
                schema:
                  types:
                    - string
                  description: The value to send back as `Last-Event-ID`.
              - name: at
                required: true
                schema:
                  types:
                    - string
                  format: date-time
              - name: status
                required: true
                schema:
                  name: ConsignmentStatus
                  ref: "#/components/schemas/ConsignmentStatus"
                  types:
                    - string
                  description: Where a consignment has got to.
                  enum:
                    - booked
                    - loading
                    - sailing
                    - landed
                    - cancelled
              - name: berth
                required: false
                schema:
                  types:
                    - string
                    - "null"
                  description: Where it is, once it is anywhere.
    - status: "404"
      description: Something went wrong, described the same way every time.
      content:
        - type: application/problem+json
          schema:
            name: Problem
            ref: "#/components/schemas/Problem"
            types:
              - object
            properties:
              - name: title
                required: true
                schema:
                  types:
                    - string
                  description: A short, human-readable summary.
              - name: status
                required: true
                schema:
                  types:
                    - integer
                  constraints:
                    minimum: 400
                    maximum: 599
              - name: detail
                required: false
                schema:
                  types:
                    - string
                    - "null"
servers:
  - url: https://api.example.org/{stage}
    description: The invented production host.
    variables:
      - name: stage
        default: v3
        enum:
          - v1
          - v2
          - v3
        description: Which line of the API to talk to.
  - url: http://localhost:8080
    description: A local process, for trying things out.
security:
  - - key: apiKey
      scheme:
        key: apiKey
        type: apiKey
        description: A key from the account page.
        name: X-Api-Key
        in: header
  - - key: bearer
      scheme:
        key: bearer
        type: http
        description: A token obtained from the authorisation server.
        scheme: bearer
        example: demo-token
        bearerFormat: JWT
securitySchemes:
  - key: apiKey
    type: apiKey
    description: A key from the account page.
    name: X-Api-Key
    in: header
  - key: bearer
    type: http
    description: A token obtained from the authorisation server.
    scheme: bearer
    example: demo-token
    bearerFormat: JWT
  - key: oauth
    type: oauth2
    description: For applications acting on someone else's behalf.
    flows:
      - name: authorizationCode
        authorizationUrl: https://auth.example.org/authorize
        tokenUrl: https://auth.example.org/token
        scopes:
          - name: consignments:read
            description: Read consignments
          - name: consignments:write
            description: Book and change consignments
---
Holds the connection open and writes one event per line as the
consignment moves, in the `text/event-stream` format.

The response is not a document, which is the interesting part for a
reference: there is a schema for one *event*, and none for the body as
a whole.
:::