{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getcourier-dev/json-schema/getcourier-dev-wait-result-schema.json",
  "title": "WaitResult",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getcourier-dev-openapi.json#/components/schemas/WaitResult",
  "type": "object",
  "required": [
    "message"
  ],
  "properties": {
    "message": {
      "oneOf": [
        {
          "$ref": "#/$defs/AgentMessage"
        },
        {
          "type": "null"
        }
      ],
      "description": "The first new message with a code or link, or null on timeout."
    },
    "code": {
      "type": [
        "string",
        "null"
      ],
      "description": "First extracted verification code, or null."
    },
    "link": {
      "type": [
        "string",
        "null"
      ],
      "description": "First extracted link, or null."
    },
    "timeout": {
      "type": "boolean",
      "description": "True when no qualifying message arrived before the timeout."
    }
  },
  "$defs": {
    "AgentMessage": {
      "type": "object",
      "required": [
        "id",
        "received_at",
        "codes",
        "links",
        "untrusted",
        "marker"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "received_at": {
          "type": "string",
          "format": "date-time"
        },
        "from": {
          "type": [
            "string",
            "null"
          ],
          "format": "email",
          "description": "Sender address."
        },
        "from_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "Sender display name. Untrusted."
        },
        "subject": {
          "type": [
            "string",
            "null"
          ],
          "description": "Subject line. Untrusted."
        },
        "codes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Extracted verification codes, in full, for the read_token holder."
        },
        "links": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          },
          "description": "Extracted links (magic links first). Untrusted."
        },
        "text": {
          "type": "string",
          "maxLength": 4000,
          "description": "Plain-text body, truncated to 4000 characters."
        },
        "auth": {
          "type": "object",
          "properties": {
            "verdict": {
              "type": "string"
            },
            "spf": {
              "type": "string"
            },
            "dkim": {
              "type": "string"
            },
            "dmarc": {
              "type": "string"
            }
          }
        },
        "untrusted": {
          "const": true
        },
        "marker": {
          "const": "UNTRUSTED EXTERNAL EMAIL"
        }
      }
    }
  }
}