{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "title": "Export Webhook Schema",
    "description": "Sent whenever a data export activity happens (e.g. export created/completed)",
    "type": "object",
    "properties": {
        "id": {
            "type": "string",
            "title": "Export Id",
            "description": "The unique identifier for this export"
        },
        "name": {
            "type": [
                "string",
                "null"
            ],
            "title": "Export Name",
            "description": "The name of this export (e.g. User Details)"
        },
        "requester": {
            "type": "string",
            "title": "Requester",
            "description": "The person or machine that requested this export"
        },
        "status": {
            "type": "string",
            "title": "Status",
            "description": "The status of this export (e.g. is it running/finished?)",
            "enum": [
                "PENDING",
                "ABORTED",
                "COMPLETED"
            ]
        },
        "dateCreated": {
            "type": "integer",
            "title": "Date Created",
            "description": "The date this export was created"
        },
        "dateCompleted": {
            "type": [
                "integer",
                "null"
            ],
            "title": "Date Completed",
            "description": "The date this export completed"
        },
        "mailtoEmail": {
            "type": [
                "string",
                "null"
            ],
            "title": "Notification Email Address",
            "description": "The email address that will receive a download link for this export when it completes"
        },
        "dateExpires": {
            "type": [
                "integer",
                "null"
            ],
            "title": "Date Expires",
            "description": "The date this export expires (e.g. when it will no longer be downloadable)"
        },
        "outputFormat": {
            "type": "string",
            "title": "Output Format",
            "description": "The format this export will be generated in (e.g. CSV or Excel)",
            "enum": [
                "XLSX",
                "CSV"
            ]
        },
        "task": {
            "type": "string",
            "title": "Export Type",
            "description": "The type of export generated",
            "enum": [
                "USER",
                "REFERRAL",
                "REWARD_BALANCE",
                "USER_REWARD_BALANCE",
                "USER_REFERRAL",
                "REFERRAL_PARTICIPANT",
                "REDEEMABLE_REWARD_BALANCE"
            ]
        },
        "operation": {
            "type": "string",
            "title": "Operation",
            "description": "The operation being performed (for exports this is always QUERY)"
        },
        "params": {
            "type": "object",
            "title": "Export Filters",
            "description": "These parameters are used to filter the export (e.g. by date or program)"
        },
        "stats": {
            "type": [
                "object",
                "null"
            ],
            "title": "Export Stats",
            "description": "Statistics recorded upon completions of the export",
            "properties": {
                "recordsProcessed": {
                    "type": "integer",
                    "title": "Records Processed",
                    "description": "The number of records that were processed to complete this export"
                },
                "errors": {
                    "type": "integer",
                    "title": "Errors",
                    "description": "The number of errors that occurred while running this export"
                }
            },
            "additionalProperties": false
        },
        "fileRef": {
            "type": [
                "string",
                "null"
            ],
            "title": "Uploaded File Reference",
            "description": "A link to an uploaded file, if this export was based on an uploaded file (e.g. a list of redemption)"
        }
    },
    "required": [
        "id",
        "requester",
        "status",
        "dateCreated",
        "outputFormat",
        "task",
        "operation"
    ],
    "additionalProperties": false
}