All Collections
Developer Documentation
Restrict API access to specific Device Groups
Restrict API access to specific Device Groups
Team Celona avatar
Written by Team Celona
Updated over a week ago

Step 1. Log in to Orchestrator as Admin user

Step 2. Navigate to Admin settings -> API Keys -> Generate API key -> Copy API Key only

Step 3. Navigate to Admin settings -> Account Info to get Customer Account ID

Step 4. Use the API key and Account ID (from Step 2 and Step 3 respectively) and create a new user with custom role: Restricted Observer.

Sample API request:

curl --location 'https://cso.celona.io/v1/api/segw/users' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-api-key: ' \ ----------> API key from Step2
--data-raw '{
"first_name": "John",
"last_name": "John",
"role_id": 10, ------------------------> Use value 10
"role_name": "Restricted observer", ---> Use value Restricted observer
"login": "john@test.com",
"email": "john@test.com",
"customer_id": <Account ID from Step3 (no quotes needed)>,
"mobile": "",
"tags": [
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "critical_grp" -->Name of Device group
}
]
}'

Sample response:

{
"code": 200,
"data": 1006004696, ----------> User ID of the created user
"error": "",
"success": true
}

Step 5. Using API key from Step2, to generate a new API key for restricted access to specific device group.

Sample request:

curl --location 'https://cso.celona.io/v1/api/segw/apikeys?customer_id= <Account ID from Step 3 (no quotes needed)>\
--header 'x-api-key: <API key from Step 2>' \
--header 'Content-Type: application/json' \
--data '{
"user_id": <User ID from response of Step 4>
}'

Sample response:

{
"code": 200,
"data": {
"api_key": "$2a$04$F.dFAI2", ---> API key for restricted access
"api_prefix": "baf075a39fc14ba8",
"created_on": "2023-03-29 16:18:07",
"expires_on": "2023-04-28 16:18:07",
"id": 1006004566,
"status": 1,
"status_name": "Active",
"updated_on": "2023-03-29 16:18:07",
"user_id": 1006004696
},
"error": "",
"success": true
}

Step 6. API details to fetch events of all devices belonging to the specific device group (mentioned in Step 4):

curl --location 'https://cso.celona.io/v1/api/stats/telemetry/events/device?startTime=1680020136132&endTime=1680106536132&customerId=<Account ID from Step3 (no quotes needed)> \
--header 'x-api-key: < Restricted Access API key from Step 5 response >

Note:

  • This step will be performed by User, with restricted API access, after Customer Admin user shares the Restricted Access API Key from Step 5 with the User.

  • startTime and endTime values are epoch time in milliseconds. Above timestamps show case events for 24 hours. These values can be changed according to the required duration

Sample response :

[
{
"groupType": "Attach",
"startTime": "2023-03-29T16:13:44.521Z",
"endTime": "2023-03-29T16:13:44.659Z",
"sourceAP": "2006CW5000009",
"targetAP": "2006CW5000009",
"status": "Success",
"imsi": "315010999961012",
"events": [
{
"eventTypeDesc": "Initial Device Message",
"eventType": "INITIALUEMESSAGE",
"timestamp": "2023-03-29T16:13:44.521Z"
},
{
"eventTypeDesc": "Initial Context Setup Request",
"eventType": "INITIALCONTEXTSETUPREQUEST",
"timestamp": "2023-03-29T16:13:44.523Z"
},
{
"eventTypeDesc": "Attach Accept",
"eventType": "ATTACHACCEPT",
"timestamp": "2023-03-29T16:13:44.524Z"
},
{
"eventTypeDesc": "Initial Context Setup Response",
"eventType": "INITIALCONTEXTSETUPRESPONSE",
"timestamp": "2023-03-29T16:13:44.659Z"
}
]
},
{
"groupType": "Detach",
"startTime": "2023-03-29T16:14:24.528Z",
"endTime": "2023-03-29T16:14:24.533Z",
"sourceAP": "2006CW5000009",
"targetAP": "2006CW5000009",
"status": "Success",
"imsi": "315010999961013",
"events": [
{
"eventTypeDesc": "Device Context Release Request",
"eventType": "UECONTEXTRELEASEREQUEST",
"timestamp": "2023-03-29T16:14:24.528Z"
},
{
"eventTypeDesc": "Device Context Release Command",
"eventType": "UECONTEXTRELEASECOMMAND",
"timestamp": "2023-03-29T16:14:24.532Z"
},
{
"eventTypeDesc": "Device Context Release Complete",
"eventType": "UECONTEXTRELEASECOMPLETE",
"timestamp": "2023-03-29T16:14:24.533Z"
}
]
}
]

Step 7. API details to fetch the events of a specific device belonging to device group (mentioned in Step 4) :

 curl --location 'https://cso.celona.io/v1/api/stats/telemetry/events/device?imsi=<IMSI of the device>&startTime=1680020136132&endTime=1680106536132&customerId=<Account ID from Step3 (no quotes needed)> \
--header 'x-api-key: < Restricted Access API key from Step 5 response >

Note:

  • This step will be performed by User, with restricted API access, after Customer Admin user shares the Restricted Access API Key from Step 5 with the User.

  • startTime and endTime values are epoch time in milliseconds. Above timestamps show case events for 24 hours. These values can be changed according to the required duration.

Sample response :

[
{
"groupType": "Attach",
"startTime": "2023-03-29T16:13:44.521Z",
"endTime": "2023-03-29T16:13:44.659Z",
"sourceAP": "2006CW5000009",
"targetAP": "2006CW5000009",
"status": "Success",
"imsi": "315010999961012",
"events": [
{
"eventTypeDesc": "Initial Device Message",
"eventType": "INITIALUEMESSAGE",
"timestamp": "2023-03-29T16:13:44.521Z"
},
{
"eventTypeDesc": "Initial Context Setup Request",
"eventType": "INITIALCONTEXTSETUPREQUEST",
"timestamp": "2023-03-29T16:13:44.523Z"
},
{
"eventTypeDesc": "Attach Accept",
"eventType": "ATTACHACCEPT",
"timestamp": "2023-03-29T16:13:44.524Z"
},
{
"eventTypeDesc": "Initial Context Setup Response",
"eventType": "INITIALCONTEXTSETUPRESPONSE",
"timestamp": "2023-03-29T16:13:44.659Z"
}
]
},
{
"groupType": "Detach",
"startTime": "2023-03-29T16:14:24.528Z",
"endTime": "2023-03-29T16:14:24.533Z",
"sourceAP": "2006CW5000009",
"targetAP": "2006CW5000009",
"status": "Success",
"imsi": "315010999961012",
"events": [
{
"eventTypeDesc": "Device Context Release Request",
"eventType": "UECONTEXTRELEASEREQUEST",
"timestamp": "2023-03-29T16:14:24.528Z"
},
{
"eventTypeDesc": "Device Context Release Command",
"eventType": "UECONTEXTRELEASECOMMAND",
"timestamp": "2023-03-29T16:14:24.532Z"
},
{
"eventTypeDesc": "Device Context Release Complete",
"eventType": "UECONTEXTRELEASECOMPLETE",
"timestamp": "2023-03-29T16:14:24.533Z"
}
]
}
]

Details (API key suspend/expiry, get device details and add multiple tags / update tags for the given user):

1. API to suspend the API key (Use API key from Step 2):

 curl --location --request PUT 'https://cso.celona.io/v1/api/segw/apikeys/<User ID from response of Step 4>
/status/2?api_prefix=< api_prefix from the response of step 5>
&customer_id==<Account ID from Step3 (no quotes needed)> '

2. API to activate a suspended API key (Use API key from Step 2):

curl --location --request PUT 'https://cso.celona.io/v1/api/segw/apikeys/<User ID from response of Step 4>
/status/1?api_prefix=< api_prefix from the response of step 5>
&customer_id==<Account ID from Step3 (no quotes needed)> '

3. API to expire the API key (Use API key from Step 2):

curl --location --request PUT 'https://cso.celona.io/v1/api/segw/apikeys/<User ID from response of Step 4>
/status/4?api_prefix=<api_prefix from the response of step 5>
&customer_id==<Account ID from Step3 (no quotes needed)> '

4. Create a user with custom role: Restricted Observer with multiple tags, .i.e device groups:

curl --location 'https://cso.celona.io/v1/api/segw/users' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'x-api-key: ' \ ----------> API key from Step2
--data-raw '{
"first_name": "ro",
"last_name": "test29",
"role_id": 10, ------------------------> Use value 10
"role_name": "Restricted observer", ---> Use value Restricted observer
"login": "ro_test29@dispostable.com",
"email": "ro_test29@dispostable.com",
"customer_id": <Account ID from Step3 (no quotes needed)>
"mobile": "",
"tags": [
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "bot1" ----------> Name of Device group

},
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "bot2"
}

]
}'

Sample response:

{ 
"code": 200,
"data": 1006004696, ----------> User ID of the created user
"error": "",
"success": true
}

5. Get details of the devices:

curl --location --request GET 'https://cso.celona.io /v1/api/cfgm/restricted/devices?customer_id= =<Account ID from Step3 (no quotes needed)>' \
--header 'x-api-key: < Restricted Access API key from Step 5 response >'

Sample Response :

{
"code": 200,
"data": [
{
"activated_pse_clusters": [
{
"pse_cluster_id": "1000000097-0-1000000152-594716049",
"pse_cluster_name": "blrexprsnode"
}
],
"config_status": 3,
"config_status_name": "Activated",
"created_on": "2023-05-09 03:19:17",
"customer_id": 1000000097,
"description":"iPhone-US", -----> Device Description
"device_connected": 0,
"device_group_id": 1006002915,
"device_group_name": "test6",
"euiccid": null,
"first_used_on": "2023-05-09 03:19:17",
"iccid": "89105212033100000369",
"id": 1006002195,
"imei": null,
"imsi": "315010999900369",
"ip_address": null,
"mac_address": "B4:15:7E:90:03:69",
"op_status": 10,
"op_status_name": "Offline",
"pse_cluster_id": "1000000097-0-1000000152-594716049",
"pse_cluster_name": "blrexprsnode",
"sim_status_name": "Activated",
"sim_type": 1,
"static_ip_address": "",
"status": 3,
"total_count": 2,
"updated_on": "2023-05-18 10:06:58",
"uptime": null
},
{
"activated_pse_clusters": [
{
"pse_cluster_id": "1000000097-0-1000000152-594716049",
"pse_cluster_name": "blrexprsnode"
}
],
"config_status": 3,
"config_status_name": "Activated",
"created_on": "2023-05-09 07:05:31",
"customer_id": 1000000097,
"description": null,
"device_connected": 0,
"device_group_id": 1006002913,
"device_group_name": "test4",
"euiccid": null,
"first_used_on": "2023-05-09 07:05:31",
"iccid": "89105212033100003497",
"id": 1006002200,
"imei": null,
"imsi": "315010999903497",
"ip_address": null,
"mac_address": "B4:15:7E:90:34:97",
"op_status": 10,
"op_status_name": "Offline",
"pse_cluster_id": "1000000097-0-1000000152-594716049",
"pse_cluster_name": "blrexprsnode",
"sim_status_name": "Activated",
"sim_type": 1,
"static_ip_address": "",
"status": 3,
"total_count": 2,
"updated_on": "2023-05-18 10:06:36",
"uptime": null
}
],
"error": "",
"success": true
}

6. Update the restricted user to add / delete tags (Device groups):

curl --location --request PUT 'https://cso.celona.io/v1/api/segw/users' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header ''x-api-key: ' \ ----------> API key from Step2
--data-raw '{
"customer_id": <Account ID from Step3 (no quotes needed)>,
"email": "<E-mail ID of Symbotic user> ",
"first_name": "<First name of Symbotic user",
"id": 1006005886, ----------> User ID of the Symbotic user
"last_name": ""<First name of Symbotic user >",
"login": " <E-mail ID of Symbotic user> ",
"role_id": 10, ----------> Use same value
"role_name": "Restricted observer", ----------> Use same value
"add_tags": [
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "BOT3"
},
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "BOT4"
}
],
"delete_tags": [
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "BOT5"
},
{
"tag_category": "DeviceGroupNameEqual",
"tag_value": "BOT6"
}
]
}'

Sample response :

{
"code": 200,
"data": true,
"error": "",
"success": true
}

Did this answer your question?