Download OpenAPI specification:Download
Usage Engine offers several different APIs for performing various tasks using external systems.
The following error response codes are used in the system:
Error code | Explanation |
---|---|
400 |
Bad request |
401 |
Unauthorized |
404 |
Not found |
405 |
Method not allowed |
409 |
Conflict |
429 |
Too many requests |
500 |
An unexpected internal error occurred even though the request was valid |
503 |
Service unavailable |
With the authentication API you can create tokens for OAuth authentication. The API supports OAuth 2.0.
Use POST /oauth/token
to create a bearer access token enabling an OAuth client to authenticate itself in the Usage Engine REST API. You have to create an Application Access in Usage Engine to retrieve the client ID and client secret, see Application Access for detailed instructions.
Credentials used for authenticating the client to the authorization server.
audience required | string The intended recipients which should accept and process the token. Use the base URL for the environment you are accessing. |
client_id required | string The client ID generated when creating the Application Access in Usage Engine CE. |
client_secret required | string The client secret generated when creating the Application Access in Usage Engine CE. |
grant_type required | string The OAuth grant type that will be used to generate the token. The value of this parameter must be |
{- "client_id": "u4grtTy18E2DYANsv0G174aSxR3EeOiA",
- "client_secret": "U6qN9NTgis3MLeleRXtLgIxtRE-qhpZcPJ_5eoNtNQYcodiY9q0Abs3afgpbX3M6",
- "grant_type": "client_credentials"
}
{- "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6ImZUYU5saGpnclFERE0xYkdVZG1WeiJ9.eyJhY2NvdW50SWQiOiJhZDZmZWM5NS1lMDYzLTQ5MmItOTJjYy01MmJiNjJjMGU3NTAiLCJpc3MiOiJodHRwczovL2F1dGguZGlnaXRhbHJvdXRlLmlvLyIsInN1YiI6IjhtMUhUMHA2SkdMOVJjbzhWNEZjWGZ2Y2dHejcwcms4QGNsaWVudHMiLCJhdWQiOiJodHRwczovL2FwaS5kaWdpdGFscm91dGUuaW8vIiwiaWF0IjoxNzEyMTQ0OTQzLCJleHAiOjE3MTIxNDg1NDMsInNjb3BlIjoiY3JlYXRlOm1ldGVyX3R5cGVzIGNyZWF0ZTptZXRlcnMgZGVsZXRlOm1ldGVyX3R5cGVzIGRlbGV0ZTptZXRlcnMgcmVhZDptZXRlcl90eXBlcyByZWFkOm1ldGVycyB1cGRhdGU6bWV0ZXJfdHlwZXMiLCJndHkiOiJjbGllbnQtY3JlZGVudGlhbHMiLCJhenAiOiI4bTFIVDBwNkpHTDlSY284VjRGY1hmdmNnR3o3MHJrOCJ9.VS8Ti1zTK4b8qGRKXJg8b0-aMpNpTTL1_nwsPbCeM7CFlUYu45ZUQGWvUqC6XGK-Xl3j9k5Tkth8TtFbbXNEW4mEV0e1qQbDu_ZlvH-bH2nCNJhk-7mFriGYfTF0U-erqNiMsk4Tbrmm2Voy9CJ4_WyVrCjTLBqRBKb_bU4KHFJtgadlqwaTVNZUiI-sIV3Y2V_gid_4qPTO1Vr01ybID_F8uNII9goDqPJBRh6hmcKHqt65U5n2xzbmBcNqRPoXqxh1g9OaYEPDjojp2lHttqs2EkGG9KxzTFqhdX4lcrjfHGgzNk7LD7S7mGJTO0V-n57geptxM7gFGr-hAQ4Ikg",
- "expires_in": 3600,
- "scope": "create:meter_types create:meters delete:meter_types delete:meters read:meter_types read:meters update:meter_types",
- "token_type": "Bearer"
}
The meter type is a representation of the product or service you want to offer with a usage based billing model.
Use GET /meter-types
to retrieve a list of all meter types configured within your account.
limit | string Defines the number of meter types to be returned. A maximum of 100 items can be returned. |
skip | string Defines an offset for the meter types to be returned. If you set skip to 10, the first 10 meter types will be skipped in the returned list. |
sortOrder | string Determines the sort order of the returned list; ASC for ascending or DESC for descending. |
sortBy | string Determines the field in the meter type by which the returned list will be sorted. |
name | string Defines the name for which meter type should be returned. You may provide full or partial name. |
X-Account-Id | string |
X-Application-Id | string |
{- "meterTypes": [
- {
- "accountId": "4d6548c8-1793-498f-9306-9ec101cb9bf8",
- "activeFrom": "2023-07-26T09:00:15.690+00:00",
- "activeTo": "2024-11-22T00:00:00.000+00:00",
- "aggregation": {
- "type": "increment"
}, - "category": "API Counts",
- "createdAt": "2023-07-26T09:00:15.690+00:00",
- "description": "Meter definition to count the number of API requests per customer",
- "externalRef": "878752b4-4ddf",
- "id": "string",
- "name": "Usage based API counter",
- "numberOfMeters": 0,
- "resetSchedule": {
- "day": "L",
- "hour": "0",
- "minute": "0",
- "month": "*",
- "weekday": "*"
}, - "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-26T09:00:15.690+00:00"
}
]
}
Use POST /meter-types
to create a new meter type for your account.
X-Account-Id | string |
X-Application-Id | string |
activeFrom | string Determines from which date and time the meter type will be active, with the time based on |
activeTo | string Determines to which date and time the meter type will be active, with the time based on |
required | object Choose the aggregation type for aggregating data within a defined interval.
The aggregation type cannot be updated. |
category | string <= 50 characters Specify the category to which the meter type should be assigned. By using the category when configuring the Meter processor, meter types can be added, edited, or deleted without necessarily affecting the Meter processor configuration. If no category is specified, the meter type will be assigned to the DEFAULT category. |
description | string <= 200 characters You can add a more detailed description for the meter type with this parameter. |
externalRef | string <= 100 characters If the meter type is registered as a product in an external system, you can add the external ID to reference it. |
name required | string <= 80 characters ^[\w\s().-]+$ Name of the meter type. Only alphanumeric characters, spaces, and the following special characters are supported |
required | object Determines how often the usage counting data should be reset and sent to downstream systems defined in crontab format. |
timezone required | string The canonical timezone that should be applied for reset time. See IANA time zones for the complete available list. |
unit required | string <= 50 characters State the unit which the meters should be measuring, such as MB, minutes, etc. |
{- "activeFrom": "2023-07-26T09:00:15.690+00:00",
- "activeTo": "2024-11-22T00:00:00.000+00:00",
- "aggregation": {
- "type": "increment"
}, - "category": "API Counts",
- "description": "Meter definition to count the number of API requests per customer",
- "externalRef": "878752b4-4ddf",
- "name": "Usage based API counter",
- "resetSchedule": {
- "day": "L",
- "hour": "0",
- "minute": "0",
- "month": "*",
- "weekday": "*"
}, - "timezone": "Etc/UTC",
- "unit": "requests"
}
{- "accountId": "4d6548c8-1793-498f-9306-9ec101cb9bf8",
- "activeFrom": "2023-07-26T09:00:15.690+00:00",
- "activeTo": "2024-11-22T00:00:00.000+00:00",
- "aggregation": {
- "type": "increment"
}, - "category": "API Counts",
- "createdAt": "2023-07-26T09:00:15.690+00:00",
- "description": "Meter definition to count the number of API requests per customer",
- "externalRef": "878752b4-4ddf",
- "id": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "name": "Usage based API counter",
- "numberOfMeters": 0,
- "resetSchedule": {
- "day": "L",
- "hour": "0",
- "minute": "0",
- "month": "*",
- "weekday": "*"
}, - "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-26T09:00:15.690+00:00"
}
Use DELETE /meter-types/{id}
to delete a specified meter type. It is not allowed to delete meter type with associated meters. You must delete associated meters first to delete meter type.
id required | string The unique ID of meter type. |
X-Account-Id | string |
X-Application-Id | string |
{- "deletedCount": 1
}
Use GET /meter-types/{id}
to retrieve information about a specified meter type.
id required | string The unique ID of meter type. |
X-Account-Id | string |
X-Application-Id | string |
{- "accountId": "4d6548c8-1793-498f-9306-9ec101cb9bf8",
- "activeFrom": "2023-07-26T09:00:15.690+00:00",
- "activeTo": "2024-11-22T00:00:00.000+00:00",
- "aggregation": {
- "type": "increment"
}, - "category": "API Counts",
- "createdAt": "2023-07-26T09:00:15.690+00:00",
- "description": "Meter definition to count the number of API requests per customer",
- "externalRef": "878752b4-4ddf",
- "id": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "name": "Usage based API counter",
- "numberOfMeters": 0,
- "resetSchedule": {
- "day": "L",
- "hour": "0",
- "minute": "0",
- "month": "*",
- "weekday": "*"
}, - "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-26T09:00:15.690+00:00"
}
Use PATCH /meter-types/{id}
to update a specified meter type.
id required | string The unique ID of meter type. |
X-Account-Id | string |
X-Application-Id | string |
string or null The new active from date you want the meter type to use. | |
string or null The new active to date you want the meter type to use. | |
string or null <= 50 characters The new category you want the meter type to use. You may need to revise the configuration in the Meter processor following the category update. | |
description | string <= 200 characters The updated description you want the meter type to have. |
string or null <= 100 characters The new external ID you want to associate with the meter type. | |
name | string <= 80 characters ^[\w\s().-]+$ The new name you want the meter type to have. Only alphanumeric characters, spaces, and the following special characters are supported |
object The new reset schedule you want the meter type to use. The new reset schedule takes effect after the current period has ended and meters have been reset. | |
timezone | string The new canonical timezone you want the meter type to use. See IANA time zones for the complete available list. |
unit | string <= 50 characters State the unit which the meters should be measuring, such as MB, minutes, etc. |
{- "activeFrom": "2023-07-26T09:00:15.690+00:00",
- "activeTo": "2024-11-22T00:00:00.000+00:00",
- "category": "API Counts",
- "description": "Meter definition to count the number of API requests per customer",
- "externalRef": "878752b4-4ddf",
- "name": "Usage based API counter",
- "resetSchedule": {
- "day": "L",
- "hour": "0",
- "minute": "0",
- "month": "*",
- "weekday": "*"
}, - "timezone": "Etc/UTC",
- "unit": "requests"
}
{- "accountId": "4d6548c8-1793-498f-9306-9ec101cb9bf8",
- "activeFrom": "2023-07-26T09:00:15.690+00:00",
- "activeTo": "2024-11-22T00:00:00.000+00:00",
- "aggregation": {
- "type": "increment"
}, - "category": "API Counts",
- "createdAt": "2023-07-26T09:00:15.690+00:00",
- "description": "Meter definition to count the number of API requests per customer",
- "externalRef": "878752b4-4ddf",
- "id": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "name": "Usage based API counter",
- "numberOfMeters": 0,
- "resetSchedule": {
- "day": "L",
- "hour": "0",
- "minute": "0",
- "month": "*",
- "weekday": "*"
}, - "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-26T09:00:15.690+00:00"
}
A meter is a customer-specific counter. The meter defines which meter types the customer’s usage should be counted for. Unique meters should be created for all customers.
Use GET /meters
to retrieve a list of available meters configured in the system.
limit | string Defines the number of meters to be returned. A maximum of 100 items can be returned. |
skip | string Defines an offset for the meters to be returned. If you set skip to 10, the first 10 meters will be skipped in the returned list. |
meterKey | string Defines the meter key for which meters should be returned. |
meterTypeId | string Defines the meter type ID for which meters should be returned. |
userId | string Defines the user ID for which meters should be returned. |
X-Account-Id | string |
X-Application-Id | string |
{- "meters": [
- {
- "carryFirst": {
- "country": "Norway"
}, - "carryLast": {
- "timestamp": "2023-07-05T22:01:04.431Z"
}, - "createdAt": "2023-07-01T00:00:00.000Z",
- "deleteOnReset": false,
- "groups": [
- {
- "fields": {
- "API name": "createUser"
}, - "key": "API name:createUser",
- "value": 10
}, - {
- "fields": {
- "API name": "updateCounter"
}, - "key": "API name:updateCounter",
- "value": 15
}
], - "id": "8a76066d-ff29-417c-a18e-abde22e44310",
- "meterKey": "a1f8797b-c827-4483-b6cf-6d3d3baa18a7",
- "meterMetaData": {
- "firstEvent": "2023-07-01T13:37:11.111Z",
- "lastEvent": "2023-07-05T22:01:04.431Z"
}, - "meterTypeId": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "meterTypeName": "Usage based API counter",
- "periodEnd": "2023-08-01T00:00:00.000Z",
- "periodStart": "2023-07-01T00:00:00.000Z",
- "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-05T22:01:04.431Z",
- "userId": "user0@example.com",
- "value": 25
}
]
}
Use POST /meters
to create a new meter.
X-Account-Id | string |
X-Application-Id | string |
meterKey required | string <= 36 characters The meter key for the Meter processor counting the usage for the meter. |
meterTypeId required | string <= 36 characters The unique ID of the meter type that the meter should count usage for. |
userId required | string <= 320 characters Unique ID of the user the meter belongs to, for example an email address, user name or MSISDN number. |
{- "meterKey": "a1f8797b-c827-4483-b6cf-6d3d3baa18a7",
- "meterTypeId": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "userId": "user0@example.com"
}
{- "carryFirst": {
- "country": "Norway"
}, - "carryLast": {
- "timestamp": "2023-07-05T22:01:04.431Z"
}, - "createdAt": "2023-07-01T00:00:00.000Z",
- "deleteOnReset": false,
- "groups": [
- {
- "fields": {
- "API name": "createUser"
}, - "key": "API name:createUser",
- "value": 10
}, - {
- "fields": {
- "API name": "updateCounter"
}, - "key": "API name:updateCounter",
- "value": 15
}
], - "id": "8a76066d-ff29-417c-a18e-abde22e44310",
- "meterKey": "a1f8797b-c827-4483-b6cf-6d3d3baa18a7",
- "meterMetaData": {
- "firstEvent": "2023-07-01T13:37:11.111Z",
- "lastEvent": "2023-07-05T22:01:04.431Z"
}, - "meterTypeId": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "meterTypeName": "Usage based API counter",
- "periodEnd": "2023-08-01T00:00:00.000Z",
- "periodStart": "2023-07-01T00:00:00.000Z",
- "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-05T22:01:04.431Z",
- "userId": "user0@example.com",
- "value": 25
}
Use GET /meters/{id}
to retrieve information about a specified meter.
id required | string The unique ID of meter. |
X-Account-Id | string |
X-Application-Id | string |
{- "carryFirst": {
- "country": "Norway"
}, - "carryLast": {
- "timestamp": "2023-07-05T22:01:04.431Z"
}, - "createdAt": "2023-07-01T00:00:00.000Z",
- "deleteOnReset": false,
- "groups": [
- {
- "fields": {
- "API name": "createUser"
}, - "key": "API name:createUser",
- "value": 10
}, - {
- "fields": {
- "API name": "updateCounter"
}, - "key": "API name:updateCounter",
- "value": 15
}
], - "id": "8a76066d-ff29-417c-a18e-abde22e44310",
- "meterKey": "a1f8797b-c827-4483-b6cf-6d3d3baa18a7",
- "meterMetaData": {
- "firstEvent": "2023-07-01T13:37:11.111Z",
- "lastEvent": "2023-07-05T22:01:04.431Z"
}, - "meterTypeId": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "meterTypeName": "Usage based API counter",
- "periodEnd": "2023-08-01T00:00:00.000Z",
- "periodStart": "2023-07-01T00:00:00.000Z",
- "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-05T22:01:04.431Z",
- "userId": "user0@example.com",
- "value": 25
}
Use PATCH /meters/{id}
to update a specified meter.
id required | string The unique ID of meter. |
X-Account-Id | string |
X-Application-Id | string |
deleteOnReset | boolean Determine whether the meter should be deleted after the next reset. |
{- "deleteOnReset": true
}
{- "carryFirst": {
- "country": "Norway"
}, - "carryLast": {
- "timestamp": "2023-07-05T22:01:04.431Z"
}, - "createdAt": "2023-07-01T00:00:00.000Z",
- "deleteOnReset": false,
- "groups": [
- {
- "fields": {
- "API name": "createUser"
}, - "key": "API name:createUser",
- "value": 10
}, - {
- "fields": {
- "API name": "updateCounter"
}, - "key": "API name:updateCounter",
- "value": 15
}
], - "id": "8a76066d-ff29-417c-a18e-abde22e44310",
- "meterKey": "a1f8797b-c827-4483-b6cf-6d3d3baa18a7",
- "meterMetaData": {
- "firstEvent": "2023-07-01T13:37:11.111Z",
- "lastEvent": "2023-07-05T22:01:04.431Z"
}, - "meterTypeId": "645ed240-02b5-400c-9a3c-21857e8f2ac4",
- "meterTypeName": "Usage based API counter",
- "periodEnd": "2023-08-01T00:00:00.000Z",
- "periodStart": "2023-07-01T00:00:00.000Z",
- "timezone": "Etc/UTC",
- "unit": "requests",
- "updatedAt": "2023-07-05T22:01:04.431Z",
- "userId": "user0@example.com",
- "value": 25
}