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

# Start a run from an alert

> Loads the alert, builds the warning area, finds the facilities inside it, measures and accepts joins, ranks by the fixed formula, and writes explanations. Every step lands in the audit log.



## OpenAPI

````yaml /contract/openapi.yaml post /runs
openapi: 3.1.0
info:
  title: Porch Light API
  version: 0.1.0
  summary: >-
    The shared contract every Porch Light agent builds against. Country
    agnostic: everything US specific sits behind the country adapter interface
    in contract/adapter.md.
  description: >-
    Porch Light takes a weather alert in, builds the warning area, ranks the
    facilities inside it with a fixed transparent formula, and returns a call
    sheet where every row carries its evidence trail. Zetaris is the only data
    path. Meterless is the only model path. Nemotron explains, the formula
    ranks.
  license:
    name: AGPL-3.0
servers: []
security:
  - bearerAuth: []
tags:
  - name: alerts
  - name: runs
  - name: health
paths:
  /runs:
    post:
      tags:
        - runs
      summary: Start a run from an alert
      description: >-
        Loads the alert, builds the warning area, finds the facilities inside
        it, measures and accepts joins, ranks by the fixed formula, and writes
        explanations. Every step lands in the audit log.
      operationId: createRun
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateRunRequest'
      responses:
        '201':
          description: Run created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Run'
        '400':
          description: Alert missing or malformed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '404':
          description: Alert id not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '503':
          description: Zetaris or Meterless unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '504':
          description: Upstream source timed out
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
components:
  schemas:
    CreateRunRequest:
      description: Exactly one of alert_id or alert is required.
      oneOf:
        - type: object
          required:
            - alert_id
          properties:
            alert_id:
              type: string
              description: Id of a known alert (archived or active).
            country:
              $ref: '#/components/schemas/CountryCode'
          additionalProperties: false
        - type: object
          required:
            - alert
          properties:
            alert:
              $ref: '#/components/schemas/Alert'
            country:
              $ref: '#/components/schemas/CountryCode'
          additionalProperties: false
    Run:
      type: object
      required:
        - id
        - status
        - alert
        - created_at
      properties:
        id:
          type: string
        status:
          type: string
          enum:
            - queued
            - building_area
            - finding_facilities
            - measuring_joins
            - scoring
            - writing_reasons
            - ready
            - exporting
            - done
            - failed
        alert:
          $ref: '#/components/schemas/Alert'
        warning_area:
          $ref: '#/components/schemas/WarningArea'
        snapshot_id:
          type: string
        country:
          $ref: '#/components/schemas/CountryCode'
        counts:
          type: object
          properties:
            facilities:
              type: integer
            joins_accepted:
              type: integer
            joins_failed:
              type: integer
            checkins_done:
              type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        error: 19edac8e-5022-409d-8aba-557400c5d725
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              $ref: '#/components/schemas/ErrorCode'
            message:
              type: string
            detail: {}
            retry_after_ms:
              type: integer
    CountryCode:
      type: string
      description: >-
        Lowercase adapter country key (us, jm, ph, ...), not an enum so new
        adapters do not change the contract.
      example: us
    Alert:
      type: object
      required:
        - id
        - country
        - source
        - event
        - headline
        - sent
        - zone_based
        - affected_zones
      properties:
        id:
          type: string
          example: iem-2024-milton-flz-12081-mock
        country:
          $ref: '#/components/schemas/CountryCode'
        source:
          type: string
          enum:
            - nws
            - iem
            - gdacs
            - cap
            - mock
          description: Which adapter source produced the alert.
        event:
          type: string
          example: Hurricane Warning
        headline:
          type: string
        severity:
          type: string
          enum:
            - extreme
            - severe
            - moderate
            - minor
            - unknown
        urgency:
          type: string
          enum:
            - immediate
            - expected
            - future
            - past
            - unknown
        certainty:
          type: string
          enum:
            - observed
            - likely
            - possible
            - unlikely
            - unknown
        sent:
          type: string
          format: date-time
        effective:
          type: string
          format: date-time
        expires:
          type: string
          format: date-time
        geocode:
          type: object
          properties:
            ugc:
              type: array
              items:
                type: string
              example:
                - FLZ152
            same:
              type: array
              items:
                type: string
              example:
                - '012081'
        affected_zones:
          type: array
          items:
            $ref: '#/components/schemas/ZoneRef'
        geometry:
          description: >-
            GeoJSON Polygon or MultiPolygon. Storm based warnings carry one;
            zone based alerts (hurricane, coastal flood) are null.
          oneOf:
            - type: object
            - type: 'null'
        zone_based:
          type: boolean
        vtec:
          type: object
          description: VTEC fields when the source carries them (NWS, IEM).
          properties:
            office:
              type: string
              example: TBW
            phenomena:
              type: string
              example: HU
            significance:
              type: string
              example: W
            event_id:
              type: integer
              example: 42
        raw_ref:
          type: string
          description: >-
            Repo relative path of the captured raw JSON and its provenance
            sidecar.
        fetched_at:
          type: string
          format: date-time
        mock:
          type: boolean
          description: True when the alert is fixture data, never a real measurement.
    WarningArea:
      type: object
      required:
        - id
        - country
        - built_from
        - keys
      properties:
        id:
          type: string
        country:
          $ref: '#/components/schemas/CountryCode'
        built_from:
          type: string
          enum:
            - zone_shapes
            - storm_polygon
            - admin_boundary
            - gdacs_buffer
          description: >-
            How the area was assembled. Zone based alerts build from zone
            shapes.
        keys:
          type: array
          items:
            $ref: '#/components/schemas/ExternalKey'
        zones:
          type: array
          items:
            $ref: '#/components/schemas/ZoneRef'
        geometry:
          oneOf:
            - type: object
            - type: 'null'
        area_km2:
          type: number
    ErrorCode:
      type: string
      enum:
        - not_found
        - bad_request
        - no_facilities
        - source_stale
        - zetaris_down
        - meterless_unauthorized
        - meterless_offline
        - timeout
        - export_refused
    ZoneRef:
      type: object
      required:
        - id
        - kind
      properties:
        id:
          type: string
          example: FLZ152
        kind:
          type: string
          enum:
            - county
            - zone
            - tract
            - admin
            - grid
            - cap_area
        name:
          type: string
        country:
          $ref: '#/components/schemas/CountryCode'
    ExternalKey:
      type: object
      required:
        - type
        - value
      properties:
        type:
          $ref: '#/components/schemas/ExternalKeyType'
        value:
          type: string
          example: '12081'
    ExternalKeyType:
      type: string
      enum:
        - ccn
        - osm_id
        - worldpop_cell
        - gdacs_event
        - cap_id
        - ugc
        - fips
        - tract_geoid
        - zip
        - ssa_county
        - nws_zone
      description: Adapter-specific key types the USL carries per country.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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