Sesam Admin API

URL: https://sesam.sircon.no/api/admin

All endpoints requires an Authorization-header with an API-key for your Sesam account. Your API-Key can be found here under the API tab.
Header="Authorization: API-Key %s"

GET /doors

Get available doors

None

{
    "status": "success",
    "message": "data",
    "data": [
        {
            "id": int,
            "name": string,
            "status": 1|0 (online|offline),
            "last_checked": int (unix timestamp)
        }
        ...
    ]
}
{
	"status": "error",
	"message": "", //Error message
}

GET /door/{door_id}

Get info on a single door

{door_id}: int
{
    "status": "success",
    "message": "data",
    "data": {
        "id": int,
        "name": string,
        "status": 1|0 (online|offline),
        "last_checked": int (unix timestamp)
    }
}
{
	"status": "error",
	"message": string, //Error message
}

POST /door/{door_id}/open

Open a door

{door_id}: int

form-data/x-www-form-urlencoded:
duration: ?int (keep open in seconds)
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": string, //Error message
}

POST /door/{door_id}/close

Close a door

{door_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": string, //Error message
}

POST /door/{door_id}/lock

Lock a door

{door_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": string, //Error message
}

POST /door/{door_id}/unlock

Unlock a door

{door_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": string, //Error message
}

GET /doorgroups

Get available door groups

None

{
    "status": "success",
    "message": "data",
    "data": {
		id: name
		...
    }
}
{
	"status": "error",
	"message": "", //Error message
}

GET /users

Get available users

None

{
    "status": "success",
    "message": "data",
    "data": [
        {
            "id": int,
            "email": string,
            "name": string
		}
		...
    ]
}
{
	"status": "error",
	"message": "", //Error message
}

GET /user?email={email}

Get user by email

None

{
    "status": "success",
    "message": "data",
    "data": {
        "id": int,
        "name": string,
        "email": string,
        "phone": string
    }
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user

Create a new user if the email is not already registered, and return the user_id of the new or existing user.

form-data/x-www-form-urlencoded:
email={email}
?name={name} - ignored if a user with the specified email already exists in Sesam
?phone={phone} - ignored if a user with the specified email already exists in Sesam
{
    "status": "success",
    "message": "data",
    "data": {
        "user_id": int
    }
}
{
	"status": "error",
	"message": "", //Error message
}

GET /user/{user_id}

Get a user

{user_id}: int
{
    "status": "success",
    "message": "data",
    "data": {
        "id": int,
        "name": string,
        "email": string,
        "phone": string
    }
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user/{user_id}

Update a user

{user_id}: int

form-data/x-www-form-urlencoded:
email={email}
name={name}
phone={phone}
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user/{user_id}/access/door/{door_id}/grant

Grant a user access to a door

{user_id}: int
{door_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user/{user_id}/access/door/{door_id}/revoke

Revoke door access from a user

{user_id}: int
{door_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user/{user_id}/access/doorgroup/{door_group_id}/grant

Grant a user access to a door group

{user_id}: int
{door_group_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user/{user_id}/access/doorgroup/{door_group_id}/revoke

Revoke door group access from a user

{user_id}: int
{door_group_id}: int
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": "", //Error message
}

POST /user/{user_id}/schedule/{door_id}

Schedule user access to a door

{user_id}: int
{door_id}: int

form-data/x-www-form-urlencoded:
from: int (unix timestamp)
to: int (unix timestamp)
{
    "status": "success",
    "message": string,
}
{
	"status": "error",
	"message": "", //Error message
}

GET /access/door/{door_id}

Get access log for a door

{door_id}: int
QUERY
*page=int
*limit=int
*from_timestamp=int
*to_timestamp=int
*unique_users=true
{
    "status": "success",
    "message": "data",
    "data": {
        "page": int,
		"total": int,
		"limit": int,
        "results": [
            {
                "user_id": int,
                "email": string,
                "door_id": int,
                "door_name": string,
                "access_time": int
			}
			...
        ]
    }
}
{
	"status": "error",
	"message": "", //Error message
}

GET /access/user/{user_id}

Get access log for a user

{user_id}: int
QUERY
*page=int
*limit=int
*from_timestamp=int
*to_timestamp=int
{
    "status": "success",
    "message": "data",
    "data": {
        "page": int,
        "total": int,
		"limit": int,
        "results": [
            {
                "user_id": int,
                "email": string,
                "door_id": int,
                "door_name": string,
                "access_time": int
			}
			...
        ]
    }
}
{
	"status": "error",
	"message": "", //Error message
}