Skip to content

UniFi Identity

The APIs here are designed for the UniFi Identity app.

Send UniFi Identity Invitations

This API enables you to send invitations and invite users to join UniFi Identity.

Request URL: /api/v1/developer/users/identity/invitations
Permission Key: edit:user
Method: POST
UniFi Access Requirement: 1.24.6 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Body

ParameterRequiredTypeDescription
Array[Object].user_idTStringIdentity ID of the user.
Array[Object].emailFStringEmail of the user. If filled in, it will update the user's existing email address.

Request Sample: Shell/cURL

bash
curl -XPOST '{host}/api/v1/developer/users/identity/invitations' \
-H 'Authorization: Bearer wHFmHR*****kD6wHg' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
--data-raw '[
    {
        "user_id": "e0051e08-c4d5-43db-87c8-a9b19cb66513",
        "email": "example@*.com"
    }
]' \
--insecure

Response Body

Success:

json
{
  "code": "SUCCESS",
  "data": [],
  "msg": "success"
}

If there is a failure to send an email:

json
{
  "code": "SUCCESS",
  "data": [
    {
      "error_code": "",
      "error_msg": "invalid email",
      "user_email": "example@*.com",
      "user_id": "e0051e08-c4d5-43db-87c8-a9b19cb66513"
    }
  ],
  "msg": "success"
}

Fetch Available Resources

This API enables you to fetch the available UniFi Identity resources.

Request URL: /api/v1/developer/users/identity/assignments
Permission Key: view:user
Method: GET
UniFi Access Requirement: 1.24.6 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Query Parameters

ParameterRequiredTypeDescriptionExample
resource_typeFStringDisplay the type of resources; show all when left blank. enum resource_type {evstation,vpn,wifi}resource_type=evstation,wifi,vpn

Response Body

ParameterRequiredTypeDescription
data. [resource_type]TStringType of the resources. enum resource_type {evstation, vpn, wifi, camera}
idTStringIdentity ID of the resources.
nameTStringName of the resources.
deletedTBooleanIndicate whether the resource is disabled.

Request Sample: Shell/cURL

bash
curl '{host}/api/v1/developer/users/identity/assignments?resource_type=evstation,wifi,vpn' \
-H 'Authorization: Bearer wHFmHR*****kD6wHg' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
--insecure

Response Sample

json
{
  "code": "SUCCESS",
  "data": {
    "evstation": [],
    "vpn": [
      {
        "deleted": false,
        "id": "65cff9a9c188cb71cfac8e9d",
        "metadata": null,
        "name": "UDM Pro",
        "short_name": ""
      }
    ],
    "wifi": [
      {
        "deleted": false,
        "id": "65cff9a8c188cb71cfac8e9a",
        "metadata": null,
        "name": "UniFi Identity",
        "short_name": ""
      }
    ]
  },
  "msg": "success"
}

Assign Resources to Users

This API enables you to assign UniFi Identity resources to users.

Request URL: /api/v1/developer/users/:id/identity/assignments
Permission Key: edit:user
Method: POST
UniFi Access Requirement: 1.24.6 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Path

ParameterRequiredTypeDescriptionHow to Get It?
idTStringIdentity ID of the user.Get it from the API /api/v1/developer/users

Request Body

ParameterRequiredTypeDescriptionHow to Get It?
resource_typeTStringenum resource_type {ev(station,vpn,wifi}Get it from the API 10.2
resource_idsTArray<String]Identity ID of the resources.Get it from the API 10.2

Request Sample: Shell/cURL

bash
curl -XPOST '{host}/api/v1/developer/users/b602879b-b857-400b-970b-336d4cb881ad/identity/assignments'  
-H 'Authorization: Bearer wHFmHR*****kD6wHg'  
-H 'accept: application/json'  
-H 'content-type: application/json'  
--data '{
    "resource_type": "wifi",  
    "resource_ids": [  
        "65cff9a8c188cb71cfac8e9a"  
    ]  
}  
--insecure

Response Sample

json
{
  "code": "SUCCESS",
  "data": null,
  "msg": "success"
}

Fetch Resources Assigned to Users

This API enables you to fetch the UniFi Identity resources assigned to users.

Request URL: /api/v1/developer/users/:id/identity/assignments
Permission Key: view:user

Method: GET
UniFi Access Requirement: 1.24.6 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Path

ParameterRequiredTypeDescriptionHow to Get It?
idTStringIdentity ID of the user.Get it from the API /api/v1/developer/users

Response Body

ParameterRequiredTypeDescription
data. [resource_type]TArray[Object]Type of the resources. enum resource_type {evstation, vpn,wifi,camera}
idTStringIdentity ID of the resources.
nameTStringName of the resources.
deletedTBooleanIndicate whether a resource is disabled.

Request Sample: Shell/cURL

bash
curl -XGET '{host}'/api/v1/developer/users/b602879b-b857-400b-970b-336d4cb881ad/identity/assignments'  
-H 'Authorization: Bearer wHFmHR*****kD6wHg'  
-H 'accept: application/json'  
-H 'content-type: application/json'  
--insecure

Response Sample

json
{
    "code": "SUCCESS",
    "data": {
        "ev_station": [],
        "vpn": [
            {
                "deleted": false,
                "id": "65dff9a9c188cb71cfac8e9d",
                "metadata": {
                    "has_ip": true
                },
                "name": "UDM Pro",
                "short_name": ""
            }
        ],
        "wifi": [
            {
                "deleted": false,
                "id": "65dff9a8c188cb71cfac8e9a",
                "metadata": null,
                "name": "UniFi Identity",
                "short_name": ""
            }
        ]
    },
    "msg": "success"
}

Assign Resources to User Groups

This API enables you to assign UniFi Identity resources to user groups.

Request URL: /api/v1/developer/user_groups/:id/identity/assignments
Permission Key: edit:user
Method: POST
UniFi Access Requirement: 2.2.0 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Path

ParameterRequiredTypeDescriptionHow to Get It?
idTStringIdentity ID of the user group.Get it from the API /api/v1/developer/user_groups

Request Body

ParameterRequiredTypeDescriptionHow to Get It?
resource_typeTStringenum resource_type {ev_station,vpn,wifi}Get it from the API 10.2
resource_idsTArray[String]Identity ID of the resources.Get it from the API 10.2

Request Sample: Shell/cURL

bash
curl -XPOST '{{host}}/api/v1/developer/user_groups/7476c839-8e10-472e-894f-c5b8254c35b5/identity/assignments'
    -H 'Authorization: Bearer wHFmHR******kD6wHg'
    -H 'accept: application/json'
    -H 'content-type: application/json'
    --data '{
        "resource_type": "wifi",
        "resource_ids": [
            "65dff9a8c188cb71cfac8e9a"
        ]
    }'
    --insecure

Response Sample

json
{
  "code": "SUCCESS",
  "data": null,
  "msg": "success"
}

Fetch the Resources Assigned to User Groups

This API enables you to fetch the UniFi Identity resources assigned to user groups.

Request URL: /api/v1/developer/user_groups/:id/identity/assignments
Permission Key: view:user
Method: GET
UniFi Access Requirement: 2.2.0 or later

Request Header

ParameterRequiredTypeDescription
AuthorizationTStringToken required for authentication and access control.

Request Path

ParameterRequiredTypeDescriptionHow to Get It?
idTStringIdentity ID of the user group.Get it from the API /api/v1/developer/user_groups

Response Body

ParameterRequiredTypeDescription
data.[resource_type]TArray[Object]Type of the resources. enum resource_type {ev_station,vpn,wifi,camera}
idTStringIdentity ID of the resources.
nameTStringName of the resources.
deletedTBooleanIndicate whether a resource is disabled.

Request Sample: Shell/cURL

bash
curl -XGET '{{host}}/api/v1/developer/user_groups/7476c839-8e10-472e-894f-c5b8254c35b5/identity/assignments'
    -H 'Authorization: Bearer wHFmHR******kD6wHg'
    -H 'accept: application/json'
    -H 'content-type: application/json'
    --insecure

Response Sample

json
{
    "code": "SUCCESS",
    "data": {
        "ev_station": [],
        "vpn": [
            {
                "deleted": false,
                "id": "65dff9a9c188cb71cfac8e9d",
                "metadata": {
                    "has_ip": true
                },
                "name": "UDM Pro",
                "short_name": ""
            }
        ],
        "wifi": [
            {
                "deleted": false,
                "id": "65dff9a8c188cb71cfac8e9a",
                "metadata": null,
                "name": "UniFi Identity",
                "short_name": ""
            }
        ]
    },
    "msg": "success"
}