{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/paidnice-com/json-schema/paidnice-com-action-schema.json",
  "title": "Action",
  "x-generated": "2026-11-20",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/paidnice-com-openapi.json#/components/schemas/Action",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Action id"
    },
    "type": {
      "type": "string",
      "enum": [
        "late_fee",
        "late_fee_email",
        "reminder",
        "discount_apply",
        "discount_remove",
        "discount_applied_email",
        "discount_removed_email",
        "send_sms",
        "issue_statement_late_fee",
        "send_statement",
        "escalation",
        "send_statement_interest_email",
        "send_announcement_email",
        "quote_email",
        "payment_plan_reminder",
        "on_demand"
      ],
      "description": "What the action does, for example reminder, late_fee, send_sms or send_statement"
    },
    "status": {
      "type": "string",
      "enum": [
        "pending",
        "complete",
        "failed",
        "suspended",
        "reverted",
        "approval_pending",
        "skipped"
      ],
      "description": "pending: waiting for its run date. complete: processed. failed: errored, see errorMessage. suspended and approval_pending: waiting for a user. skipped: skipped by a user. reverted: a late fee that was reverted"
    },
    "substatus": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "deferred",
        "no_interest_generated",
        "no_statement_sent",
        null
      ],
      "description": "Extra detail on the status, null when there is none. deferred: processing was pushed back. no_interest_generated: a statement interest run produced no interest. no_statement_sent: a statement check ran but sent no statement"
    },
    "createdAt": {
      "type": "string",
      "description": "When the action was created, as an ISO 8601 datetime"
    },
    "actionOn": {
      "type": "string",
      "description": "When the action is or was due to run"
    },
    "executedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "When the action was processed, as an ISO 8601 datetime. Null if it has not been"
    },
    "failedAt": {
      "type": [
        "string",
        "null"
      ],
      "description": "When the action failed, as an ISO 8601 datetime. Null if it has not failed"
    },
    "deferredUntil": {
      "type": [
        "string",
        "null"
      ],
      "description": "Set while a pending action has been pushed back, for example to retry after an error"
    },
    "ignored": {
      "type": "boolean",
      "description": "True when a user ignored a completed late fee so an identical fee can be issued again. Treat the action as not having happened"
    },
    "errorCode": {
      "type": [
        "string",
        "null"
      ],
      "description": "Machine readable code for why the action failed, null when it has not failed"
    },
    "errorMessage": {
      "type": [
        "string",
        "null"
      ],
      "description": "Why the action failed, often the message from the accounting system or email or SMS provider"
    },
    "notes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Notes Paidnice recorded on the action, for example why nothing was sent"
    },
    "contactId": {
      "type": "integer",
      "description": "Paidnice id of the contact the action is for. Use it with get_contact"
    },
    "contactName": {
      "type": "string",
      "description": "Name of the contact the action is for"
    },
    "invoiceId": {
      "type": [
        "string",
        "null"
      ],
      "description": "Null for actions on the contact as a whole, such as statements"
    },
    "invoiceNumber": {
      "type": [
        "string",
        "null"
      ],
      "description": "Number of the invoice the action is for, null for actions on the contact as a whole"
    },
    "policies": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "description": "Paidnice policy id"
          },
          "title": {
            "type": "string",
            "description": "Policy name"
          },
          "type": {
            "type": "string",
            "enum": [
              "reminder",
              "fee",
              "discount",
              "sms",
              "statement_late_fee",
              "statement",
              "escalation",
              "contact_escalation",
              "quote_email",
              "payment_plan_reminder",
              "on_demand_placeholder"
            ],
            "description": "The kind of policy, for example reminder, fee, discount or sms"
          }
        },
        "required": [
          "id",
          "title",
          "type"
        ]
      },
      "description": "The policies that created the action. Empty for manual actions"
    }
  },
  "required": [
    "id",
    "type",
    "status",
    "substatus",
    "createdAt",
    "actionOn",
    "executedAt",
    "failedAt",
    "deferredUntil",
    "ignored",
    "errorCode",
    "errorMessage",
    "notes",
    "contactId",
    "contactName",
    "invoiceId",
    "invoiceNumber",
    "policies"
  ]
}