{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/akahu/main/json-schema/akahu-payment-schema.json",
  "title": "Payment",
  "x-generated": "2026-10-27",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/akahu-enduring-api-openapi.yml#/components/schemas/Payment",
  "type": "object",
  "properties": {
    "_id": {
      "type": "string",
      "description": "The Akahu Payment ID"
    },
    "from": {
      "type": "string",
      "description": "The Akahu Account ID of the source account"
    },
    "to": {
      "type": "object",
      "description": "Information about who this payment is to",
      "properties": {
        "account_number": {
          "type": "string",
          "description": "The NZ bank account number to whom this payment is made"
        },
        "name": {
          "type": "string",
          "description": "The name of the account holder of the destination account",
          "pattern": "^[A-Za-z0-9 \\-_]*$"
        }
      }
    },
    "amount": {
      "type": "number",
      "format": "decimal",
      "multipleOf": 0.01,
      "description": "How much money the payment is for"
    },
    "meta": {
      "type": "object",
      "description": "Payment metadata that you have specified",
      "properties": {
        "destination": {
          "type": "object",
          "description": "Metadata that will appear in the destination account",
          "properties": {
            "particulars": {
              "type": "string",
              "description": "The particulars you have specified for the destination account",
              "pattern": "^[A-Za-z0-9 \\-_]*$"
            },
            "code": {
              "type": "string",
              "description": "The code you have specified for the destination account",
              "pattern": "^[A-Za-z0-9 \\-_]*$"
            },
            "reference": {
              "type": "string",
              "description": "The reference you have specified for the destination account",
              "pattern": "^[A-Za-z0-9 \\-_]*$"
            }
          }
        },
        "source": {
          "type": "object",
          "description": "Metadata that will appear in the source account",
          "properties": {
            "code": {
              "type": "string",
              "description": "The code you have specified for the source account",
              "pattern": "^[A-Za-z0-9 \\-_]*$"
            },
            "reference": {
              "type": "string",
              "description": "The reference you have specified for the source account",
              "pattern": "^[A-Za-z0-9 \\-_]*$"
            }
          }
        }
      }
    },
    "sid": {
      "type": "string",
      "description": "Akahu's unique ID inserted into the particulars field"
    },
    "status": {
      "type": "string",
      "enum": [
        "READY",
        "SENT",
        "PAUSED",
        "DECLINED",
        "CANCELLED",
        "ERROR"
      ],
      "description": "Status of the payment:\n- `READY` → Initial state payment is ready to be processed.\n\n- `SENT` → Payment initiated with the user's bank and we've received confirmation that it has been accepted.\n\n- `PAUSED` → Payment is not yet ready to be processed.\n\n- `DECLINED` → Payment has been declined by the user's bank.\n\n- `CANCELLED` → Payment was cancelled.\n\n- `ERROR` → Internal Akahu error occurred.\n\nFor more details see:\n  - [📚 Payments guide](/docs/making-a-payment)\n  - [📚 Payments lifecycle guide](/docs/making-a-payment#payment-lifecycle)"
    },
    "status_text": {
      "type": "string",
      "description": "If available, more information about the payment's staus"
    },
    "final": {
      "type": "boolean",
      "description": "If this payment has reached it's final state"
    },
    "timeline": {
      "type": "array",
      "description": "A timeline of events regarding this payment",
      "items": {
        "type": "object",
        "description": "A timeline event",
        "properties": {
          "status": {
            "type": "string",
            "description": "The payment's status at this time"
          },
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "An ISO 8701 timestamp of when this event was created"
          },
          "eta": {
            "type": "string",
            "format": "date-time",
            "description": "An ISO 8701 timestamp of when Akahu expects the payment to arrive. Only present on events for `SENT` statuses."
          }
        }
      }
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "An ISO 8701 timestamp of when this payment was created"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "An ISO 8701 timestamp of when this payment was last updated by Akahu"
    },
    "received_at": {
      "type": "string",
      "format": "date-time",
      "description": "An ISO 8701 timestamp of when this payment was received by the destination account. This field will only be populated if the destination account is connected to Akahu."
    }
  }
}