{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/palisade-email/json-schema/palisade-email-task-schema.json",
  "title": "Task",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/palisade-email-openapi.yml#/components/schemas/Task",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "domain_id": {
      "type": "string",
      "format": "uuid"
    },
    "domain": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "url": {
          "type": "string"
        },
        "dmarc_policy": {
          "type": "string"
        },
        "score": {
          "type": "number",
          "minimum": 0,
          "maximum": 100,
          "description": "The domain audit score as it stands now."
        }
      },
      "required": [
        "id",
        "url",
        "dmarc_policy",
        "score"
      ]
    },
    "score_gain": {
      "type": "integer",
      "minimum": 0,
      "description": "How much of the domain score completing this ticket wins back, by the same scoring the domain overview shows. 0 for ticket types the score does not measure. Present only with expand[]=domain, since it depends on the domain as it stands now."
    },
    "sending_domain": {
      "type": [
        "string",
        "null"
      ]
    },
    "source_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "source": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "name": {
          "type": "string"
        },
        "homepage": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        },
        "documentation": {
          "type": "object",
          "properties": {
            "spf": {
              "type": [
                "string",
                "null"
              ]
            },
            "dkim": {
              "type": [
                "string",
                "null"
              ]
            },
            "combined": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        },
        "category": {
          "type": "string",
          "enum": [
            "SENDING_TOOL",
            "MAILBOX_PROVIDER",
            "VPS_PROVIDER",
            "SECURITY_PROVIDER",
            "EMAIL_RELAY"
          ]
        },
        "forwarding_type": {
          "type": "string",
          "enum": [
            "NOT_FORWARDER",
            "FORWARDER",
            "FORWARDER_ONLY"
          ]
        },
        "spf_support": {
          "type": "string",
          "enum": [
            "NONE",
            "RARE",
            "FULL"
          ]
        },
        "spf_supported_methods": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "DIRECT",
              "SUBDOMAIN",
              "MANAGED_SUBDOMAIN"
            ]
          }
        },
        "spf_support_options": {
          "type": "object",
          "properties": {
            "direct": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "values": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "requires_advanced_config": {
                  "type": [
                    "boolean",
                    "null"
                  ]
                }
              },
              "required": [
                "values",
                "requires_advanced_config"
              ]
            },
            "subdomain": {
              "type": [
                "object",
                "null"
              ],
              "properties": {
                "is_managed": {
                  "type": "boolean"
                },
                "requires_user_selection": {
                  "type": "boolean"
                },
                "path": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "value": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "dns_records": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "TXT",
                          "CNAME",
                          "MX"
                        ]
                      },
                      "value": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "type"
                    ]
                  }
                }
              },
              "required": [
                "is_managed",
                "requires_user_selection",
                "path",
                "value",
                "dns_records"
              ]
            }
          },
          "required": [
            "direct",
            "subdomain"
          ]
        },
        "dkim_support": {
          "type": "string",
          "enum": [
            "NONE",
            "RARE",
            "FULL"
          ]
        },
        "dkim_discovery_selectors": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "id",
        "name",
        "homepage",
        "documentation",
        "category",
        "forwarding_type",
        "spf_support",
        "spf_supported_methods",
        "spf_support_options",
        "dkim_support",
        "dkim_discovery_selectors"
      ]
    },
    "instructions": {
      "type": [
        "object",
        "null"
      ],
      "properties": {
        "steps": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "dns_records": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "TXT",
                  "CNAME"
                ]
              },
              "name": {
                "type": "string"
              },
              "value": {
                "type": "string"
              }
            },
            "required": [
              "type"
            ]
          }
        }
      },
      "required": [
        "steps",
        "dns_records"
      ],
      "description": "BETA: Only expandable for GET /tasks/:id. Can contain instructions sometimes."
    },
    "source_alias": {
      "type": [
        "string",
        "null"
      ]
    },
    "priority": {
      "type": "number"
    },
    "sequence": {
      "type": "number",
      "description": "Where the task sits in the email-authentication rollout, lower first: 10 DMARC setup, 20 foundation records, 30 SPF/DKIM alignment, 40 cleanup, 50 enforcement, 60 hardening. Separate from priority, which is urgency; sequence orders tasks of equal priority, since an alignment task cannot be worked before DMARC reporting exists to show the failure."
    },
    "status": {
      "$ref": "#/$defs/TaskStatus"
    },
    "type": {
      "$ref": "#/$defs/TaskType"
    },
    "description": {
      "type": "string"
    },
    "snoozed_until": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "marked_pending_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "resolved_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "resolution_reason": {
      "$ref": "#/$defs/TaskResolutionReason"
    }
  },
  "required": [
    "id",
    "domain_id",
    "sending_domain",
    "source_id",
    "source_alias",
    "priority",
    "sequence",
    "status",
    "type",
    "description",
    "snoozed_until",
    "marked_pending_at",
    "created_at",
    "updated_at",
    "resolved_at",
    "resolution_reason"
  ],
  "$defs": {
    "TaskResolutionReason": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "verified",
        "manual"
      ],
      "description": "Why a done ticket closed. 'verified': Palisade's own check found the problem gone. 'manual': a person or an API caller marked it done and nothing was checked. Null on a ticket that is not done, and on one closed before the reason was first recorded. More values may be added, so treat an unknown one as unspecified."
    },
    "TaskStatus": {
      "type": "string",
      "enum": [
        "open",
        "snoozed",
        "canceled",
        "dismissed",
        "pending",
        "done"
      ]
    },
    "TaskType": {
      "type": "string",
      "enum": [
        "cleanup_spf_record",
        "confirm_source",
        "lockdown_domain",
        "reduce_spf_lookups",
        "set_up_dmarc_record",
        "source_failing_dkim",
        "source_failing_spf",
        "set_up_mx_record",
        "set_up_spf_record",
        "update_dmarc_record",
        "update_ttl",
        "set_up_mta_sts",
        "set_up_tls_rpt",
        "resolve_dns_conflict",
        "review_unused_sender",
        "cleanup_sender_records",
        "fix_mx_certificate",
        "renew_vmc_certificate",
        "dkim_selector_not_imported",
        "set_up_bimi",
        "review_lookalike_domain",
        "switch_dmarc_tool",
        "enable_mta_sts"
      ]
    }
  }
}