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

# Declare an emergency

> **Required permission:** `write`.

Forwarded to the shared EmergencyDeclarationUsecase so Notify and v1 share
a single implementation. Idempotency-Key handling is on the roadmap — for
now, retries on a transient failure may create duplicate emergencies.
Partners that want dedup today can supply `externalId` (unique per org).



## OpenAPI

````yaml https://api.rescue-serverless.dev.back2back.team/api/public/v1/openapi.json post /orgs/{org_id}/emergencies
openapi: 3.1.0
info:
  title: Rescue Public API v1
  description: >-
    Stable public API for partner integrations.


    **Authentication:** `Authorization: Bearer rk_live_<8 hex><64 hex>`. Tokens
    are minted via `POST /api/v1/api-keys` (internal admin) and shown exactly
    once at creation. The same plaintext is required for every public-v1 request
    — store it securely.


    **Permissions:** v1 vocabulary is `read` | `write`. Future versions may
    introduce granular `<resource>:<action>` permissions additively.


    **Idempotency:** retries on a 5xx must be assumed to have unknown outcomes —
    check `GET /emergencies/{id}` (optionally via `externalId`) before retrying.
    An `Idempotency-Key` header will be supported in a future revision.


    **Webhook delivery:** payloads may be duplicated and out-of-order. Dedup on
    `eventId`; order events per emergency on `(emergencyId, sequence)`.
  version: 1.0.0
servers:
  - url: https://api.punchrescue.com/api/public/v1
security:
  - BearerAuth: []
paths:
  /orgs/{org_id}/emergencies:
    post:
      tags:
        - Emergencies
      summary: Declare an emergency
      description: >-
        **Required permission:** `write`.


        Forwarded to the shared EmergencyDeclarationUsecase so Notify and v1
        share

        a single implementation. Idempotency-Key handling is on the roadmap —
        for

        now, retries on a transient failure may create duplicate emergencies.

        Partners that want dedup today can supply `externalId` (unique per org).
      operationId: emergencies.create
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
            description: Target organization id (from the route path)
            title: Org Id
          description: Target organization id (from the route path)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateEmergencyRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PublicEmergencyResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateEmergencyRequest:
      properties:
        externalId:
          anyOf:
            - type: string
              maxLength: 256
              minLength: 1
            - type: 'null'
          title: Externalid
          description: >-
            Partner-supplied incident id from the caller's own system; indexed,
            surfaced on reads + webhooks.
        categoryId:
          anyOf:
            - type: string
            - type: 'null'
          title: Categoryid
        categoryName:
          anyOf:
            - type: string
            - type: 'null'
          title: Categoryname
        source:
          anyOf:
            - type: string
              maxLength: 128
            - type: 'null'
          title: Source
        description:
          anyOf:
            - type: string
              maxLength: 2000
            - type: 'null'
          title: Description
        occurredAt:
          anyOf:
            - type: string
            - type: 'null'
          title: Occurredat
        location:
          anyOf:
            - $ref: '#/components/schemas/PublicLocationInput'
            - type: 'null'
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
        declaredBy:
          anyOf:
            - $ref: '#/components/schemas/DeclareEmergencyDeclaredBy'
            - type: 'null'
      additionalProperties: false
      type: object
      title: CreateEmergencyRequest
    PublicEmergencyResponse:
      properties:
        emergencyId:
          type: string
          title: Emergencyid
        orgId:
          type: string
          title: Orgid
        externalId:
          anyOf:
            - type: string
            - type: 'null'
          title: Externalid
        status:
          type: string
          title: Status
        category:
          anyOf:
            - $ref: '#/components/schemas/PublicCategoryRef'
            - type: 'null'
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
        description:
          anyOf:
            - type: string
            - type: 'null'
          title: Description
        occurredAt:
          anyOf:
            - type: string
            - type: 'null'
          title: Occurredat
        createdAt:
          anyOf:
            - type: string
            - type: 'null'
          title: Createdat
        resolvedAt:
          anyOf:
            - type: string
            - type: 'null'
          title: Resolvedat
        resolvedBy:
          anyOf:
            - $ref: '#/components/schemas/PublicActorRef'
            - type: 'null'
        declaredBy:
          anyOf:
            - $ref: '#/components/schemas/PublicActorRef'
            - type: 'null'
        location:
          anyOf:
            - $ref: '#/components/schemas/PublicLocation'
            - type: 'null'
        resolutionNote:
          anyOf:
            - type: string
            - type: 'null'
          title: Resolutionnote
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
      type: object
      required:
        - emergencyId
        - orgId
        - status
      title: PublicEmergencyResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    PublicLocationInput:
      properties:
        latitude:
          anyOf:
            - type: number
            - type: 'null'
          title: Latitude
        longitude:
          anyOf:
            - type: number
            - type: 'null'
          title: Longitude
        floorId:
          anyOf:
            - type: string
            - type: 'null'
          title: Floorid
      additionalProperties: false
      type: object
      title: PublicLocationInput
    DeclareEmergencyDeclaredBy:
      properties:
        id:
          type: string
          title: Id
          description: Partner-supplied user id from the caller's own system
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
          description: Display name fallback
      additionalProperties: false
      type: object
      required:
        - id
      title: DeclareEmergencyDeclaredBy
    PublicCategoryRef:
      properties:
        id:
          type: string
          title: Id
        name:
          type: string
          title: Name
        color:
          anyOf:
            - type: string
            - type: 'null'
          title: Color
        severity:
          anyOf:
            - type: integer
            - type: 'null'
          title: Severity
      type: object
      required:
        - id
        - name
      title: PublicCategoryRef
      description: Minimal category info embedded on emergencies + webhook payloads.
    PublicActorRef:
      properties:
        type:
          type: string
          title: Type
          description: user | api_key | system
        id:
          type: string
          title: Id
        name:
          anyOf:
            - type: string
            - type: 'null'
          title: Name
      type: object
      required:
        - type
        - id
      title: PublicActorRef
      description: >-
        Unified actor shape (declaredBy / resolvedBy) for both user and api_key
        attribution.
    PublicLocation:
      properties:
        latitude:
          anyOf:
            - type: number
            - type: 'null'
          title: Latitude
        longitude:
          anyOf:
            - type: number
            - type: 'null'
          title: Longitude
        floorId:
          anyOf:
            - type: string
            - type: 'null'
          title: Floorid
      type: object
      title: PublicLocation
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: rk_live_<8hex><64hex>

````