---
updatedAt: 2026-04-30T06:50:08.000Z
agentTools:
  projectIndex: https://developers.akahu.nz/llms.txt
---

# Download all report data as a single JSON file

In order to facilitate fast access to potentially large datasets this endpoint returns a `HTTP 302` redirect to the result. You may need to configure your HTTP client to follow redirects in order to access the results transparently.

The final response provides a JSON object containing all of the report data combined. This avoids the need for pagination, but note that the resulting payload may be quite large.

# OpenAPI definition

```json
{
  "info": {
    "title": "Akahu Apply API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.apply.akahu.nz",
      "description": "Akahu Apply API"
    }
  ],
  "x-readme": {
    "apply-endpoint-order": true
  },
  "openapi": "3.1.0",
  "components": {
    "securitySchemes": {
      "APIKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer auth using an Akahu Apply API Key. These can be generated by an Akahu Apply administrator in the web portal."
      }
    },
    "schemas": {
      "WebhookEventId": {
        "type": "string",
        "pattern": "^evt_[a-z0-9]{24,27}$",
        "example": "evt_tz4a98xxat96iws9zmbrgj3a"
      },
      "OrgId": {
        "type": "string",
        "pattern": "^org_[a-z0-9]{24,27}$",
        "example": "org_tz4a98xxat96iws9zmbrgj3a"
      },
      "WebhookEndpointId": {
        "type": "string",
        "pattern": "^webhook_[a-z0-9]{24,27}$",
        "example": "webhook_tz4a98xxat96iws9zmbrgj3a"
      },
      "TestWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "test"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_endpoint": {
            "$ref": "#/components/schemas/WebhookEndpointId"
          }
        },
        "required": [
          "type",
          "_org",
          "_endpoint"
        ]
      },
      "TestWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/TestWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ApplicationId": {
        "type": "string",
        "pattern": "^application_[a-z0-9]{24,27}$",
        "example": "application_tz4a98xxat96iws9zmbrgj3a"
      },
      "ApplicationCreatedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "application:created"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application"
        ]
      },
      "ApplicationCreatedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ApplicationCreatedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ApplicationArchivedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "application:archived"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application"
        ]
      },
      "ApplicationArchivedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ApplicationArchivedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ApplicationUnarchivedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "application:unarchived"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application"
        ]
      },
      "ApplicationUnarchivedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ApplicationUnarchivedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "SharingRequestId": {
        "type": "string",
        "pattern": "^sharing_request_[a-z0-9]{24,27}$",
        "example": "sharing_request_tz4a98xxat96iws9zmbrgj3a"
      },
      "SharingRequestViewedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "sharing_request:viewed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_sharing_request": {
            "$ref": "#/components/schemas/SharingRequestId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_sharing_request"
        ]
      },
      "SharingRequestViewedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/SharingRequestViewedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "SharingRequestSubmittedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "sharing_request:submitted"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_sharing_request": {
            "$ref": "#/components/schemas/SharingRequestId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_sharing_request"
        ]
      },
      "SharingRequestSubmittedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/SharingRequestSubmittedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "DocumentId": {
        "type": "string",
        "pattern": "^doc_[a-z0-9]{24,27}$",
        "example": "doc_tz4a98xxat96iws9zmbrgj3a"
      },
      "DocumentUploadedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "document:uploaded"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_document": {
            "$ref": "#/components/schemas/DocumentId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_document"
        ]
      },
      "DocumentUploadedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/DocumentUploadedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "DocumentCompletedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "document:completed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_document": {
            "$ref": "#/components/schemas/DocumentId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_document"
        ]
      },
      "DocumentCompletedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/DocumentCompletedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "DocumentFailedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "document:failed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_document": {
            "$ref": "#/components/schemas/DocumentId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_document"
        ]
      },
      "DocumentFailedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/DocumentFailedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReportId": {
        "type": "string",
        "pattern": "^report_[a-z0-9]{24,27}$",
        "example": "report_tz4a98xxat96iws9zmbrgj3a"
      },
      "ReportCompletedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "report:completed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_report": {
            "$ref": "#/components/schemas/ReportId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_report"
        ]
      },
      "ReportCompletedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReportCompletedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReportFailedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "report:failed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_report": {
            "$ref": "#/components/schemas/ReportId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_report"
        ]
      },
      "ReportFailedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReportFailedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReferralId": {
        "type": "string",
        "pattern": "^referral_[a-z0-9]{24,27}$",
        "example": "referral_tz4a98xxat96iws9zmbrgj3a"
      },
      "ReferralCreatedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "referral:created"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_referral": {
            "$ref": "#/components/schemas/ReferralId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_referral"
        ]
      },
      "ReferralCreatedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReferralCreatedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReferralRevokedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "referral:revoked"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_referral": {
            "$ref": "#/components/schemas/ReferralId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_referral"
        ]
      },
      "ReferralRevokedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReferralRevokedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReferralRedeemedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "referral:redeemed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          },
          "_referral": {
            "$ref": "#/components/schemas/ReferralId"
          }
        },
        "required": [
          "type",
          "_org",
          "_application",
          "_referral"
        ]
      },
      "ReferralRedeemedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReferralRedeemedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReferralRedemptionId": {
        "type": "string",
        "pattern": "^referral_redemption_[a-z0-9]{24,27}$",
        "example": "referral_redemption_tz4a98xxat96iws9zmbrgj3a"
      },
      "ReferralRedemptionCreatedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "referral_redemption:created"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_referral_redemption": {
            "$ref": "#/components/schemas/ReferralRedemptionId"
          }
        },
        "required": [
          "type",
          "_org",
          "_referral_redemption"
        ]
      },
      "ReferralRedemptionCreatedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReferralRedemptionCreatedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReferralRedemptionCompletedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "referral_redemption:completed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_referral_redemption": {
            "$ref": "#/components/schemas/ReferralRedemptionId"
          },
          "_application": {
            "$ref": "#/components/schemas/ApplicationId"
          }
        },
        "required": [
          "type",
          "_org",
          "_referral_redemption",
          "_application"
        ]
      },
      "ReferralRedemptionCompletedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReferralRedemptionCompletedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "ReferralRedemptionFailedWebhookPayload": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "referral_redemption:failed"
            ]
          },
          "_org": {
            "$ref": "#/components/schemas/OrgId"
          },
          "_referral_redemption": {
            "$ref": "#/components/schemas/ReferralRedemptionId"
          }
        },
        "required": [
          "type",
          "_org",
          "_referral_redemption"
        ]
      },
      "ReferralRedemptionFailedWebhookEvent": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/WebhookEventId"
          },
          "emitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "payload": {
            "$ref": "#/components/schemas/ReferralRedemptionFailedWebhookPayload"
          }
        },
        "required": [
          "_id",
          "emitted_at",
          "payload"
        ]
      },
      "X-Akahu-Apply-Signature": {
        "type": "string",
        "description": "Detached JWS over the request body, signed with `ES256`. The signing key is published at https://api.apply.akahu.nz/.well-known/jwks.json",
        "example": "eyJhbGciOiJFUzI1NiIsImtpZCI6IjAwMDAwMDAwLTAwMDAtNDAwMC04MDAwLTAwMDAwMDAwMDAwMCJ9..c2lnbmF0dXJl"
      },
      "X-Akahu-Apply-Request-Id": {
        "type": "string",
        "description": "Unique per delivery attempt, including retries. Quote it when asking us about a delivery. Not an idempotency key - use the event `_id` for that.",
        "example": "00000000-0000-4000-8000-000000000000"
      },
      "Generic400ErrorResponseCode": {
        "type": "string",
        "enum": [
          "invalid_type",
          "too_big",
          "too_small",
          "invalid_format",
          "not_multiple_of",
          "unrecognized_keys",
          "invalid_union",
          "invalid_key",
          "invalid_element",
          "invalid_value",
          "invalid",
          "invalid_id"
        ]
      },
      "IssuePath": {
        "type": "array",
        "items": {
          "title": "IssuePathSegment",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "integer"
            }
          ]
        }
      },
      "Generic401ErrorResponseCode": {
        "type": "string",
        "enum": [
          "unauthorized"
        ]
      },
      "Generic401ErrorResponse": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/Generic401ErrorResponseCode"
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "$ref": "#/components/schemas/IssuePath"
                }
              },
              "required": [
                "code",
                "message",
                "path"
              ]
            }
          }
        },
        "required": [
          "issues"
        ]
      },
      "Generic403ErrorResponseCode": {
        "type": "string",
        "enum": [
          "forbidden"
        ]
      },
      "Generic403ErrorResponse": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/Generic403ErrorResponseCode"
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "$ref": "#/components/schemas/IssuePath"
                }
              },
              "required": [
                "code",
                "message",
                "path"
              ]
            }
          }
        },
        "required": [
          "issues"
        ]
      },
      "Generic404ErrorResponseCode": {
        "type": "string",
        "enum": [
          "not_found"
        ]
      },
      "Generic404ErrorResponse": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/Generic404ErrorResponseCode"
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "$ref": "#/components/schemas/IssuePath"
                }
              },
              "required": [
                "code",
                "message",
                "path"
              ]
            }
          }
        },
        "required": [
          "issues"
        ]
      },
      "Generic429ErrorResponseCode": {
        "type": "string",
        "enum": [
          "too_many_requests"
        ]
      },
      "Generic429ErrorResponse": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/Generic429ErrorResponseCode"
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "$ref": "#/components/schemas/IssuePath"
                }
              },
              "required": [
                "code",
                "message",
                "path"
              ]
            }
          }
        },
        "required": [
          "issues"
        ]
      },
      "Generic500ErrorResponseCode": {
        "type": "string",
        "enum": [
          "internal_error"
        ]
      },
      "Generic500ErrorResponse": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "$ref": "#/components/schemas/Generic500ErrorResponseCode"
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "$ref": "#/components/schemas/IssuePath"
                }
              },
              "required": [
                "code",
                "message",
                "path"
              ]
            }
          }
        },
        "required": [
          "issues"
        ]
      },
      "DatafileId": {
        "type": "string",
        "pattern": "^dat_[a-z0-9]{24,27}$",
        "example": "dat_tz4a98xxat96iws9zmbrgj3a"
      },
      "SpendingCategory": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^spending:[0-9]{3}/[a-z0-9-]*$",
            "example": "spending:000/useful-name-here",
            "description": "A unique code for this spending category."
          },
          "name": {
            "type": "string",
            "description": "The name of this spending category."
          }
        },
        "required": [
          "code",
          "name"
        ],
        "description": "The high-level spending category for this transaction."
      },
      "IncomeCategory": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "pattern": "^income:[0-9]{3}/[a-z0-9-]*$",
            "example": "income:000/useful-name-here",
            "description": "A unique code for this income category."
          },
          "name": {
            "type": "string",
            "description": "The name of this income category."
          }
        },
        "required": [
          "code",
          "name"
        ],
        "description": "The income category for this transaction"
      },
      "ReportDataSourceId": {
        "type": "string",
        "pattern": "^src_[a-z0-9]{24,27}$",
        "example": "src_tz4a98xxat96iws9zmbrgj3a"
      },
      "ReportAccountId": {
        "type": [
          "string",
          "null"
        ],
        "pattern": "^report_acc_[a-z0-9]{24,27}$",
        "example": "report_acc_tz4a98xxat96iws9zmbrgj3a"
      },
      "DocumentCompleteSource": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "document_complete"
            ]
          },
          "_document": {
            "$ref": "#/components/schemas/DocumentId"
          },
          "filename": {
            "type": "string"
          },
          "page_count": {
            "type": "number"
          },
          "unreadable": {
            "type": "boolean"
          }
        },
        "required": [
          "type",
          "filename",
          "page_count"
        ],
        "description": "A data source that represents one full document."
      },
      "DocumentPartialSource": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "document_partial"
            ]
          },
          "_document": {
            "$ref": "#/components/schemas/DocumentId"
          },
          "filename": {
            "type": "string"
          },
          "page_start": {
            "type": "number"
          },
          "page_end": {
            "type": "number"
          }
        },
        "required": [
          "type",
          "filename",
          "page_start",
          "page_end"
        ],
        "description": "A data source that represents a range of pages within a document."
      },
      "DatafileSource": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "datafile"
            ]
          },
          "_data_file": {
            "$ref": "#/components/schemas/DatafileId"
          },
          "filename": {
            "type": "string"
          }
        },
        "required": [
          "type",
          "_data_file",
          "filename"
        ],
        "description": "A data source that represents data from an uploaded Datafile."
      },
      "DataSourceOrigin": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/DocumentCompleteSource"
          },
          {
            "$ref": "#/components/schemas/DocumentPartialSource"
          },
          {
            "$ref": "#/components/schemas/DatafileSource"
          }
        ],
        "discriminator": {
          "propertyName": "type",
          "mapping": {
            "document_complete": "#/components/schemas/DocumentCompleteSource",
            "document_partial": "#/components/schemas/DocumentPartialSource",
            "datafile": "#/components/schemas/DatafileSource"
          }
        },
        "description": "The origin of this data source."
      },
      "DataSourceStatus": {
        "type": "string",
        "enum": [
          "unprocessed",
          "processed",
          "duplicate"
        ],
        "description": "The status of this data source:\n\n - `processed`: This data source was successfully processed.\n\n - `unprocessed`: This data source was unable to be processed.\n\n - `duplicate`: This data source was processed, but it was identified as a duplicate."
      },
      "Period": {
        "type": "object",
        "properties": {
          "start": {
            "type": "string",
            "format": "date-time"
          },
          "end": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "start",
          "end"
        ]
      },
      "ReportDataSource": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/ReportDataSourceId"
          },
          "_account": {
            "$ref": "#/components/schemas/ReportAccountId"
          },
          "provider": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "_id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "logo": {
                "type": "string",
                "description": "A URL pointing to a logo for this provider."
              }
            },
            "required": [
              "_id",
              "name",
              "logo"
            ],
            "description": "The institution that provides data (eg. a bank, a card issuer)."
          },
          "origin": {
            "$ref": "#/components/schemas/DataSourceOrigin"
          },
          "status": {
            "$ref": "#/components/schemas/DataSourceStatus"
          },
          "period": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Period"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "_id",
          "_account",
          "provider",
          "origin",
          "status",
          "period"
        ],
        "description": "A Data Source represents a single data input, such as an individual bank statement. A Resource may map to one or more Data Sources (for example a PDF that includes multiple bank statements would be one resource containing multiple data sources)."
      },
      "AccountOwnershipType": {
        "type": "string",
        "enum": [
          "SOLE",
          "JOINT",
          "UNKNOWN"
        ]
      },
      "AccountLoanPurpose": {
        "type": "string",
        "enum": [
          "HOME",
          "PERSONAL",
          "VEHICLE",
          "BUSINESS",
          "UNKNOWN"
        ],
        "description": "The purpose of the loan:\n\n - `HOME`: This is a home loan facility.\n\n - `PERSONAL`: This is a personal loan facility.\n\n - `VEHICLE`: This is a vehicle loan facility, if it can be distinguished from a personal loan.\n\n - `BUSINESS`: This is a business loan facility.\n\n - `UNKNOWN`: We could not determine what this loan is for."
      },
      "AccountLoanInterestType": {
        "type": "string",
        "enum": [
          "FLOATING",
          "FIXED",
          "UNKNOWN"
        ],
        "description": "The type of interest rate:\n\n- `FLOATING`: This account has a variable interest rate.\n\n- `FIXED`: This account has a fixed interest rate.\n\n- `UNKNOWN`: We could not determine the interest type for this account."
      },
      "AccountLoanTerm": {
        "type": "object",
        "properties": {
          "years": {
            "type": "number"
          },
          "months": {
            "type": "number"
          }
        },
        "description": "The duration/term of the loan for it to be paid to completion from the start date of the loan."
      },
      "AccountLoanRepaymentStructure": {
        "type": "string",
        "enum": [
          "PRINCIPAL_AND_INTEREST",
          "REVOLVING",
          "INTEREST_ONLY",
          "UNKNOWN"
        ],
        "description": "The high-level repayment structure of a loan:\n\n - `PRINCIPAL_AND_INTEREST`: Regular repayments include both interest and principal.\n\n - `REVOLVING`: Sometimes called a “line of credit” or “revolving credit mortgage”. The idea is to help save on interest by reducing your daily loan balance as much as possible. You can do this by direct crediting all your income into the account and then paying your bills and everyday expenses from the account as you need to. Revolving loans have a floating (or variable) interest rate. The interest is calculated on the daily balance of your account, so by keeping the loan as low as you can, for as long as you can, you should pay less interest.\n\n - `INTEREST_ONLY`: You don’t repay any of the money you’ve borrowed (principal) until an agreed time. In the meantime you make regular interest payments.\n\n - `UNKNOWN`: We could not determine the repayment structure for this account."
      },
      "AccountLoanRepaymentFrequency": {
        "type": "string",
        "enum": [
          "WEEKLY",
          "FORTNIGHTLY",
          "MONTHLY",
          "QUARTERLY",
          "BIANNUALLY",
          "ANNUALLY"
        ],
        "description": "The frequency of repayments for a loan:\n\n- `WEEKLY`: Repayments are made every week.\n\n- `FORTNIGHTLY`: Repayments are made every two weeks.\n\n- `MONTHLY`: Repayments are made every month.\n\n- `QUARTERLY`: Repayments are made every three months.\n\n- `BIANNUALLY`: Repayments are made every six months.\n\n- `ANNUALLY`: Repayments are made every year."
      },
      "AccountLoanRepayment": {
        "type": "object",
        "properties": {
          "structure": {
            "$ref": "#/components/schemas/AccountLoanRepaymentStructure"
          },
          "frequency": {
            "$ref": "#/components/schemas/AccountLoanRepaymentFrequency"
          },
          "next_date": {
            "type": "string",
            "format": "date-time",
            "description": "The date of the next repayment instalment, if available."
          },
          "next_amount": {
            "type": "number",
            "description": "The amount of the next repayment instalment, if available."
          }
        },
        "required": [
          "structure"
        ],
        "description": "Loan repayment information for an account."
      },
      "ReportAccount": {
        "type": "object",
        "properties": {
          "_id": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ReportAccountId"
              },
              {
                "type": "string"
              }
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "DEPOSITORY",
              "CREDIT CARD",
              "LOAN",
              "TERM DEPOSIT",
              "KIWISAVER",
              "INVESTMENT",
              "UNKNOWN"
            ],
            "description": "Types of account:\n - `DEPOSITORY` A regular transactional or savings bank account.\n - `CREDIT CARD` A credit card or charge card.\n - `LOAN` A loan account, including line-of-credit accounts such as revolving home loans.\n - `TERM DEPOSIT` A term deposit.\n - `KIWISAVER` A KiwiSaver account.\n - `INVESTMENT` A generic investment account, e.g. A shares portfolio.\n - `UNKNOWN` An unsupported account type."
          },
          "identifier": {
            "type": [
              "string",
              "null"
            ],
            "description": "If available, an official identifier such as an NZ bank account number or credit card number."
          },
          "name": {
            "type": "string"
          },
          "holder": {
            "type": [
              "string",
              "null"
            ],
            "description": "The name of the account holder."
          },
          "ownership_type": {
            "$ref": "#/components/schemas/AccountOwnershipType"
          },
          "provider": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "_id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "logo": {
                "type": "string",
                "description": "A URL pointing to a logo for this provider."
              }
            },
            "required": [
              "_id",
              "name",
              "logo"
            ],
            "description": "The institution that provides data (eg. a bank, a card issuer)."
          },
          "periods": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_source": {
                  "type": "string",
                  "pattern": "^src_[a-z0-9]{24,27}$",
                  "example": "src_tz4a98xxat96iws9zmbrgj3a",
                  "description": "The data source that supplied information in this period"
                },
                "opening_balance": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The opening balance for the account in this period, if available."
                },
                "closing_balance": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The closing balance for the account in this period, if available."
                },
                "limit": {
                  "type": [
                    "number",
                    "null"
                  ],
                  "description": "The credit limit for the account in this period, if available."
                },
                "start": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The start date of the period."
                },
                "end": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The end date of the period."
                }
              },
              "required": [
                "_source",
                "opening_balance",
                "closing_balance",
                "limit",
                "start",
                "end"
              ],
              "description": "A period of data pertaining to this account."
            },
            "description": "Periods of data that have been extracted pertaining to this account."
          },
          "loan": {
            "type": "object",
            "properties": {
              "purpose": {
                "$ref": "#/components/schemas/AccountLoanPurpose"
              },
              "interest": {
                "type": "object",
                "properties": {
                  "type": {
                    "$ref": "#/components/schemas/AccountLoanInterestType"
                  },
                  "rate": {
                    "type": "number",
                    "description": "The interest rate percentage for this account, e.g. 6.49 for 6.49%."
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time",
                    "description": "When the interest rate expires, if available. This is the date after which the interest rate may change."
                  }
                },
                "required": [
                  "type"
                ]
              },
              "interest_only_expires_at": {
                "type": "string",
                "format": "date-time",
                "description": "When the interest only period expires, if available. This is the date after which the borrower will need to start repaying the principal in addition to the interest."
              },
              "term": {
                "$ref": "#/components/schemas/AccountLoanTerm"
              },
              "matures_at": {
                "type": "string",
                "format": "date-time",
                "description": "Loan maturity date refers to the date on which a borrower's final loan payment is due."
              },
              "initial_principal": {
                "type": "number",
                "description": "The loan initial principal amount, this was the original amount borrowed."
              },
              "repayment": {
                "$ref": "#/components/schemas/AccountLoanRepayment"
              }
            },
            "required": [
              "purpose",
              "interest",
              "repayment"
            ],
            "description": "Any loan information associated with the account.",
            "example": {
              "purpose": "HOME",
              "interest": {
                "type": "FIXED",
                "rate": 5.7,
                "expires_at": "2026-08-22T12:00:00.000Z"
              },
              "repayment": {
                "structure": "PRINCIPAL_AND_INTEREST",
                "frequency": "FORTNIGHTLY",
                "next_amount": 2061,
                "next_date": "2026-07-04T12:00:00.000Z"
              },
              "term": {
                "years": 29,
                "months": 6
              },
              "initial_principal": 500000,
              "matures_at": "2048-08-22T12:00:00.000Z"
            }
          }
        },
        "required": [
          "_id",
          "type",
          "identifier",
          "name",
          "holder",
          "provider",
          "periods"
        ],
        "description": "Each financial account included in the Report dataset is represented by an Account record. If data relating to the same financial account is included in multiple Resources, the data will be combined (deduplicated) into a single Account record."
      },
      "InsightScopeReport": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string",
            "enum": [
              "report"
            ],
            "description": "The insight was calculated for the entire report."
          },
          "identifier": {
            "$ref": "#/components/schemas/ReportId"
          },
          "label": {
            "type": "string",
            "description": "The application reference"
          }
        },
        "required": [
          "dimension",
          "identifier",
          "label"
        ]
      },
      "InsightScopeAccount": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string",
            "enum": [
              "account"
            ],
            "description": "The insight was calculated for a specific account."
          },
          "identifier": {
            "type": "string"
          },
          "label": {
            "type": "string",
            "description": "The name of the account"
          },
          "account_number": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "dimension",
          "identifier",
          "label",
          "account_number"
        ]
      },
      "CounterpartyId": {
        "type": "string",
        "pattern": "^counterparty_[a-z0-9]{24,27}$",
        "example": "counterparty_tz4a98xxat96iws9zmbrgj3a"
      },
      "InsightScopeCounterparty": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string",
            "enum": [
              "counterparty"
            ],
            "description": "The insight was calculated for a specific counterparty."
          },
          "identifier": {
            "$ref": "#/components/schemas/CounterpartyId"
          },
          "label": {
            "type": "string",
            "description": "The name of the counterparty"
          }
        },
        "required": [
          "dimension",
          "identifier",
          "label"
        ]
      },
      "StreamId": {
        "type": "string",
        "pattern": "^stream_[a-z0-9]{24,27}$",
        "example": "stream_tz4a98xxat96iws9zmbrgj3a"
      },
      "InsightScopeStream": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string",
            "enum": [
              "stream"
            ],
            "description": "The insight was calculated for a specific transaction stream."
          },
          "identifier": {
            "$ref": "#/components/schemas/StreamId"
          },
          "label": {
            "type": "string",
            "description": "A description of the transaction stream"
          },
          "direction": {
            "type": "string",
            "enum": [
              "credit",
              "debit"
            ]
          }
        },
        "required": [
          "dimension",
          "identifier",
          "label",
          "direction"
        ]
      },
      "IncomeCategoryCode": {
        "type": "string",
        "pattern": "^income:[0-9]{3}/[a-z0-9-]*$",
        "example": "income:000/useful-name-here"
      },
      "InsightScopeIncomeCategory": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string",
            "enum": [
              "income_category"
            ],
            "description": "The insight was calculated for a specific income category."
          },
          "identifier": {
            "$ref": "#/components/schemas/IncomeCategoryCode"
          },
          "label": {
            "type": "string",
            "description": "The name of the income category"
          }
        },
        "required": [
          "dimension",
          "identifier",
          "label"
        ]
      },
      "SpendingCategoryCode": {
        "type": "string",
        "pattern": "^spending:[0-9]{3}/[a-z0-9-]*$",
        "example": "spending:000/useful-name-here"
      },
      "InsightScopeSpendingCategory": {
        "type": "object",
        "properties": {
          "dimension": {
            "type": "string",
            "enum": [
              "spending_category"
            ],
            "description": "The insight was calculated for a specific spending category."
          },
          "identifier": {
            "$ref": "#/components/schemas/SpendingCategoryCode"
          },
          "label": {
            "type": "string",
            "description": "The name of the spending category"
          }
        },
        "required": [
          "dimension",
          "identifier",
          "label"
        ]
      },
      "InsightUnit": {
        "type": "string",
        "enum": [
          "count",
          "currency",
          "percentage",
          "days"
        ],
        "description": "The unit of an insight value:\n\n - `count` The value is a count. This will always be an integer greater than or equal to 0.\n\n - `currency` The value is a quantity of currency in NZD.\n\n - `percentage` The value is a percentage.\n\n - `days` The value is a number of days."
      },
      "ReportInsightCompleted": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "completed"
            ]
          },
          "code": {
            "type": "string",
            "pattern": "^insight:[0-9]{3}/[a-z0-9-]*$",
            "example": "insight:000/useful-name-here",
            "description": "A unique code for this insight."
          },
          "scope": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InsightScopeReport"
              },
              {
                "$ref": "#/components/schemas/InsightScopeAccount"
              },
              {
                "$ref": "#/components/schemas/InsightScopeCounterparty"
              },
              {
                "$ref": "#/components/schemas/InsightScopeStream"
              },
              {
                "$ref": "#/components/schemas/InsightScopeIncomeCategory"
              },
              {
                "$ref": "#/components/schemas/InsightScopeSpendingCategory"
              }
            ],
            "discriminator": {
              "propertyName": "dimension",
              "mapping": {
                "report": "#/components/schemas/InsightScopeReport",
                "account": "#/components/schemas/InsightScopeAccount",
                "counterparty": "#/components/schemas/InsightScopeCounterparty",
                "stream": "#/components/schemas/InsightScopeStream",
                "income_category": "#/components/schemas/InsightScopeIncomeCategory",
                "spending_category": "#/components/schemas/InsightScopeSpendingCategory"
              }
            },
            "description": "The scope under which this insight was calculated."
          },
          "description": {
            "type": "string",
            "description": "A description of this insight."
          },
          "value": {
            "type": "number",
            "description": "The quantity measured by the insight"
          },
          "unit": {
            "$ref": "#/components/schemas/InsightUnit"
          },
          "formatted": {
            "type": "string",
            "description": "The value formatted for display"
          }
        },
        "required": [
          "status",
          "code",
          "scope",
          "description",
          "value",
          "formatted"
        ],
        "description": "An insight that has been successfully calculated."
      },
      "InsightFailureReasonCode": {
        "type": "string",
        "enum": [
          "internal_error",
          "timeout",
          "insufficient_data"
        ],
        "description": "The reason for an insight's failure to be calculated:\n\n - `internal_error` An unhandled internal error prevented the calculation from completing.\n\n - `timeout` The calculation took too long and was cancelled.\n\n - `insufficient_data` The report does not contain the relevant data to calculate this insight."
      },
      "InsightFailureReason": {
        "type": "object",
        "properties": {
          "code": {
            "$ref": "#/components/schemas/InsightFailureReasonCode"
          },
          "message": {
            "type": "string",
            "default": "Sorry, something went wrong while processing this insight."
          }
        },
        "required": [
          "code"
        ],
        "description": "If a report has failed to be synthesized, this field provides additional information about what went wrong."
      },
      "ReportInsightFailed": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "failed"
            ]
          },
          "code": {
            "type": "string",
            "pattern": "^insight:[0-9]{3}/[a-z0-9-]*$",
            "example": "insight:000/useful-name-here",
            "description": "A unique code for this insight."
          },
          "scope": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/InsightScopeReport"
              },
              {
                "$ref": "#/components/schemas/InsightScopeAccount"
              },
              {
                "$ref": "#/components/schemas/InsightScopeCounterparty"
              },
              {
                "$ref": "#/components/schemas/InsightScopeStream"
              },
              {
                "$ref": "#/components/schemas/InsightScopeIncomeCategory"
              },
              {
                "$ref": "#/components/schemas/InsightScopeSpendingCategory"
              }
            ],
            "discriminator": {
              "propertyName": "dimension",
              "mapping": {
                "report": "#/components/schemas/InsightScopeReport",
                "account": "#/components/schemas/InsightScopeAccount",
                "counterparty": "#/components/schemas/InsightScopeCounterparty",
                "stream": "#/components/schemas/InsightScopeStream",
                "income_category": "#/components/schemas/InsightScopeIncomeCategory",
                "spending_category": "#/components/schemas/InsightScopeSpendingCategory"
              }
            },
            "description": "The scope under which this insight was calculated."
          },
          "description": {
            "type": "string",
            "description": "A description of this insight."
          },
          "failure_reason": {
            "$ref": "#/components/schemas/InsightFailureReason"
          }
        },
        "required": [
          "status",
          "code",
          "scope",
          "description",
          "failure_reason"
        ],
        "description": "An insight that has not been calculated."
      },
      "ReportInsight": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ReportInsightCompleted"
          },
          {
            "$ref": "#/components/schemas/ReportInsightFailed"
          }
        ],
        "discriminator": {
          "propertyName": "status",
          "mapping": {
            "completed": "#/components/schemas/ReportInsightCompleted",
            "failed": "#/components/schemas/ReportInsightFailed"
          }
        },
        "description": "An insight derived from data in the report."
      },
      "ReportTransactionId": {
        "type": "string",
        "pattern": "^report_trans_[a-z0-9]{24,27}$",
        "example": "report_trans_tz4a98xxat96iws9zmbrgj3a"
      },
      "TransactionAction": {
        "type": "string",
        "enum": [
          "money_in",
          "money_out",
          "transfer"
        ],
        "description": "The net action of this transaction:\n\n - `money_in`: The transaction describes the inwards flow of funds (i.e. income).\n\n - `money_out`: The transaction describes the outwards flow of funds (i.e. an expense).\n\n - `transfer`: The transaction describes the transfer of funds between two accounts that are both present in the dataset provided for this report."
      },
      "TransactionType": {
        "type": "string",
        "enum": [
          "CARD",
          "PAYMENT",
          "TRANSFER",
          "INTEREST",
          "FEE",
          "TAX",
          "DIRECT CREDIT",
          "DIRECT DEBIT",
          "STANDING ORDER",
          "ATM",
          "FX",
          "LOAN",
          "KIWISAVER",
          "CREDIT",
          "DEBIT",
          "UNKNOWN"
        ],
        "description": "The type of transaction:\n\n - `CARD` The transaction was initiated via Credit, Debit, or EFTPOS card.\n\n - `PAYMENT` An outbound payment to another New Zealand bank account.\n\n - `TRANSFER` A money transfer between two of the user's accounts with this provider.\n\n - `INTEREST` Interest received from a savings or investment account.\n\n - `FEE` Fee paid to the institution e.g. an account fee, card fee, ATM fee.\n\n - `TAX` Tax paid on interest or other source of income.\n\n - `DIRECT CREDIT` Payment received from another party.\n\n - `DIRECT DEBIT` Direct debit payment initiated by (and paid to) a third party with prior authorization from the account holder.\n\n - `STANDING ORDER` A regular scheduled payment, aka. 'Automatic payment'.\n\n - `ATM` ATM deposit or withdrawal.\n\n - `FX` Foreign currency exchange.\n\n - `LOAN` Payments towards a loan.\n\n - `KIWISAVER` Transactions towards a KiwiSaver account.\n\n - `CREDIT` A fallback for any other money that has entered the account.\n\n - `DEBIT` A fallback for any other money that has left the account.\n\n - `UNKNOWN` An unknown transaction type.\n"
      },
      "MerchantId": {
        "type": "string",
        "pattern": "^merchant_[a-z0-9]{24,27}$",
        "example": "merchant_tz4a98xxat96iws9zmbrgj3a"
      },
      "ReportMerchant": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/MerchantId"
          },
          "name": {
            "type": "string"
          },
          "logo": {
            "type": "string",
            "description": "A URL pointing to a logo for this merchant."
          }
        },
        "required": [
          "_id",
          "name",
          "logo"
        ],
        "example": {
          "_id": "merchant_cjtt1msoq000a59oj3tpw7vla",
          "name": "Woolworths",
          "logo": "https://cdn.akahu.nz/logos/merchants/merchant_cjtt1msoq000a59oj3tpw7vla"
        }
      },
      "NZFCCategoryId": {
        "type": "string",
        "pattern": "^nzfcc_[a-z0-9]{24,27}$",
        "example": "nzfcc_tz4a98xxat96iws9zmbrgj3a"
      },
      "TransactionCategory": {
        "type": [
          "object",
          "null"
        ],
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/NZFCCategoryId"
          },
          "name": {
            "type": "string"
          }
        },
        "required": [
          "_id",
          "name"
        ],
        "description": "A low-level NZFCC category for this transaction. See nzfcc.org",
        "example": {
          "_id": "nzfcc_ckouvvy84001608ml5p6z4d8j",
          "name": "Supermarkets and grocery stores"
        }
      },
      "ReportTransaction": {
        "type": "object",
        "properties": {
          "_id": {
            "$ref": "#/components/schemas/ReportTransactionId"
          },
          "_account": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ReportAccountId"
              },
              {
                "type": "string"
              }
            ]
          },
          "_source": {
            "type": "string",
            "description": "The data source that this transaction belongs to."
          },
          "action": {
            "$ref": "#/components/schemas/TransactionAction"
          },
          "type": {
            "$ref": "#/components/schemas/TransactionType"
          },
          "date": {
            "type": "string",
            "format": "date-time"
          },
          "description": {
            "type": "string"
          },
          "amount": {
            "type": "number",
            "description": "The transaction amount. Debits are returned as negative numbers."
          },
          "balance": {
            "type": [
              "number",
              "null"
            ],
            "description": "The account balance at this transaction, if available in the data source."
          },
          "merchant": {
            "$ref": "#/components/schemas/ReportMerchant"
          },
          "nzfcc": {
            "$ref": "#/components/schemas/TransactionCategory"
          },
          "income_category": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/IncomeCategory"
              },
              {
                "type": "null"
              }
            ]
          },
          "spending_category": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/SpendingCategory"
              },
              {
                "type": "null"
              }
            ]
          },
          "other_account": {
            "type": [
              "string",
              "null"
            ],
            "description": "The NZ account number of the other party to this transaction, if available."
          },
          "other_loan_account": {
            "type": [
              "string",
              "null"
            ],
            "description": "The loan account number of the other party to this transaction, if available."
          },
          "other_card_suffix": {
            "type": [
              "string",
              "null"
            ],
            "description": "The suffix of the card account for the other party to this transaction, if available."
          }
        },
        "required": [
          "_id",
          "_account",
          "_source",
          "action",
          "type",
          "date",
          "description",
          "amount",
          "balance",
          "merchant",
          "nzfcc",
          "income_category",
          "spending_category"
        ],
        "description": "A record of money moving into or out of an account."
      },
      "GetReportJsonDownload400ErrorResponseCode": {
        "type": "string",
        "enum": [
          "report_processing"
        ]
      },
      "GetReportJsonDownload400ErrorResponse": {
        "type": "object",
        "properties": {
          "issues": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Generic400ErrorResponseCode"
                    },
                    {
                      "$ref": "#/components/schemas/GetReportJsonDownload400ErrorResponseCode"
                    }
                  ]
                },
                "message": {
                  "type": "string"
                },
                "path": {
                  "$ref": "#/components/schemas/IssuePath"
                }
              },
              "required": [
                "code",
                "message",
                "path"
              ]
            }
          }
        },
        "required": [
          "issues"
        ]
      }
    },
    "parameters": {
      "X-Akahu-Apply-Signature": {
        "schema": {
          "$ref": "#/components/schemas/X-Akahu-Apply-Signature"
        },
        "required": true,
        "description": "Detached JWS over the request body, signed with `ES256`. The signing key is published at https://api.apply.akahu.nz/.well-known/jwks.json",
        "name": "X-Akahu-Apply-Signature",
        "in": "header"
      },
      "X-Akahu-Apply-Request-Id": {
        "schema": {
          "$ref": "#/components/schemas/X-Akahu-Apply-Request-Id"
        },
        "required": true,
        "description": "Unique per delivery attempt, including retries. Quote it when asking us about a delivery. Not an idempotency key - use the event `_id` for that.",
        "name": "X-Akahu-Apply-Request-Id",
        "in": "header"
      }
    }
  },
  "paths": {
    "/v1/applications/{applicationId}/reports/{reportId}/json": {
      "get": {
        "operationId": "GetReportJsonDownload",
        "tags": [
          "Reports"
        ],
        "summary": "Download all report data as a single JSON file",
        "description": "In order to facilitate fast access to potentially large datasets this endpoint returns a `HTTP 302` redirect to the result. You may need to configure your HTTP client to follow redirects in order to access the results transparently.\n\nThe final response provides a JSON object containing all of the report data combined. This avoids the need for pagination, but note that the resulting payload may be quite large.",
        "deprecated": false,
        "security": [
          {
            "APIKey": []
          }
        ],
        "parameters": [
          {
            "schema": {
              "$ref": "#/components/schemas/ApplicationId"
            },
            "required": true,
            "name": "applicationId",
            "in": "path"
          },
          {
            "schema": {
              "$ref": "#/components/schemas/ReportId"
            },
            "required": true,
            "name": "reportId",
            "in": "path"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data_sources": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ReportDataSource"
                      }
                    },
                    "accounts": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ReportAccount"
                      }
                    },
                    "insights": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ReportInsight"
                      }
                    },
                    "transactions": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ReportTransaction"
                      }
                    }
                  },
                  "required": [
                    "data_sources",
                    "accounts",
                    "insights",
                    "transactions"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetReportJsonDownload400ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generic401ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generic403ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generic404ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generic429ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Generic500ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "webhooks": {
    "Test": {
      "post": {
        "operationId": "Test",
        "summary": "test",
        "description": "A manually triggered test event for a specific endpoint.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ApplicationCreated": {
      "post": {
        "operationId": "ApplicationCreated",
        "summary": "application:created",
        "description": "An application was created.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationCreatedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ApplicationArchived": {
      "post": {
        "operationId": "ApplicationArchived",
        "summary": "application:archived",
        "description": "An application was archived.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationArchivedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ApplicationUnarchived": {
      "post": {
        "operationId": "ApplicationUnarchived",
        "summary": "application:unarchived",
        "description": "An archived application was restored to active.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationUnarchivedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "SharingRequestViewed": {
      "post": {
        "operationId": "SharingRequestViewed",
        "summary": "sharing_request:viewed",
        "description": "An applicant opened a sharing request link.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SharingRequestViewedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "SharingRequestSubmitted": {
      "post": {
        "operationId": "SharingRequestSubmitted",
        "summary": "sharing_request:submitted",
        "description": "An applicant submitted data against a sharing request.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SharingRequestSubmittedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "DocumentUploaded": {
      "post": {
        "operationId": "DocumentUploaded",
        "summary": "document:uploaded",
        "description": "A document was uploaded to an application.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentUploadedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "DocumentCompleted": {
      "post": {
        "operationId": "DocumentCompleted",
        "summary": "document:completed",
        "description": "A document finished processing successfully.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentCompletedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "DocumentFailed": {
      "post": {
        "operationId": "DocumentFailed",
        "summary": "document:failed",
        "description": "A document failed to process.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DocumentFailedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReportCompleted": {
      "post": {
        "operationId": "ReportCompleted",
        "summary": "report:completed",
        "description": "A report finished generating successfully.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportCompletedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReportFailed": {
      "post": {
        "operationId": "ReportFailed",
        "summary": "report:failed",
        "description": "A report failed to generate.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReportFailedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReferralCreated": {
      "post": {
        "operationId": "ReferralCreated",
        "summary": "referral:created",
        "description": "A referral was created from an application.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralCreatedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReferralRevoked": {
      "post": {
        "operationId": "ReferralRevoked",
        "summary": "referral:revoked",
        "description": "A referral was revoked. Not sent when a referral expires.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralRevokedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReferralRedeemed": {
      "post": {
        "operationId": "ReferralRedeemed",
        "summary": "referral:redeemed",
        "description": "Another organisation redeemed a referral.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralRedeemedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReferralRedemptionCreated": {
      "post": {
        "operationId": "ReferralRedemptionCreated",
        "summary": "referral_redemption:created",
        "description": "A referral redemption was started.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralRedemptionCreatedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReferralRedemptionCompleted": {
      "post": {
        "operationId": "ReferralRedemptionCompleted",
        "summary": "referral_redemption:completed",
        "description": "A referral redemption finished and the new application is available.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralRedemptionCompletedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    },
    "ReferralRedemptionFailed": {
      "post": {
        "operationId": "ReferralRedemptionFailed",
        "summary": "referral_redemption:failed",
        "description": "A referral redemption failed.",
        "tags": [
          "Webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Signature"
          },
          {
            "$ref": "#/components/parameters/X-Akahu-Apply-Request-Id"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReferralRedemptionFailedWebhookEvent"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Event acknowledged."
          }
        }
      }
    }
  }
}
```