{
    "name": "user",
    "type": "record",
    "fields": [
        {
            "name": "uid",
            "doc": "User ID. Can be one of anid, ifa, xfa, external_id, device_id type.",
            "type": [
                "long",
                {
                    "name": "eid",
                    "type": "record",
                    "doc": "Single user identity",
                    "fields": [
                        {
                            "name": "source",
                            "type": "string",
                            "doc": "Identity code from Identity Settings Service"
                        },
                        {
                            "name": "id",
                            "type": "string",
                            "doc": "User identity"
                        }
                    ]
                },
                {
                    "name": "ifa",
                    "type": "record",
                    "doc": "Identifier for Advertising record by iabtechlab.com",
                    "fields": [
                        {
                            "name": "id",
                            "type": "string",
                            "doc": "IFA in UUID format."
                        },
                        {
                            "name": "type",
                            "type": "string",
                            "doc": "IFA type."
                        }
                    ]
                },
                {
                    "name": "xfa",
                    "type": "record",
                    "doc": "Xandr synthetic ID record.",
                    "fields": [
                        {
                            "name": "device_model_id",
                            "type": "int",
                            "doc": "Device atlas device model.",
                            "default": 0
                        },
                        {
                            "name": "device_make_id",
                            "type": "int",
                            "doc": "Device atlas device make.",
                            "default": 0
                        },
                        {
                            "name": "ip",
                            "type": "string",
                            "default": "",
                            "doc": "Residential IP address."
                        }
                    ]
                },
                {
                    "name": "external_id",
                    "type": "record",
                    "doc": "External ID record.",
                    "fields": [
                        {
                            "name": "id",
                            "type": "string",
                            "doc": "External ID provided by member."
                        },
                        {
                            "name": "member_id",
                            "type": "int",
                            "doc": "Owner member ID.",
                            "default": 0
                        }
                    ]
                },
                {
                    "name": "device_id",
                    "type": "record",
                    "doc": "Mobile device ID record.",
                    "fields": [
                        {
                            "name": "id",
                            "type": "string",
                            "doc": "Mobile device ID."
                        },
                        {
                            "name": "domain",
                            "type": {
                                "name": "domain",
                                "type": "enum",
                                "doc": "Mobile device domain.",
                                "symbols": [
                                    "idfa",
                                    "sha1udid",
                                    "md5udid",
                                    "openudid",
                                    "aaid",
                                    "windowsadid",
                                    "rida"
                                ]
                            }
                        }
                    ]
                },
                {
                    "name": "aes_encrypted",
                    "type": "record",
                    "doc": "AES encrypted id, ID+PKCS5 padding (to get 16x bytes block size), then AES-CBC.",
                    "fields": [
                        {
                            "name": "ciphertext",
                            "type": "bytes",
                            "doc": "Encrypted id interpreted as either one of: anid, external_id, device_id depending on the value of set_name field."
                        },
                        {
                            "name": "iv",
                            "type": "bytes",
                            "doc": "Initialization vector."
                        },
                        {
                            "name": "key_id",
                            "type": "int",
                            "doc": "Key index in our database."
                        },
                        {
                            "name": "set_name",
                            "doc": "Empty/omitted for anid/external_id or enum value from device_id.domain",
                            "default": null,
                            "type": ["null", "domain"]
                        }
                    ]
                },
                {
                    "name": "hem",
                    "type": "record",
                    "doc": "A record representing hashed email",
                    "fields": [
                        {
                            "name": "hex_encoded",
                            "type": "string",
                            "doc": "A hex encoded string representing hashed email"
                        }
                    ]
                }
            ]
        },
        {
            "name": "segments",
            "doc": "Array of segments.",
            "type": {
                "type": "array",
                "doc": "Element of the segments array.",
                "items": {
                    "name": "segment",
                    "type": "record",
                    "fields": [
                        {
                            "name": "id",
                            "type": "int",
                            "doc": "Segment ID. Alternatively, pair of code and member_id can be used.",
                            "default": 0
                        },
                        {
                            "name": "code",
                            "type": "string",
                            "doc": "Segment code. Requires segment.member_id.",
                            "default": ""
                        },
                        {
                            "name": "member_id",
                            "type": "int",
                            "doc": "Segment member ID. Requires segment.code.",
                            "default": 0
                        },
                        {
                            "name": "expiration",
                            "type": "int",
                            "doc": "Segment expiration in minutes. 0: max expiration (180 days); -2: default expiration; -1: segment removal.",
                            "default": 0
                        },
                        {
                            "name": "timestamp",
                            "type": "long",
                            "doc": "Defines when segment becomes 'live'. Timestamp in seconds from epoch. 0 enables segment immediately",
                            "default": 0
                        },
                        {
                            "name": "value",
                            "type": "int",
                            "doc": "User provided value associated with the segment.",
                            "default": 0
                        }
                    ]
                }
            }
        }
    ]
}
