{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/gsma/json-schema/gsma-subscription-request-schema.json",
  "title": "SubscriptionRequest",
  "description": "The request for creating a event-type event subscription",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/gsma-connectivity-insights-subscriptions-api-openapi.yml#/components/schemas/SubscriptionRequest",
  "type": "object",
  "required": [
    "sink",
    "protocol",
    "config",
    "types"
  ],
  "properties": {
    "protocol": {
      "$ref": "#/$defs/Protocol"
    },
    "sink": {
      "type": "string",
      "format": "url",
      "description": "The address to which events shall be delivered using the selected\nprotocol.\n"
    },
    "sinkCredential": {
      "$ref": "#/$defs/SinkCredential"
    },
    "types": {
      "description": "Camara Event types eligible to be delivered by this subscription.\nNote: for the Commonalities meta-release v0.4 we enforce to have\nonly event type per subscription then for following meta-release\nuse of array MUST be decided at API project level.\n",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "config": {
      "$ref": "#/$defs/Config"
    }
  },
  "$defs": {
    "ApplicationProfileId": {
      "description": "Identifier for the Application Profile",
      "type": "string",
      "format": "uuid"
    },
    "ApplicationServer": {
      "description": "A server hosting backend applications to deliver some business logic to\nclients.\n\nThe developer can choose to provide the below specified device\nidentifiers:\n\n* `ipv4Address`\n* `ipv6Address`\n\nThe Operator will use this information to calculate the end to end\nnetwork performance in scenarios where its feasible.\n",
      "type": "object",
      "properties": {
        "ipv4Address": {
          "$ref": "#/$defs/ApplicationServerIpv4Address"
        },
        "ipv6Address": {
          "$ref": "#/$defs/ApplicationServerIpv6Address"
        }
      },
      "minProperties": 1
    },
    "ApplicationServerIpv4Address": {
      "type": "string",
      "description": "IPv4 address may be specified in form <address/mask> as:\n  - address - an IPv4 number in dotted-quad form 1.2.3.4. Only this\n  exact IP number will match the flow control rule.\n  - address/mask - an IP number as above with a mask width of the\n  form 1.2.3.4/24.\n    In this case, all IP numbers from 1.2.3.0 to 1.2.3.255 will match.\n    The bit width MUST be valid for the IP version.\n"
    },
    "ApplicationServerIpv6Address": {
      "type": "string",
      "description": "IPv6 address may be specified in form <address/mask> as:\n  - address - The /128 subnet is optional for single addresses:\n    - 2001:db8:85a3:8d3:1319:8a2e:370:7344\n    - 2001:db8:85a3:8d3:1319:8a2e:370:7344/128\n  - address/mask - an IP v6 number with a mask:\n    - 2001:db8:85a3:8d3::0/64\n    - 2001:db8:85a3:8d3::/64\n"
    },
    "Config": {
      "description": "Implementation-specific configuration parameters needed by the\nsubscription manager for acquiring events.\nIn CAMARA we have predefined attributes like `subscriptionExpireTime`,\n`subscriptionMaxEvents`, `initialEvent`\nSpecific event type attributes must be defined in `subscriptionDetail`\nNote: if a request is performed for several event type, all subscribed\nevent will use same `config` parameters.\n",
      "type": "object",
      "required": [
        "subscriptionDetail"
      ],
      "properties": {
        "subscriptionDetail": {
          "$ref": "#/$defs/CreateSubscriptionDetail"
        },
        "subscriptionExpireTime": {
          "type": "string",
          "format": "date-time",
          "description": "The subscription expiration time (in date-time format) requested by\nthe API consumer. Up to API project decision to keep it.\n"
        },
        "subscriptionMaxEvents": {
          "type": "integer",
          "description": "Identifies the maximum number of event reports to be generated\n(>=1) requested by the API consumer - Once this number is reached,\nthe subscription ends. Up to API project decision to keep it.\n",
          "minimum": 1
        },
        "initialEvent": {
          "type": "boolean",
          "description": "Set to `true` by API consumer if consumer wants to get an event as\nsoon as the subscription is created and current situation reflects\nevent request.\nExample: Consumer request Roaming event. If consumer sets\ninitialEvent to true and device is in roaming situation, an event\nis triggered Up to API project decision to keep it.\n"
        }
      }
    },
    "CreateSubscriptionDetail": {
      "description": "The detail of the requested event subscription",
      "type": "object",
      "properties": {
        "device": {
          "$ref": "#/$defs/Device"
        },
        "applicationServer": {
          "$ref": "#/$defs/ApplicationServer"
        },
        "applicationServerPorts": {
          "description": "A list of single ports or port ranges on the application server\n",
          "allOf": [
            {
              "$ref": "#/$defs/PortsSpec"
            }
          ]
        },
        "applicationProfileId": {
          "$ref": "#/$defs/ApplicationProfileId"
        }
      },
      "required": [
        "device",
        "applicationProfileId"
      ]
    },
    "Device": {
      "description": "End-user equipment able to connect to a mobile network. Examples of\ndevices include smartphones or IoT sensors/actuators.\n\nThe developer can choose to provide the below specified device\nidentifiers:\n\n* `ipv4Address`\n* `ipv6Address`\n* `phoneNumber`\n* `networkAccessIdentifier`\n\nNOTE1: the MNO might support only a subset of these options. The\nAPI invoker can provide multiple identifiers to be compatible across\ndifferent MNOs. In this case the identifiers MUST belong to the same\ndevice.\nNOTE2: for the Commonalities release v0.4, we are enforcing that the\nnetworkAccessIdentifier is only part of the schema for future-proofing,\nand CAMARA does not currently allow its use. After the CAMARA\nmeta-release work is concluded and the relevant issues are resolved,\nits use will need to be explicitly documented in the guidelines.\n",
      "type": "object",
      "properties": {
        "phoneNumber": {
          "$ref": "#/$defs/PhoneNumber"
        },
        "networkAccessIdentifier": {
          "$ref": "#/$defs/NetworkAccessIdentifier"
        },
        "ipv4Address": {
          "$ref": "#/$defs/DeviceIpv4Addr"
        },
        "ipv6Address": {
          "$ref": "#/$defs/DeviceIpv6Address"
        }
      },
      "minProperties": 1
    },
    "DeviceIpv4Addr": {
      "type": "object",
      "description": "The device should be identified by either the public (observed) IP\naddress and port as seen by the application server, or the private\n(local) and any public (observed) IP addresses in use by the device\n(this information can be obtained by various means, for example from\nsome DNS servers).\n\nIf the allocated and observed IP addresses are the same (i.e. NAT is\nnot in use) then  the same address should be specified for both\npublicAddress and privateAddress.\n\nIf NAT64 is in use, the device should be identified by its\npublicAddress and publicPort, or separately by its allocated IPv6\naddress (field ipv6Address of the Device object)\n\nIn all cases, publicAddress must be specified, along with at least one\nof either privateAddress or publicPort, dependent upon which is known.\nIn general, mobile devices cannot be identified by their public IPv4\naddress alone.\n",
      "properties": {
        "publicAddress": {
          "$ref": "#/$defs/SingleIpv4Addr"
        },
        "privateAddress": {
          "$ref": "#/$defs/SingleIpv4Addr"
        },
        "publicPort": {
          "$ref": "#/$defs/Port"
        }
      },
      "anyOf": [
        {
          "required": [
            "publicAddress",
            "privateAddress"
          ]
        },
        {
          "required": [
            "publicAddress",
            "publicPort"
          ]
        }
      ]
    },
    "DeviceIpv6Address": {
      "description": "The device should be identified by the observed IPv6 address, or by any\nsingle IPv6 address from within the subnet allocated to the device\n(e.g. adding ::0 to the /64 prefix).\n\nThe session shall apply to all IP flows between the device subnet and\nthe specified application server, unless further restricted by the\noptional parameters devicePorts or applicationServerPorts.\n",
      "type": "string",
      "format": "ipv6"
    },
    "NetworkAccessIdentifier": {
      "description": "A public identifier addressing a subscription in a mobile network. In\n3GPP terminology, it corresponds to the GPSI formatted with the\nExternal Identifier ({Local Identifier}@{Domain Identifier}). Unlike\nthe telephone number, the network access identifier is not subjected\nto portability ruling in force, and is individually managed by each\noperator.\n",
      "type": "string"
    },
    "PhoneNumber": {
      "description": "A public identifier addressing a telephone subscription. In mobile\nnetworks it corresponds to the MSISDN (Mobile Station International\nSubscriber Directory Number). In order to be globally unique it has to\nbe formatted in international format, according to E.164 standard,\noptionally prefixed with '+'.\n",
      "type": "string",
      "pattern": "^\\+?[0-9]{5,15}$"
    },
    "Port": {
      "description": "TCP or UDP port number",
      "type": "integer",
      "minimum": 0,
      "maximum": 65535
    },
    "PortsSpec": {
      "description": "Specification of several TCP or UDP ports",
      "type": "object",
      "minProperties": 1,
      "properties": {
        "ranges": {
          "description": "Range of TCP or UDP ports",
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "from",
              "to"
            ],
            "properties": {
              "from": {
                "$ref": "#/$defs/Port"
              },
              "to": {
                "$ref": "#/$defs/Port"
              }
            }
          }
        },
        "ports": {
          "description": "Array of TCP or UDP ports",
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/Port"
          }
        }
      }
    },
    "Protocol": {
      "type": "string",
      "enum": [
        "HTTP",
        "MQTT3",
        "MQTT5",
        "AMQP",
        "NATS",
        "KAFKA"
      ],
      "description": "Identifier of a delivery protocol. Only HTTP is allowed for now\n"
    },
    "SingleIpv4Addr": {
      "description": "A single IPv4 address with no subnet mask",
      "type": "string",
      "format": "ipv4"
    },
    "SinkCredential": {
      "type": "object",
      "description": "A sink credential provides authentication or authorization information\n",
      "properties": {
        "credentialType": {
          "type": "string",
          "enum": [
            "PLAIN",
            "ACCESSTOKEN",
            "REFRESHTOKEN"
          ],
          "description": "The type of the credential."
        }
      },
      "required": [
        "credentialType"
      ]
    }
  }
}