{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "orgId": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "applicationTemplateId": {
            "type": "string",
            "pattern": "^[A-Fa-f\\d]{24}$"
        },
        "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255
        },
        "description": {
            "type": "string",
            "maxLength": 1024
        },
        "endpointSlug": {
            "type": "string",
            "minLength": 4,
            "maxLength": 63,
            "pattern": "^[0-9a-z-]*$"
        },
        "expUserTokenCutoff": {
            "type": "string",
            "format": "date-time"
        },
        "endpointDefaultCors": {
            "type": "boolean"
        },
        "globals": {
            "type": "array",
            "maxItems": 100,
            "items": {
                "type": "object",
                "properties": {
                    "key": {
                        "type": "string",
                        "pattern": "^[0-9a-zA-Z_-]{1,255}$"
                    },
                    "json": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 32767
                    },
                    "cloudOnly": {
                        "type": "boolean",
                        "default": false
                    },
                    "description": {
                        "type": "string",
                        "maxLength": 1024
                    }
                },
                "additionalProperties": false,
                "required": [
                    "key",
                    "json"
                ]
            }
        },
        "archiveConfig": {
            "type": "object",
            "properties": {
                "directory": {
                    "type": "string",
                    "max": 255
                },
                "mode": {
                    "type": "string",
                    "enum": [
                        "all",
                        "whitelist",
                        "blacklist"
                    ]
                },
                "deviceIds": {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "pattern": "^[A-Fa-f\\d]{24}$"
                    },
                    "maxItems": 1000
                },
                "deviceTags": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "key": {
                                "type": "string",
                                "pattern": "^[0-9a-zA-Z_-]{1,255}$"
                            },
                            "value": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 255
                            }
                        },
                        "additionalProperties": false
                    },
                    "maxItems": 100
                },
                "includeDevices": {
                    "type": "boolean",
                    "default": true
                },
                "includeEvents": {
                    "type": "boolean",
                    "default": false
                },
                "includeDataTables": {
                    "type": "boolean",
                    "default": false
                },
                "dataTablesMode": {
                    "type": "string",
                    "enum": [
                        "all",
                        "whitelist",
                        "blacklist"
                    ]
                },
                "dataTableIds": {
                    "type": "array",
                    "items": {
                        "type": "string",
                        "pattern": "^[A-Fa-f\\d]{24}$"
                    },
                    "maxItems": 1000
                },
                "s3": {
                    "type": "object",
                    "properties": {
                        "bucket": {
                            "type": "string",
                            "max": 255
                        },
                        "accessKeyId": {
                            "type": "string",
                            "min": 4,
                            "max": 128
                        },
                        "secretAccessKey": {
                            "type": "string",
                            "min": 4,
                            "max": 128
                        },
                        "region": {
                            "type": "string",
                            "max": 128
                        }
                    },
                    "required": [
                        "bucket",
                        "accessKeyId",
                        "secretAccessKey",
                        "region"
                    ],
                    "additionalProperties": false
                },
                "gcs": {
                    "type": "object",
                    "properties": {
                        "projectId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 1024
                        },
                        "keyJson": {
                            "type": "string",
                            "maxLength": 32767,
                            "minLength": 4
                        },
                        "bucket": {
                            "type": "string",
                            "max": 255
                        }
                    },
                    "required": [
                        "projectId",
                        "keyJson",
                        "bucket"
                    ],
                    "additionalProperties": false
                },
                "azure": {
                    "type": "object",
                    "properties": {
                        "account": {
                            "type": "string",
                            "min": 3,
                            "max": 24
                        },
                        "accountKey": {
                            "type": "string",
                            "max": 255
                        },
                        "bucket": {
                            "type": "string",
                            "min": 3,
                            "max": 63
                        }
                    },
                    "required": [
                        "account",
                        "accountKey",
                        "bucket"
                    ],
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "blobUrlTTL": {
            "type": "number",
            "minimum": 3600,
            "maximum": 604800
        }
    },
    "additionalProperties": false,
    "required": [
        "name"
    ]
}