most-frequent-location
openapi: 3.0.3
info:
title: Most Frequent Location
description: |
The Most Frequent Location API provides API Consumers with the ability to verify the frequency of a device's location within a specific geographic area.
This API verifies if a device is present most of the time in a certain location. This location insight is useful as an approach to the residence location of the end-user.
This API can be used in anti-fraud cases where an application provider needs further evidence about the reported place of residence of the end-user. Also, for service provision or personalization tasks when the service provider needs to manage their offer depending on the habits of the end-user.
Such use cases are transversal to different sectors such as:
- Financial institutions: to mitigate risks about identity fraud, helping in their compliance with AML/KYC regulation.
- Insurance companies: to assess risks and prevent fraudulent claims.
- E-commerce and retail: to ensure accurate shipping and delivery, fraud prevention and targeted marketing.
- Digital Content Delivery companies: to verify service provisioning and billing, and to comply with regulation.
- Utilities: to verify service provisioning and billing, and to prevent service theft.
- Real estate: to screen potential tenants and ensure that lease agreements are in compliance with local laws.
* **Device**: End-user equipment able to connect to a network. Examples of devices include smartphones, home gateways or IoT sensors/actuators.
* **Geographical reference**: Using coordinates or a reference code, the geographical surface where a device can be physically located is specified.
* **Verification**: The process triggered on the API server to calculate the frequency of time a device is at a given location.
The API allows API Consumers to verify the frequency with which a device is in a specific location. The location can be specified using a geographical reference of type:
- `COVERAGE_ZONE`: It is specified by latitude and longitude coordinates. The coverage area is generated by one or more antennas closest to the specified coordinates, determining the device's connection to these antennas.
- `POSTAL_CODE`: A zip code or postal code that delimits a geographic area.
The operation returns a score representing how frequently the device was connected to antennas whose coverage cover the requested area in certain time slots. The range of score values is between "0" and "100", where higher scores indicate a more frequent presence in the location.
The `score` value maps to the frequency as follows:
- `score = 0`: The device has never been in the specified location.
- `score = 100`: The device is almost always in the specified location.
This API requires the API consumer to identify a device as the subject of the API as follows:
- When the API is invoked using a two-legged access token, the subject will be identified from the optional `device` object, which therefore MUST be provided.
- When a three-legged access token is used however, this optional identifier MUST NOT be provided, as the subject will be uniquely identified from the access token.
This approach simplifies API usage for API consumers using a three-legged access token to invoke the API by relying on the information that is associated with the access token and was identified during the authentication process.
- If the subject cannot be identified from the access token and the optional `device` object is not included in the request, then the server will return an error with the `422 MISSING_IDENTIFIER` error code.
- If the subject can be identified from the access token and the optional `device` object is also included in the request, then the server will return an error with the `422 UNNECESSARY_IDENTIFIER` error code. This will be the case even if the same device is identified by these two methods, as the server is unable to make this comparison.
The "Camara Security and Interoperability Profile" provides details of how an API consumer requests an access token. Please refer to Identity and Consent Management (https://github.com/camaraproject/IdentityAndConsentManagement/) for the released version of the profile.
The specific authorization flows to be used will be agreed upon during the onboarding process, happening between the API consumer and the API provider, taking into account the declared purpose for accessing the API, whilst also being subject to the prevailing legal framework dictated by local legislation.
In cases where personal data is processed by the API and users can exercise their rights through mechanisms such as opt-in and/or opt-out, the use of three-legged access tokens is mandatory. This ensures that the API remains in compliance with privacy regulations, upholding the principles of transparency and user-centric privacy-by-design.
The list of error codes in this API specification is not exhaustive. Therefore the API specification may not document some non-mandatory error statuses as indicated in `CAMARA API Design Guide`.
Please refer to the `CAMARA_common.yaml` of the Commonalities Release associated to this API version for a complete list of error responses. The applicable Commonalities Release can be identified in the `API Readiness Checklist` document associated to this API version.
As a specific rule, error `501 - NOT_IMPLEMENTED` can be only a possible error response if it is explicitly documented in the API.
(FAQs will be added in a later version of the documentation)
license:
name: Apache 2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
version: 0.2.0
x-camara-commonalities: 0.6
externalDocs:
description: Product documentation at CAMARA
url: https://github.com/camaraproject/MostFrequentLocation
servers:
- url: "{apiRoot}/most-frequent-location/v0.2"
variables:
apiRoot:
default: http://localhost:9091
description: API root
tags:
- name: Frequent location verification
description: Verification of the most frequent location of a device
paths:
/verify:
post:
security:
- openId:
- most-frequent-location:verify
tags:
- Frequent location verification
summary: Verify the most frequent location of a device
description: |-
Verify the frequency with which a device is within a requested geographic area location. The location can be defined by a postal code or a latitude and longitude coordinates. The operation returns a score representing how frequently the device was connected to antennas whose coverage covers the requested area.
operationId: verifyFrequentLocation
parameters:
- $ref: '#/components/parameters/x-correlator'
requestBody:
description: Request body with a device as identifier and geographical reference for location
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/VerifyFrequentLocationRequest'
examples:
INPUT_PHONE_NUMBER_POSTAL_CODE:
summary: Phone number and postal code
description: Verify the frequency with which the device, identified by a phone number, has been in a location delimited by a postal code
value:
device:
phoneNumber: '+123456789'
geoReference:
type: POSTAL_CODE
postalCode: '12345'
INPUT_PHONE_NUMBER_COVERAGE_ZONE:
summary: Phone number and coverage zone
description: Verify the frequency with which the device, identified by a phone number, has been in a location delimited by a coverage zone specified by latitude and longitude coordinates
value:
device:
phoneNumber: '+123456789'
geoReference:
type: COVERAGE_ZONE
latitude: 50.735851
longitude: 7.10066
INPUT_IP_ADDRESS_V4_POSTAL_CODE:
summary: IPv4 address and postal code
description: Verify the frequency with which the device, identified by an IPv4 address, has been in a location delimited by a postal code
value:
device:
ipv4Address:
publicAddress: '123.234.1.2'
publicPort: 1234
geoReference:
type: POSTAL_CODE
postalCode: '12345'
INPUT_IP_ADDRESS_V4_COVERAGE_ZONE:
summary: IPv4 address and coverage zone
description: Verify the frequency with which the device, identified by an IPv4 address, has been in a location delimited by a coverage zone specified by latitude and longitude coordinates
value:
device:
ipv4Address:
publicAddress: '123.234.1.2'
publicPort: 1234
geoReference:
type: COVERAGE_ZONE
latitude: 50.735851
longitude: 7.10066
responses:
'200':
description: Most frequent location verification result
content:
application/json:
schema:
$ref: '#/components/schemas/VerifyFrequentLocationResponse'
examples:
HIGH_SCORE:
summary: High score with detail
description: The device has been at the requested location with high frequency for most of the time.
value:
score: 86
headers:
x-correlator:
$ref: '#/components/headers/x-correlator'
'400':
$ref: '#/components/responses/VerifyFrequentLocationBadRequest400'
'401':
$ref: '#/components/responses/Generic401'
'403':
$ref: '#/components/responses/VerifyFrequentLocationPermissionDenied403'
'404':
$ref: '#/components/responses/VerifyFrequentLocationNotFound404'
'422':
$ref: '#/components/responses/VerifyFrequentLocationUnprocessableEntity422'
components:
securitySchemes:
openId:
type: openIdConnect
openIdConnectUrl: https://example.com/.well-known/openid-configuration
schemas:
VerifyFrequentLocationRequest:
type: object
description: Request with a device as identifier and geographical reference for location
required:
- geoReference
properties:
device:
$ref: '#/components/schemas/Device'
geoReference:
$ref: '#/components/schemas/GeoReference'
VerifyFrequentLocationResponse:
type: object
description: Calculated Score Response
required:
- score
properties:
score:
$ref: '#/components/schemas/Score'
Device:
description: |-
End-user equipment 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 MNO might support only a subset of these options. The API invoker can provide multiple identifiers to be compatible across different MNOs. In this case the identifiers MUST belong to the same device.
NOTE2: for the Commonalities release v0.4, 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.
type: object
properties:
phoneNumber:
$ref: '#/components/schemas/PhoneNumber'
networkAccessIdentifier:
$ref: '#/components/schemas/NetworkAccessIdentifier'
ipv4Address:
$ref: '#/components/schemas/DeviceIpv4Addr'
ipv6Address:
$ref: '#/components/schemas/DeviceIpv6Address'
minProperties: 1
PhoneNumber:
description: 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 '+'.
type: string
pattern: '^\+[1-9][0-9]{4,14}$'
example: "+123456789"
NetworkAccessIdentifier:
description: 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.
type: string
example: 123456789@domain.com
DeviceIpv4Addr:
type: object
description: |-
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.
properties:
publicAddress:
$ref: '#/components/schemas/SingleIpv4Addr'
privateAddress:
$ref: '#/components/schemas/SingleIpv4Addr'
publicPort:
$ref: '#/components/schemas/Port'
anyOf:
- required:
- publicAddress
- privateAddress
- required:
- publicAddress
- publicPort
example:
publicAddress: 84.125.93.10
publicPort: 59765
SingleIpv4Addr:
description: A single IPv4 address with no subnet mask
type: string
format: ipv4
example: 84.125.93.10
Port:
description: TCP or UDP port number
type: integer
minimum: 0
maximum: 65535
DeviceIpv6Address:
description: |-
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).
type: string
format: ipv6
example: 2001:db8:85a3:8d3:1319:8a2e:370:7344
GeoReference:
description: |-
Specific Geographical reference. It can be defined in different ways, such as by a postal code or coverage zone specified by latitude and longitude coordinates.
type: object
properties:
type:
$ref: '#/components/schemas/GeoReferenceType'
required:
- type
discriminator:
propertyName: type
mapping:
COVERAGE_ZONE: '#/components/schemas/CoverageZone'
POSTAL_CODE: '#/components/schemas/PostalCode'
GeoReferenceType:
type: string
description: |-
Type of this geographical reference.
- `COVERAGE_ZONE`: It is specified by latitude and longitude coordinates. The coverage area is generated by one or more antennas closest to the specified coordinates, determining the device's connection to these antennas.
- `POSTAL_CODE`: A zip code or postal code that delimits a geographic area.
enum:
- COVERAGE_ZONE
- POSTAL_CODE
CoverageZone:
description: Coverage zone specified by latitude and longitude coordinates
allOf:
- $ref: '#/components/schemas/GeoReference'
- type: object
properties:
latitude:
$ref: '#/components/schemas/Latitude'
longitude:
$ref: '#/components/schemas/Longitude'
example:
latitude: 50.735851
longitude: 7.10066
required:
- latitude
- longitude
example:
type: COVERAGE_ZONE
latitude: 50.735851
longitude: 7.10066
Latitude:
description: Latitude component of a location
type: number
format: double
minimum: -90
maximum: 90
example: 50.735851
Longitude:
description: Longitude component of location
type: number
format: double
minimum: -180
maximum: 180
example: 7.10066
PostalCode:
description: Area associated to an administrative or geographical code
allOf:
- $ref: '#/components/schemas/GeoReference'
- type: object
properties:
postalCode:
type: string
description: Zip code or postal code.
required:
- postalCode
Score:
type: integer
description: |-
The value is a summary metric derived from analysis of the device's connections to antennas covering the requested area across all time slots.
The range of score values is between "0" and "100", where higher scores indicate a more frequent presence in the location.
minimum: 0
maximum: 100
example: 86
ErrorInfo:
type: object
description: Error information
required:
- status
- code
- message
properties:
status:
type: integer
description: HTTP response status code
code:
type: string
description: A human-readable code to describe the error
message:
type: string
description: A human-readable description of what the event represent
XCorrelator:
type: string
pattern: ^[a-zA-Z0-9-_:;.\/<>{}]{0,256}$
example: "b4333c46-49c0-4f62-80d7-f0ef930f1c46"
responses:
VerifyFrequentLocationBadRequest400:
description: |-
Bad Request.
In addition to regular scenario of `INVALID_ARGUMENT`, other scenarios may exist:
- Out of Range. Specific Syntax Exception used when a given field has a pre-defined range or a invalid filter criteria combination is requested ("code": "OUT_OF_RANGE","message": "Client specified an invalid range.")
- The postal code value does not exist or is invalid ("code": "MOST_FREQUENT_LOCATION.POSTAL_CODE_NOT_VALID","message": "Requested postal code value does not exist or is invalid.").
headers:
x-correlator:
$ref: '#/components/headers/x-correlator'
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/ErrorInfo"
- type: object
properties:
status:
enum:
- 400
code:
enum:
- INVALID_ARGUMENT
- OUT_OF_RANGE
- MOST_FREQUENT_LOCATION.POSTAL_CODE_NOT_VALID
examples:
GENERIC_400_INVALID_ARGUMENT:
description: Invalid Argument. Generic Syntax Exception
value:
status: 400
code: INVALID_ARGUMENT
message: Client specified an invalid argument, request body or query param.
GENERIC_400_OUT_OF_RANGE:
description: Out of Range. Specific Syntax Exception used when a given field has a pre-defined range or a invalid filter criteria combination is requested
value:
status: 400
code: OUT_OF_RANGE
message: Client specified an invalid range.
POSTAL_CODE_NOT_VALID:
description: The postal code value does not exist or is invalid
value:
status: 400
code: MOST_FREQUENT_LOCATION.POSTAL_CODE_NOT_VALID
message: Requested postal code value does not exist or is invalid.
Generic401:
description: Unauthorized
headers:
x-correlator:
$ref: "#/components/headers/x-correlator"
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/ErrorInfo"
- type: object
properties:
status:
enum:
- 401
code:
enum:
- UNAUTHENTICATED
examples:
GENERIC_401_UNAUTHENTICATED:
description: Request cannot be authenticated and a new authentication is required
value:
status: 401
code: UNAUTHENTICATED
message: Request not authenticated due to missing, invalid, or expired credentials. A new authentication is required.
VerifyFrequentLocationPermissionDenied403:
description: |-
Forbidden.
In addition to regular scenario of `PERMISSION_DENIED`, another scenarios may exist:
- Phone number cannot be deducted from access token context.("code": "INVALID_TOKEN_CONTEXT","message": "Phone number is not consistent with access token.")
headers:
x-correlator:
$ref: '#/components/headers/x-correlator'
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/ErrorInfo"
- type: object
properties:
status:
enum:
- 403
code:
enum:
- PERMISSION_DENIED
examples:
GENERIC_403_PERMISSION_DENIED:
description: Permission denied. OAuth2 token access does not have the required scope or when the user fails operational security
value:
status: 403
code: PERMISSION_DENIED
message: Client does not have sufficient permissions to perform this action.
VerifyFrequentLocationNotFound404:
description: |-
Not found.
In addition to regular scenario of `NOT_FOUND`, other scenarios may exist:
- Device identifier not found ("code": "IDENTIFIER_NOT_FOUND","message": "Device identifier not found.").
- There is not enough information to calculate the score ("code": "MOST_FREQUENT_LOCATION.INFORMATION_NOT_AVAILABLE","message": "Requested information is not available").
headers:
x-correlator:
$ref: '#/components/headers/x-correlator'
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/ErrorInfo"
- type: object
properties:
status:
enum:
- 404
code:
enum:
- NOT_FOUND
- IDENTIFIER_NOT_FOUND
- MOST_FREQUENT_LOCATION.INFORMATION_NOT_AVAILABLE
examples:
GENERIC_404_NOT_FOUND:
description: Resource is not found
value:
status: 404
code: NOT_FOUND
message: The specified resource is not found.
GENERIC_404_IDENTIFIER_NOT_FOUND:
description: The phone number is not associated with a CSP customer account
value:
status: 404
code: IDENTIFIER_NOT_FOUND
message: The phone number provided is not associated with a customer account
INFORMATION_NOT_AVAILABLE:
description: There is not enough information to calculate the score
value:
status: 404
code: MOST_FREQUENT_LOCATION.INFORMATION_NOT_AVAILABLE
message: Requested information is not available.
VerifyFrequentLocationUnprocessableEntity422:
description: |-
Unprocessable Content.
- Service is not available for the provided device ("code": "SERVICE_NOT_APPLICABLE","message": "The service is not available for the provided device.").
- None of the provided device identifiers are supported by the implementation ("code": "UNSUPPORTED_IDENTIFIER","message": "Supported device identifiers are: ...").
- The device identifier is not included in the request and the device information cannot be derived from the 3-legged access token ("code": "MISSING_IDENTIFIER","message": "The device cannot be identified.").
headers:
x-correlator:
$ref: '#/components/headers/x-correlator'
content:
application/json:
schema:
allOf:
- $ref: "#/components/schemas/ErrorInfo"
- type: object
properties:
status:
enum:
- 422
code:
enum:
- SERVICE_NOT_APPLICABLE
- MISSING_IDENTIFIER
- UNSUPPORTED_IDENTIFIER
- UNNECESSARY_IDENTIFIER
examples:
GENERIC_422_SERVICE_NOT_APPLICABLE:
description: Service not applicable for the provided identifier
value:
status: 422
code: SERVICE_NOT_APPLICABLE
message: The service is not available for the provided identifier.
GENERIC_422_MISSING_IDENTIFIER:
description: An identifier is not included in the request and the device or phone number identification cannot be derived from the 3-legged access token
value:
status: 422
code: MISSING_IDENTIFIER
message: The device cannot be identified.
GENERIC_422_UNSUPPORTED_IDENTIFIER:
description: None of the provided identifiers is supported by the implementation
value:
status: 422
code: UNSUPPORTED_IDENTIFIER
message: The identifier provided is not supported.
GENERIC_422_UNNECESSARY_IDENTIFIER:
description: An explicit identifier is provided when a device or phone number has already been identified from the access token
value:
status: 422
code: UNNECESSARY_IDENTIFIER
message: The device is already identified by the access token.
headers:
x-correlator:
description: Correlation id for the different services
schema:
$ref: "#/components/schemas/XCorrelator"
parameters:
x-correlator:
name: x-correlator
in: header
description: Correlation id for the different services
schema:
$ref: "#/components/schemas/XCorrelator"