Magic links for unlocking resources¶
One of the features offered by our API is the ability to create temporary links that can be visited to unlock specific resources in your building.
All the endpoints and how to interface them are documented below
/magiclink¶
This endpoint will allow you to use a magic link to unlock a resource for a set period of time.
This link is generated by an admin using /magiclinkadmin
Resource Methods¶
- /GET
List all the devices that this magic link can access, if its valid.
Specific doors can be unlocked and locked by using the SocketIO connection to the backend server
- Parameters:
magic_token – The secure code provided to unlock a particular resource
email – The email associated with this link
- Returns:
An array of dictionaries with the doors that this link can be used to unlock, or an error
[{ 'door_name': 'Door 1', 'end_time': '2023-01-29 15:48:20', 'resource_id': 1, 'resource_subtype': None, 'resource_type': 'DOOR' }]
- /POST
EXTERNAL This endpoint will generate a new unique token value to be stored in the browser to lock the browser
Note that we can only create one entry with one pair of (magic_token, email) if the same pair appears again, we should not be able to create a second entry. Return 400 instead
- Parameters:
email – Email that we are bonding to this browser
magic_token – Magic token that we using to bond this browser
- Returns:
{success, browser_identifier}, 200 if successful, {error}, 400 if the token cannot be generated
/magiclinkadmin¶
This endpoint will allow you to create a magic link – a link that when clicked will open the specified resource.
To generate a magic link, you can use your API Key to PUT a new magic link in the database You can then GET a list of all the existing magic links And, you can DELETE specific magic links by referencing them directly
Resource Methods¶
- /DELETE
This endpoint will remove the specific magic link.
- Parameters:
magic_link_id – The ID of the magic link that you’d like to remove. [This can be obtained from /GET]
- Returns:
An HTTP tuple for Flask ({‘success/error’: ‘message’}, status_number) or a dict {‘success/error’: ‘message’, ‘magic_link_id’: id}
- /GET
This endpoint will list all the active magic links in your organization with the associated users and resources This link is generated by an admin using /PUT.
- Parameters:
view_inactive – (Optional) Display inactive links as well
- Returns:
Returns an array with tuples for active magic links
[[magic_link_id, magic_token, access_control_name, start_time, end_time, created, emails, doors, created_email_id, created_email], ...]
- /PUT
Create a magic link that can be sent the user that they can click to unlock the specified resource.
- Parameters:
email_list – (Required) An array of emails for users that you want to provide the magic link to
resource_id_list – (Required) The resource ID that you want to provide access to. Note: These must be
doors! :param end_time: (Required) A date and time to expire this link in UTC (YYYY-MM-DD hh:mm:ss) [Default: never] :param name: (Required) This is the name of this policy that will make it easier to manage later :param send_email: (Optional) If this is set to False, we will not automatically send this link to
them in an email
- Parameters:
start_time – (Optional) A date and time to activate this link in UTC (YYYY-MM-DD hh:mm:ss) [Default: now]
config_id – (Optional) The configuration ID that you want to use for this link.
smartcards – (Optional) An array of dictionary of smartcards containing the ‘label’ and ‘number’ field mapped 1-1 for the emails.e.g [{“label”: “<label>”, “number”: “<number>”}]
allow_duplicates – (Optional) If this is set to True, we will allow smartcard to be added even if someone else in the org, owns the smartcard number.
time_mapping –
(Optional) An array of days of the week (7 elements) and the range of times that this link should be active. [Default is 24/7 access]
With the week starting on Sunday, each element contains a list of active ranges. For example, 24/7 access looks like this:
[[[0,24]],[[0,24]], ...]
9 am - 5 pm work days only:
[[],[[9,17]],[[9,17]], ... ,[]]
And, 9-noon and 1pm-5pm would be:
[[],[[9,12],[13,17]], [[9,12],[13,17]], ... ,[]]
- Returns:
Returns a magic token that can be used to unlock the resource and dictionary (email_ids) that maps
emails to email_ids
{"success": "Successfully created a new temporary policy and magic link.", "magic_token": "WufGylsf1w0ZFZfYAw8_ziK3KxDOYQ16IPLwgSpFg9WjJzQZF-u8XLKU7fQsTB8gCnuUlm1OHA0wjxBzGFFkOg", "email_ids": {"email@address.com": <email_id>}, "config_id": ID of the configuration that was used, "magic_link_id": ID of the newly created magic link, }
- Raises:
AllthenticateError – Default 400 Bad Request Error
/quickmagiclink¶
Create a default magic link for 7 days that can be used to unlock a door. Only needs an API key and email ID to give access
Resource Methods¶
- /POST
Create a magic link for a single user that will be active for 7 days
- Parameters:
email – The email to create the quick 7 day magic link for
resource_id – The resource ID that you want to provide access to. Note: These must be
doors!
- Returns:
Returns a magic token that can be used to unlock the resource and dictionary (email_ids) that maps
emails to email_ids
{"success": "Successfully created a new temporary policy and magic link.", "magic_token": "WufGylsf1w0ZFZfYAw8_ziK3KxDOYQ16IPLwgSpFg9WjJzQZF-u8XLKU7fQsTB8gCnuUlm1OHA0wjxBzGFFkOg", "email_ids": {"email@address.com": <email_id>}, "config_id": ID of the configuration that was used, "magic_link_id": ID of the newly created magic link, }
- Raises:
AllthenticateError – Default 400 Bad Request Error