Skip to content

Overview

This section provides an introduction to essential concepts related to working with APIs, including API tokens, HTTP status codes, success and error codes, HTTP verbs, and API hosts.

API Token

To authenticate API requests with UniFi Access, you need to utilize API tokens associated with your account. If a request includes a deleted or expired token, the service will return an authentication error. The Authorization Token is obtained from UniFi Portal.

HTTP Status Code Reference

200OKEverything worked as expected.
400Bad RequestThe request is unacceptable, often due to missing required parameters.
401UnauthorizedThe request lacks a valid API token for authentication.
402Request FailedThe request contains valid parameters, but failed for some reason.
403ForbiddenThe API token used does not have the necessary permissions to perform the request.
429Too Many RequestsToo many requests were sent to the API in a short amount of time.
500, 502, 503, 504Server ErrorsSomething went wrong on UniFi Access's end during request processing.

Success Code

json
{
  "code": "SUCCESS",
  "msg": "success"
}
CodeMessage
SUCCESSSuccess

Error Code

json
{
  "code": "CODE_PARAMS_INVALID",
  "msg": "Invalid parameters."
}
CodeMessage
CODE_PARAMS_INVALIDThe provided parameters are invalid.
CODE_SYSTEM_ERRORAn error occurred on the server's end.
CODE_RESOURCE_NOT_FOUNDThe requested resource was not found.
CODE_OPERATION_FORBIDDENThe requested operation is not allowed.
CODE_AUTH_FAILEDAuthentication failed.
CODE_ACCESS_TOKEN_INVALIDThe provided access token is invalid.
CODE_UNAUTHORIZEDYou are not allowed to perform this action.
CODE_NOT_EXISTSThe requested item does not exist.
CODE_USER_EMAIL_ERRORThe provided email format is invalid.
CODE_USER_ACCOUNT_NOT_EXISTThe requested user account does not exist.
CODE_USER_WORKER_NOT_EXISTSThe requested user does not exist.
CODE_USER_NAME_DUPLICATEDThe provided name already exists.
CODE_USER_CSV_IMPORT_INCOMPLETE_PROPPlease provide both first name and last name.
CODE_ACCESS_POLICY_USER_TIMEZONE_NOT_FOUNDThe requested workday schedule could not be found.
CODE_ACCESS_POLICY_HOLIDAY_TIMEZONE_NOT_FOUNDThe requested holiday schedule could not be found.
CODE_ACCESS_POLICY_HOLIDAY_GROUP_NOT_FOUNDThe requested holiday group could not be found.
CODE_ACCESS_POLICY_HOLIDAY_NOT_FOUNDThe requested holiday could not be found.
CODE_ACCESS_POLICY_SCHEDULE_NOT_FOUNDThe requested schedule could not be found.
CODE_ACCESS_POLICY_HOLIDAY_NAME_EXISTThe provided holiday name already exists.
CODE_ACCESS_POLICY_HOLIDAY_GROUP_NAME_EXISTThe provided holiday group name already exists.
CODE_ACCESS_POLICY_SCHEDULE_NAME_EXISTThe provided schedule name already exists.
CODE_ACCESS_POLICY_SCHEDULE_CAN_NOT_DELETEThe schedule could not be deleted.
CODE_ACCESS_POLICY_HOLIDAY_GROUP_CAN_NOT_DELETEThe holiday group could not be deleted.
CODE_CREDS_NFC_HAS_BIND_USERThe NFC card is already registered and assigned to another user.
CODE_CREDS_DISABLE_TRANSFER_UID_USER_NFCThe UniFi Identity Enterprise user's NFC card is not transferrable.
CODE_CREDS_NFC_READ_SESSION_NOT_FOUNDFailed to obtain the NFC read session.
CODE_CREDS_NFC_READ_POLL_TOKEN_EMPTYThe NFC token is empty.
CODE_CREDS_NFC_CARD_IS_PROVISIONThe NFC card is already registered at another site.
CODE_CREDS_NFC_CARD_PROVISION_FAILEDPlease hold the NFC card against the reader for more than 5 seconds.
CODE_CREDS_NFC_CARD_INVALIDThe card type is not supported. Please use a UA Card.
CODE_CREDS_NFC_CARD_CANNOT_BE_DELETEThe NFC card could not be deleted.
CODE_CREDS_PIN_CODE_CREDS_ALREADY_EXISTThe PIN code already exists.
CODE_CREDS_PIN_CODE_CREDS_LENGTH_INVALIDThe PIN code length does not meet the preset requirements.
CODE_SPACE_DEVICE_BOUND_LOCATION_NOT_FOUNDThe device's location was not found.
CODE_DEVICE_DEVICE_VERSION_NOT_FOUNDThe firmware version is up to date.
CODE_DEVICE_DEVICE_VERSION_TOO_OLDThe firmware version is too old. Please update to the latest version.
CODE_DEVICE_DEVICE_BUSYThe camera is currently in use.
CODE_DEVICE_DEVICE_NOT_FOUNDThe device was not found.
CODE_DEVICE_DEVICE_OFFLINEThe device is currently offline.
CODE_OTHERS_UID_ADOPTED_NOT_SUPPORTEDThe API is not available after upgrading to Identity Enterprise.
CODE_HOLIDAY_GROUP_CAN_NOT_DELETEThe holiday group could not be deleted.
CODE_HOLIDAY_GROUP_CAN_NOT_EDITThe holiday group could not be edited.
CODE_DEVICE_WEBHOOK_ENDPOINT_DUPLICATEDThe provided endpoint already exists.
CODE_DEVICE_API_NOT_SUPPORTEDThe API is currently not available for this device.

HTTP Verbs

HTTP MethodDescription
GETUsed for retrieving objects.
POSTUsed for creating objects or performing custom actions.
PUTUsed for replacing objects or collections.
DELETEUsed for deleting objects.

API Host

The Open API Server is hosted on port 12445 and can be accessed via HTTPS at https://console-ip:12445.

The server certificate is self-generated and untrusted.

Request Header

The header for a request contains the following information:

ParameterRequiredTypeDescriptionExample
AuthorizationTStringToken required for authentication and access control.Authorization: Bearer wHFmHRuX4I7sB2oDkD6wHg

Response Schema

The response for a request contains the following information:

json
{
  "code": "SUCCESS",
  "msg": "success",
  "data": {}
}
  1. code: Represents the result of request handling and indicates success or failure.
  2. msg: Represents the error description if the code is not equal to 1.
  3. data: Represents the data of API requests.