Skip to content
Get started

Create a geofencing subscription for a device

POST/devicelocation/subscriptions

Create a subscription for a device to receive notifications when the device enters or exits a specified area.

Header ParametersExpand Collapse
"x-correlator": optional string
Body ParametersJSONExpand Collapse
config: DeviceLocationConfig { initialEvent, subscriptionExpireTime, subscriptionMaxEvents }

Implementation-specific configuration parameters are needed by the subscription manager for acquiring events. In CAMARA we have predefined attributes like subscriptionExpireTime, subscriptionMaxEvents, initialEvent.

subscriptionDetail: object { area, device }

The detail of the requested event subscription.

area: DeviceLocationArea { areaType }

The geofencing area where the monitor is active. This area is specified by API consumers in the subscription request. The same area definition is included in event notifications without any modifications.

areaType: "CIRCLE"

Type of this area. CIRCLE - The area is defined as a circle.

device: optional DeviceLocationDevice { ipv4Address, ipv6Address, networkAccessIdentifier, phoneNumber }

End-user device able to connect to a mobile network. Examples of devices include smartphones or IoT sensors/actuators.

The developer can choose to provide the below specified device identifiers:

  • ipv4Address
  • ipv6Address
  • phoneNumber
  • networkAccessIdentifier

NOTE1: the API provider might support only a subset of these options. The API consumer can provide multiple identifiers to be compatible across different API providers. In this case the identifiers MUST belong to the same device. Where more than one device identifier is provided, only one identifier will be selected by the implementation and this choice indicated to the API consumer in the response or event. NOTE2: as for this Commonalities release, we are enforcing that the networkAccessIdentifier is only part of the schema for future-proofing, and CAMARA does not currently allow its use. After the CAMARA meta-release work is concluded and the relevant issues are resolved, its use will need to be explicitly documented in the guidelines.

ipv4Address: optional object { privateAddress, publicAddress, publicPort }

The device should be identified by either the public (observed) IP address and port as seen by the application server, or the private (local) and any public (observed) IP addresses in use by the device (this information can be obtained by various means, for example from some DNS servers).

If the allocated and observed IP addresses are the same (i.e. NAT is not in use) then the same address should be specified for both publicAddress and privateAddress.

If NAT64 is in use, the device should be identified by its publicAddress and publicPort, or separately by its allocated IPv6 address (field ipv6Address of the Device object)

In all cases, publicAddress must be specified, along with at least one of either privateAddress or publicPort, dependent upon which is known. In general, mobile devices cannot be identified by their public IPv4 address alone.

privateAddress: optional string

A single IPv4 address with no subnet mask.

formatipv4
publicAddress: optional string

A single IPv4 address with no subnet mask.

formatipv4
publicPort: optional number

TCP or UDP port number.

minimum0
maximum65535
ipv6Address: optional string

The device should be identified by the observed IPv6 address, or by any single IPv6 address from within the subnet allocated to the device (e.g. adding ::0 to the /64 prefix).

formatipv6
networkAccessIdentifier: optional string

A public identifier addressing a subscription in a mobile network. In 3GPP terminology, it corresponds to the GPSI formatted with the External Identifier ({Local Identifier}@{Domain Identifier}). Unlike the telephone number, the network access identifier is not subjected to portability ruling in force, and is individually managed by each operator.

phoneNumber: optional string

A public identifier addressing a telephone subscription. In mobile networks, it corresponds to the MSISDN (Mobile Station International Subscriber Directory Number). In order to be globally unique it has to be formatted in international format, according to E.164 standard, prefixed with ’+’.

Identifier of a delivery protocol. Only HTTP is allowed for now.

One of the following:
"HTTP"
"MQTT3"
"MQTT5"
"AMQP"
"NATS"
"KAFKA"
sink: string

The address to which events shall be delivered using the selected protocol.

formaturi

Camara Event types which are eligible to be delivered by this subscription. Note: As of now we enforce to have only event type per subscription.

One of the following:
"org.camaraproject.geofencing-subscriptions.v0.area-entered"
"org.camaraproject.geofencing-subscriptions.v0.area-left"
sinkCredential: optional object { credentialType }

A sink credential provides authentication or authorization information necessary to enable delivery of events to a target.

credentialType: "PLAIN" or "ACCESSTOKEN" or "REFRESHTOKEN"

The type of the credential. Note: Type of the credential - MUST be set to ACCESSTOKEN for now

One of the following:
"PLAIN"
"ACCESSTOKEN"
"REFRESHTOKEN"
ReturnsExpand Collapse
DeviceLocationSubscription object { id, config, protocol, 5 more }

Represents a event-type subscription.

id: string

The unique identifier of the subscription in the scope of the subscription manager. When this information is contained within an event notification, this concept SHALL be referred as subscriptionId as per Commonalities Event Notification Model.

config: DeviceLocationConfig { initialEvent, subscriptionExpireTime, subscriptionMaxEvents }

Implementation-specific configuration parameters are needed by the subscription manager for acquiring events. In CAMARA we have predefined attributes like subscriptionExpireTime, subscriptionMaxEvents, initialEvent.

subscriptionDetail: object { area, device }

The detail of the event subscription granted by the implementation.

area: DeviceLocationArea { areaType }

The geofencing area where the monitor is active. This area is specified by API consumers in the subscription request. The same area definition is included in event notifications without any modifications.

areaType: "CIRCLE"

Type of this area. CIRCLE - The area is defined as a circle.

device: optional DeviceLocationDevice { ipv4Address, ipv6Address, networkAccessIdentifier, phoneNumber }

End-user device able to connect to a mobile network. Examples of devices include smartphones or IoT sensors/actuators.

The developer can choose to provide the below specified device identifiers:

  • ipv4Address
  • ipv6Address
  • phoneNumber
  • networkAccessIdentifier

NOTE1: the API provider might support only a subset of these options. The API consumer can provide multiple identifiers to be compatible across different API providers. In this case the identifiers MUST belong to the same device. Where more than one device identifier is provided, only one identifier will be selected by the implementation and this choice indicated to the API consumer in the response or event. NOTE2: as for this Commonalities release, we are enforcing that the networkAccessIdentifier is only part of the schema for future-proofing, and CAMARA does not currently allow its use. After the CAMARA meta-release work is concluded and the relevant issues are resolved, its use will need to be explicitly documented in the guidelines.

ipv4Address: optional object { privateAddress, publicAddress, publicPort }

The device should be identified by either the public (observed) IP address and port as seen by the application server, or the private (local) and any public (observed) IP addresses in use by the device (this information can be obtained by various means, for example from some DNS servers).

If the allocated and observed IP addresses are the same (i.e. NAT is not in use) then the same address should be specified for both publicAddress and privateAddress.

If NAT64 is in use, the device should be identified by its publicAddress and publicPort, or separately by its allocated IPv6 address (field ipv6Address of the Device object)

In all cases, publicAddress must be specified, along with at least one of either privateAddress or publicPort, dependent upon which is known. In general, mobile devices cannot be identified by their public IPv4 address alone.

privateAddress: optional string

A single IPv4 address with no subnet mask.

formatipv4
publicAddress: optional string

A single IPv4 address with no subnet mask.

formatipv4
publicPort: optional number

TCP or UDP port number.

minimum0
maximum65535
ipv6Address: optional string

The device should be identified by the observed IPv6 address, or by any single IPv6 address from within the subnet allocated to the device (e.g. adding ::0 to the /64 prefix).

formatipv6
networkAccessIdentifier: optional string

A public identifier addressing a subscription in a mobile network. In 3GPP terminology, it corresponds to the GPSI formatted with the External Identifier ({Local Identifier}@{Domain Identifier}). Unlike the telephone number, the network access identifier is not subjected to portability ruling in force, and is individually managed by each operator.

phoneNumber: optional string

A public identifier addressing a telephone subscription. In mobile networks, it corresponds to the MSISDN (Mobile Station International Subscriber Directory Number). In order to be globally unique it has to be formatted in international format, according to E.164 standard, prefixed with ’+’.

Identifier of a delivery protocol. Only HTTP is allowed for now.

One of the following:
"HTTP"
"MQTT3"
"MQTT5"
"AMQP"
"NATS"
"KAFKA"
sink: string

The address to which events shall be delivered using the selected protocol.

formaturi
startsAt: string

Date when the event subscription will begin/began It must follow RFC 3339 and must have time zone.

formatdate-time

Camara Event types eligible to be delivered by this subscription. Note: As of now we enforce to have only event type per subscription.

One of the following:
"org.camaraproject.geofencing-subscriptions.v0.area-entered"
"org.camaraproject.geofencing-subscriptions.v0.area-left"
expiresAt: optional string

Date when the event subscription will expire. Only provided when subscriptionExpireTime is indicated by API client or Telco Operator has specific policy about that. It must follow RFC 3339 and must have time zone.

formatdate-time
status: optional "ACTIVATION_REQUESTED" or "ACTIVE" or "EXPIRED" or 2 more

Current status of the subscription - Management of Subscription State engine is not mandatory for now. Note not all statuses may be considered to be implemented. Details:

  • ACTIVATION_REQUESTED: Subscription creation (POST) is triggered but subscription creation process is not finished yet.
  • ACTIVE: Subscription creation process is completed. Subscription is fully operative.
  • INACTIVE: Subscription is temporarily inactive, but its workflow logic is not deleted.
  • EXPIRED: Subscription is ended (no longer active). This status applies when subscription is ended due to SUBSCRIPTION_EXPIRED or ACCESS_TOKEN_EXPIRED event.
  • DELETED: Subscription is ended as deleted (no longer active). This status applies when subscription information is kept (i.e. subscription workflow is no longer active but its meta-information is kept).
One of the following:
"ACTIVATION_REQUESTED"
"ACTIVE"
"EXPIRED"
"INACTIVE"
"DELETED"

Create a geofencing subscription for a device

curl https://api.example.com/camara/devicelocation/subscriptions \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $CAMARA_BEARER_TOKEN" \
    -d '{
          "config": {
            "initialEvent": true,
            "subscriptionExpireTime": "2024-03-22T05:40:58.469Z",
            "subscriptionMaxEvents": 10,
            "subscriptionDetail": {
              "area": {
                "areaType": "CIRCLE"
              },
              "device": {
                "phoneNumber": "+12345678912"
              }
            }
          },
          "protocol": "HTTP",
          "sink": "https://notificationSendServer12.supertelco.com",
          "types": [
            "org.camaraproject.geofencing-subscriptions.v0.area-entered"
          ]
        }'
{
  "id": "1119920371",
  "config": {
    "initialEvent": true,
    "subscriptionExpireTime": "2023-01-17T13:18:23.682Z",
    "subscriptionMaxEvents": 5,
    "subscriptionDetail": {
      "area": {
        "areaType": "CIRCLE"
      },
      "device": {
        "ipv4Address": {
          "privateAddress": "84.125.93.10",
          "publicAddress": "84.125.93.10",
          "publicPort": 59765
        },
        "ipv6Address": "2001:db8:85a3:8d3:1319:8a2e:370:7344",
        "networkAccessIdentifier": "123456789@domain.com",
        "phoneNumber": "+123456789"
      }
    }
  },
  "protocol": "HTTP",
  "sink": "https://endpoint.example.com/sink",
  "startsAt": "2023-07-03T12:27:08.312Z",
  "types": [
    "org.camaraproject.geofencing-subscriptions.v0.area-entered"
  ],
  "expiresAt": "2023-07-03T12:27:08.312Z",
  "status": "ACTIVATION_REQUESTED"
}
{
  "status": 400,
  "code": "INVALID_ARGUMENT",
  "message": "Client specified an invalid argument, request body or query param."
}
{
  "status": 400,
  "code": "INVALID_PROTOCOL",
  "message": "Only HTTP is supported."
}
{
  "status": 400,
  "code": "INVALID_CREDENTIAL",
  "message": "Only Access token is supported."
}
{
  "status": 400,
  "code": "INVALID_TOKEN",
  "message": "Only bearer token is supported."
}
{
  "status": 400,
  "code": "INVALID_SINK",
  "message": "sink not valid for the specified protocol"
}
{
  "status": 401,
  "code": "UNAUTHENTICATED",
  "message": "Request not authenticated due to missing, invalid, or expired credentials. A new authentication is required."
}
{
  "status": 403,
  "code": "PERMISSION_DENIED",
  "message": "Client does not have sufficient permissions to perform this action."
}
{
  "status": 422,
  "code": "SERVICE_NOT_APPLICABLE",
  "message": "The service is not available for the provided identifier."
}
{
  "status": 422,
  "code": "MISSING_IDENTIFIER",
  "message": "The device cannot be identified."
}
{
  "status": 422,
  "code": "MULTIEVENT_SUBSCRIPTION_NOT_SUPPORTED",
  "message": "Multi event types subscription not managed."
}
{
  "status": 422,
  "code": "UNNECESSARY_IDENTIFIER",
  "message": "The device is already identified by the access token."
}
{
  "status": 422,
  "code": "UNSUPPORTED_IDENTIFIER",
  "message": "The identifier provided is not supported."
}
{
  "status": 422,
  "code": "GEOFENCING_SUBSCRIPTIONS.AREA_NOT_COVERED",
  "message": "Unable to cover the requested area"
}
{
  "status": 422,
  "code": "GEOFENCING_SUBSCRIPTIONS.INVALID_AREA",
  "message": "The requested area is too small"
}
{
  "status": 429,
  "code": "QUOTA_EXCEEDED",
  "message": "Out of resource quota."
}
{
  "status": 429,
  "code": "TOO_MANY_REQUESTS",
  "message": "Rate limit reached."
}
Returns Examples
{
  "id": "1119920371",
  "config": {
    "initialEvent": true,
    "subscriptionExpireTime": "2023-01-17T13:18:23.682Z",
    "subscriptionMaxEvents": 5,
    "subscriptionDetail": {
      "area": {
        "areaType": "CIRCLE"
      },
      "device": {
        "ipv4Address": {
          "privateAddress": "84.125.93.10",
          "publicAddress": "84.125.93.10",
          "publicPort": 59765
        },
        "ipv6Address": "2001:db8:85a3:8d3:1319:8a2e:370:7344",
        "networkAccessIdentifier": "123456789@domain.com",
        "phoneNumber": "+123456789"
      }
    }
  },
  "protocol": "HTTP",
  "sink": "https://endpoint.example.com/sink",
  "startsAt": "2023-07-03T12:27:08.312Z",
  "types": [
    "org.camaraproject.geofencing-subscriptions.v0.area-entered"
  ],
  "expiresAt": "2023-07-03T12:27:08.312Z",
  "status": "ACTIVATION_REQUESTED"
}
{
  "status": 400,
  "code": "INVALID_ARGUMENT",
  "message": "Client specified an invalid argument, request body or query param."
}
{
  "status": 400,
  "code": "INVALID_PROTOCOL",
  "message": "Only HTTP is supported."
}
{
  "status": 400,
  "code": "INVALID_CREDENTIAL",
  "message": "Only Access token is supported."
}
{
  "status": 400,
  "code": "INVALID_TOKEN",
  "message": "Only bearer token is supported."
}
{
  "status": 400,
  "code": "INVALID_SINK",
  "message": "sink not valid for the specified protocol"
}
{
  "status": 401,
  "code": "UNAUTHENTICATED",
  "message": "Request not authenticated due to missing, invalid, or expired credentials. A new authentication is required."
}
{
  "status": 403,
  "code": "PERMISSION_DENIED",
  "message": "Client does not have sufficient permissions to perform this action."
}
{
  "status": 422,
  "code": "SERVICE_NOT_APPLICABLE",
  "message": "The service is not available for the provided identifier."
}
{
  "status": 422,
  "code": "MISSING_IDENTIFIER",
  "message": "The device cannot be identified."
}
{
  "status": 422,
  "code": "MULTIEVENT_SUBSCRIPTION_NOT_SUPPORTED",
  "message": "Multi event types subscription not managed."
}
{
  "status": 422,
  "code": "UNNECESSARY_IDENTIFIER",
  "message": "The device is already identified by the access token."
}
{
  "status": 422,
  "code": "UNSUPPORTED_IDENTIFIER",
  "message": "The identifier provided is not supported."
}
{
  "status": 422,
  "code": "GEOFENCING_SUBSCRIPTIONS.AREA_NOT_COVERED",
  "message": "Unable to cover the requested area"
}
{
  "status": 422,
  "code": "GEOFENCING_SUBSCRIPTIONS.INVALID_AREA",
  "message": "The requested area is too small"
}
{
  "status": 429,
  "code": "QUOTA_EXCEEDED",
  "message": "Out of resource quota."
}
{
  "status": 429,
  "code": "TOO_MANY_REQUESTS",
  "message": "Rate limit reached."
}