{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/akahu/main/json-schema/akahu-application-schema.json",
  "title": "Application",
  "description": "The core function of Akahu Apply is to provide insights over a dataset consisting of financial accounts and their transactions. An Akahu Apply **Application** represents a container where data can be added, processed, and prepared for analysis.\n\nFor example, if you are using Akahu Apply as part of a lending workflow, a new Application should be set up in Akahu Apply for each lending application being processed.",
  "x-generated": "2026-10-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/akahu-applications-api-openapi.yml#/components/schemas/Application",
  "type": "object",
  "properties": {
    "_id": {
      "$ref": "#/$defs/ApplicationId"
    },
    "reference": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "A value used to identify the application in a way that makes sense to the creator.\n\nFor some this may include the applicant names, for others it may be a unique reference from their CRM.\n\nIt does not need to be unique."
    },
    "report_type": {
      "$ref": "#/$defs/ReportType"
    },
    "status": {
      "$ref": "#/$defs/ApplicationStatus"
    },
    "last_applicant_submission_at": {
      "type": "string",
      "format": "date-time",
      "description": "The date of the last submission by an applicant from a sharing request."
    },
    "archived_at": {
      "type": "string",
      "format": "date-time",
      "description": "If this application has been archived, the date that it happened."
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "The date this application was created."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "The date this application was last updated."
    }
  },
  "required": [
    "_id",
    "reference",
    "report_type",
    "status",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "ApplicationId": {
      "type": "string",
      "pattern": "^application_[a-z0-9]{24,27}$"
    },
    "ApplicationStatus": {
      "type": "string",
      "enum": [
        "active",
        "archived"
      ]
    },
    "ReportType": {
      "type": "string",
      "enum": [
        "standard",
        "income"
      ],
      "description": "The type of report generated for an application:\n\n - `standard` A full report covering accounts, income, expenses and transactions.\n\n - `income` A report focused on income."
    }
  }
}