{
    "id": "http://schemas.triniti.io/json-schema/gdbots/pbjx/envelope/1-0-2.json#",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
        "_schema": {
            "type": "string",
            "pattern": "^pbj:([a-z0-9-]+):([a-z0-9\\.-]+):([a-z0-9-]+)?:([a-z0-9-]+):([0-9]+-[0-9]+-[0-9]+)$",
            "default": "pbj:gdbots:pbjx::envelope:1-0-2"
        },
        "envelope_id": {
            "type": "string",
            "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
            "pbj": {
                "type": "uuid",
                "rule": "single"
            }
        },
        "ok": {
            "type": "boolean",
            "default": true,
            "pbj": {
                "type": "boolean",
                "rule": "single"
            }
        },
        "code": {
            "type": "integer",
            "default": 0,
            "minimum": 0,
            "maximum": 65535,
            "pbj": {
                "type": "small-int",
                "rule": "single"
            }
        },
        "http_code": {
            "type": "integer",
            "default": 200,
            "enum": [
                0,
                100,
                101,
                102,
                200,
                201,
                202,
                203,
                204,
                205,
                206,
                207,
                208,
                226,
                300,
                301,
                302,
                303,
                304,
                305,
                306,
                307,
                308,
                400,
                401,
                402,
                403,
                404,
                405,
                406,
                407,
                408,
                409,
                410,
                411,
                412,
                413,
                414,
                415,
                416,
                417,
                418,
                422,
                423,
                424,
                425,
                426,
                428,
                429,
                499,
                431,
                451,
                500,
                501,
                502,
                503,
                504,
                505,
                506,
                507,
                508,
                510,
                511
            ],
            "pbj": {
                "type": "int-enum",
                "rule": "single"
            }
        },
        "etag": {
            "type": "string",
            "pattern": "^[\\w\\.:-]+$",
            "pbj": {
                "type": "string",
                "rule": "single"
            }
        },
        "error_name": {
            "type": "string",
            "pattern": "^[\\w\\/\\.:-]+$",
            "pbj": {
                "type": "string",
                "rule": "single"
            }
        },
        "error_message": {
            "type": "string",
            "minLength": 0,
            "maxLength": 65535,
            "pbj": {
                "type": "text",
                "rule": "single"
            }
        },
        "message_ref": {
            "type": "object",
            "properties": {
                "curie": {
                    "type": "string",
                    "pattern": "^([a-z0-9-]+):([a-z0-9\\.-]+):([a-z0-9-]+)?:([a-z0-9-]+)$",
                    "minLength": 0,
                    "maxLength": 146
                },
                "id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9:_\\-]+$",
                    "minLength": 0,
                    "maxLength": 255
                },
                "tag": {
                    "type": "string",
                    "pattern": "^([\\w\\/-]|[\\w-][\\w\\/-]*[\\w-])$",
                    "minLength": 0,
                    "maxLength": 255
                }
            },
            "required": [
                "curie",
                "id"
            ],
            "additionalProperties": false,
            "pbj": {
                "type": "message-ref",
                "rule": "single"
            }
        },
        "message": {
            "type": "object",
            "pbj": {
                "type": "message",
                "rule": "single"
            }
        },
        "derefs": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z_]{1}[\\w\\.:-]+$": {
                    "type": "object"
                }
            },
            "additionalProperties": false,
            "description": "Some pbjx operations (normally requests) can include \"dereferenced\" messages on the envelope to prevent the consumer from needing to make multiple HTTP requests. It is up to the consumer to make use of the dereferenced messages if/when they are provided.",
            "pbj": {
                "type": "message",
                "rule": "map"
            }
        },
        "links": {
            "type": "object",
            "patternProperties": {
                "^[a-zA-Z_]{1}[\\w\\.:-]+$": {
                    "type": "string",
                    "pattern": "^(https?:\\/\\/)?([\\da-z\\.-]+)\\.([a-z\\.]{2,6})([\\/\\w \\.-]*)*\\/?$"
                }
            },
            "additionalProperties": false,
            "description": "@link https://en.wikipedia.org/wiki/HATEOAS",
            "pbj": {
                "type": "text",
                "rule": "map",
                "format": "url"
            }
        }
    },
    "required": [
        "_schema",
        "envelope_id"
    ],
    "additionalProperties": false
}