Emerge API-DataExchangev2 - 5
Emerge API-DataExchangev2 - 5
Emerge API-DataExchangev2 - 5
____________ 1
Version 2.5, March 25, 2007 International Electronics, Inc.
Table of Contents
Overview.....................................................................................................3
Database Architecture .......................................................................................... 3
Calling the API ............................................................................................4
Retrieving the version of the API .......................................................................... 6
API Commands and Parameters ................................................................6
Access Levels in EditPerson .............................................................................. 19
Date Formats...................................................................................................... 20
Using the ENCODEDNUM, HOTSTAMP, CARDID and CARDNUM Parameters
in AddCredential ................................................................................................. 20
The CARDNUM Parameter and Card Format in AddCredential ......................... 21
Response to GetPerson ..................................................................................... 22
Calling SearchPersonData ................................................................................. 22
Response to SearchPersonData ........................................................................ 23
Response to GetAccessLevels........................................................................... 24
Response to the GetAccessCardDetails Command ........................................... 24
Response to the GetAccessDataLog Command ................................................ 26
Calling EditThreatLevelGroup............................................................................. 27
Calling GetPortals............................................................................................... 28
Response to the GetPortals ............................................................................... 28
Calls and Responses to GetAccessHistory ........................................................ 29
Notes on TimeSpecs and TimeSpecGroups ...................................................... 31
Calling GetTimeSpec.......................................................................................... 31
Response to GetTimeSpec ................................................................................ 32
Calling GetTimeSpecs........................................................................................ 32
Response to GetTimeSpecs............................................................................... 32
Calling GetTimeSpecGroup................................................................................ 33
Response to GetTimeSpecGroup....................................................................... 33
Calling GetTimeSpecGroups .............................................................................. 33
Response to GetTimeSpecGroups..................................................................... 33
Errors in API Processing .................................................................................... 34
Message Authentication Code ..................................................................35
Generating the MAC........................................................................................... 35
Examples..................................................................................................36
____________ 2
Version 2.5, March 25, 2007 International Electronics, Inc.
Overview
The IEI eMerge is an integrated security management network appliance that supports access
control, alarm monitoring, video surveillance, temperature monitoring, intercom, and administrative
functions. Individual EMerge units are typically deployed to manage security for single facilities, and
may be networked for the purpose of building larger security networks.
Internally, the EMerge deploys the familiar three-tier architecture in which the database tier uses
MySQL, the web server is based on GoAhead’s embedded web server, and the business logic is
provided by IEI Security Corporation. All components managed by the EMerge are network-
connected, and are managed through a web-based user interface.
This document describes the API for the EMerge that permits network-connected systems to perform
various operations with the EMerge under program control.
Database Architecture
The database server embedded in the IEI Network Controller (IEINC) is MySQL, specifically licensed
for this application. While the DBMS supports ODBC, to avoid conflict with possible future schema
changes all database interaction should be accomplished through the API.
With regard to the access control subsystem, a fragment of the database schema is shown below.
The database includes a table of “people”, whose records act as container objects for attributes
attached to people in real life. People are mapped to access levels which specify access privilege
and to access cards, the credentials used for access control.
It is assumed that the access levels will be input into the system using the normal web user interface
for the EMerge, and that people and cards may be entered either through the web user interface or
through the API. Likewise, card formats are entered through the standard web user interface. Note
that because records of the Person table are basically container objects, a Person record must exist
before an AccessCard or PersonToAccessLevel record is associated with it. The API provides a
mechanism for accomplishing this by splitting the entry of the Person record from the credentials
associated with that person. This is a two-step operation in the API, while the user interface
encapsulates it as a single operation.
____________ 3
Version 2.5, March 25, 2007 International Electronics, Inc.
Calling the API
The API for the IEI eMerge is invoked by POSTing an HTTP message to the web server on the IEI
Network Controller (IEINC). The message includes a single form parameter whose name is
“APIcommand,” and whose value is a blob of XML that contains the API command(s) described
below.
API commands are accepted at address:
http://<eMerge address>/goforms/nbapi
The IP port for these commands is the port at which the EMerge web server responds and is set with
the SETUP > SITE SETTINGS > NETWORK CONTROLLER command. It defaults to port 80. By
way of example, commands for a network controller located at 192.168.0.220 port 8080 go to
http://192.168.0.220:8080/goforms/nbapi.
The XML API command passed to the EMerge is wrapped in <NETBOX-API> tags. Within those
1
tags are one or more <COMMAND> blocks that contain individual API commands and a single <MAC>
entry containing the computed message authentication code for the entire contents of the XML blob.
Return information is passed back to the calling program from the web server, also in XML format.
The <COMMAND> block includes a command name attribute (name=) defined in the table below, a
2
command number attribute (num=) which serves to connect a given command with its response,
and a block of parameters enclosed within <PARAMS> tags. Parameters are uniquely named, also
as defined in the table below. Multiple <COMMAND> blocks can be included in a single blob of XML.
Each message sent by the caller contains a sequence number that is part of the message
authentication code in the <MAC> tag. It is up to the caller to increment the sequence numbers; the
EMerge remembers the highest sequence number that is has seen, and will reject messages that
3
have sequence numbers less than or equal to that number.
XML tags that are not supported by the API but are syntactically valid XML are ignored. The
structure of the XML blob is as follows:
<NETBOX-API>
<COMMAND name=command-name1 num=”1” dateformat=”tzoffset”>
<PARAMS>
<PARAM1> … value 1 … </PARAM1>
<PARAM2> … value 2 … </PARAM2>
.
.
.
</PARAMS>
</COMMAND>
<COMMAND name=command-name2 num=”2”>
<PARAMS>
1
The maximum number of <COMMAND> blocks that can be sent to the API is 32.
2
The num= attribute is a number in the range from 1 to 32 (depending upon how many commands are
provided. There can be no gaps in the numbering, so, for example, if there are two commands, they must
be num=1 and num=2.
3
The system administrator has the option of turning off message authentication from the S2 NetBox user
interface if there are other methods of data security in place. It is up to the caller to remember the highest
sequence number transacted, and to always transact sequence numbers higher than the last one. If that
becomes impossible, an option in the S2 NetBox user interface can be used to reset the sequence
numbering.
____________ 4
Version 2.5, March 25, 2007 International Electronics, Inc.
<PARAM1> … value 1 … </PARAM1>
<PARAM2> … value 2 … </PARAM2>
.
.
.
</PARAMS>
</COMMAND>
.
.
.
<MAC> …authentication code as hex digits … </MAC>
</NETBOX-API>
The “dateformat” attribute on a command is optional. If it is supplied, dates are returned with an
additional timezone offset included (see below for date format).
4 5
In response to the API call, a blob of XML is returned as follows, with each command generating a
<RESPONSE> block that includes a “name=” attribute indicating the type of command to which it
applies and a “num=” attribute indicating the instance, as follows:
<NETBOX>
<RESPONSE command=command-name1 num=”1”>
<CODE> …response code text… </CODE>
<DETAILS> …response details… </DETAILS>
</RESPONSE>
<RESPONSE command=command-name2 num=”2”>
<CODE> …response code text… </CODE>
<DETAILS> …response details… </DETAILS>
</RESPONSE>
.
.
.
</NETBOX>
4
No <MAC> is required for message responses because they are associated only with specific API
requests.
5
The maximum size of a response block is 8192 (8K) bytes.
____________ 5
Version 2.5, March 25, 2007 International Electronics, Inc.
Retrieving the version of the API
For versions 2.1 and newer, an XML command <GetAPIVersion> exists that will return
<APIVERSION> with the appropriate version string. Versions of the API older than 2.1 do not
recognize this command.
Therefore a request such as:
<NETBOX-API>
<COMMAND name=GetAPIVersion num=”1”>
</COMMAND>
</NETBOX-API>
6
A PERSONID is a text field supplied by the caller that is displayed in the “ID” field of the person record
in the user interface. Typically this field holds an identifier of significance to the calling application’s
database such as an employee number.
____________ 6
Version 2.5, March 25, 2007 International Electronics, Inc.
3. If a PERSONID is supplied by the caller and a Person already exists in the database with
that ID, then the record in the database is replaced by the data supplied by the caller and the
PERSONID is returned or zero is returned if the operation failed.
EditPerson may also be used to Delete or “Undelete” a Person, as in the UI.
• RemovePerson – removes a person7 and all associated credentials from the database.
• GetPerson – returns data about a Person.
• SearchPersonData – retrieves information about 1 or more people, based on various search
criteria.
• AddCredential – adds a credential to a person already in the database.
• RemoveCredential – removes a credential from a person already in the database.
• GetCardFormats - retrieves a list of the names of the defined card formats.
• AddAccessLevel – add a new access level.
• ModifyAccessLevel – modify an existing access level.
• RemoveAccessLevel – delete an access level.
• GetAccessLevel – retrieve information about an access level.
• GetAccessLevels – returns a list of names of the valid access levels in the system.
• PingApp – heartbeat for the application. Used only for the caller to determine the health of the
EMerge.
• GetAPIVersion (2.1 and newer) – retrieves the current version of the NBAPI from the server.
• GetAccessDataLog – retrieve a data log from the history. The use of this is deprecated. Use
GetAccessHistory instead.
The GetAccessDataLog command operates as follows:
1. The caller issues the GetAccessDataLog command passing the LOGID of the last data log
retrieved from the API.
2. If the caller does not know the LOGID of the last data log, then the caller passes zero to the
GetAccessDataLog command and the command returns the last data log in the system with
its LOGID.
3. The caller adds one (1) to the LOGID of the last log received, and requests the data log with
that LOGID. If no such data log exists (that is, if the LOGID passed was for the last log in
the system), then the API will return a LOGID of zero.
• GetAccessCardDetails – returns recent card access events and related information given a
CARDID and CARDFORMAT.
• AddThreatLevel – add in a new Threat Level.
• ModifyThreatLevel – modify an existing Threat Level.
• EditThreatLevel – add a new or edit an existing Threat Level The use of this is deprecated in
2.5 – AddThreatLevel and ModifyThreatLevel are preferred.
• RemoveThreatLevel – delete a Threat Level.
• SetThreatLevel – change the Threat Level in the system.
7
RemovePerson actually disables the person record, leaving it in the database so that reports of history
continue to function. Access levels and credential records are actually deleted, however.
____________ 7
Version 2.5, March 25, 2007 International Electronics, Inc.
• AddThreatLevelGroup – add a new Threat Level Group.
• ModifyThreatLevelGroup – modify threat level members in an existing threat level group.
• EditThreatLevelGroup – add a new or modify an existing Threat Levevl Group. The use of this
is deprecated in 2.5 – AddThreatLevelGroup and ModifyThreatLevelGroup are preferred.
• RemoveThreatLevelGroup – remove a threat level group.
• GetPortals – returns list of portals and associated card readers defined for the EMerge.
• GetAccessHistory – returns a history of access activity, either for all users or for a particular
access card (as a supplement to both GetAccessDataLog and GetAccessCardDetails).
• GetTimeSpec – returns a single time spec that is in the system.
• GetTimeSpecs – returns a list of time specs that are in the system.
• AddTimeSpec – add a new time spec into the system.
• ModifyTimeSpec – modify a time spec already in the system.
• DeleteTimeSpec – delete a time spec in the system.
• GetTimeSpecGroup – returns a single time spec group that is in the system.
• GetTimeSpecGroups – returns a list of time spec groups that are in the system.
• AddTimeSpecGroup – add a new time spec group into the system.
• ModifyTimeSpecGroup – modify a time spec group already in the system.
• DeleteTimeSpecGroup – Delete a time spec group from the system.
• AddHoliday – add a new holiday into the system.
• ModifyHoliday – modify an existing holiday.
• DeleteHoliday – delete an existing holiday.
• GetHolidays – return a list of holiday keys.
• GetHoliday – return a specific holiday.
• AddReaderGroup – add a new reader group to the system.
• ModifyReaderGroup – modify an existing reader group.
• DeleteReaderGroup – delete an existing reader group.
• GetReaderGroups – return a list of reader group keys.
• GetReaderGroup – return information for a specific reader group.
• GetReaders – return a list of readers in the system.
• GetReader – return information about a single reader.
• AddPortalGroup – add a new portal group.
• ModifyPortalGroup – modify an existing portal group.
• RemovePortalGroup - remove a portal group.
• GetPortalGroups – retrieve a list of Portal Groups.
• GetPortalGroup – retrieve information about a single portal group.
The table below details the available commands and their parameters.
____________ 8
Version 2.5, March 25, 2007 International Electronics, Inc.
Call /
Command Name Parameter Retu Usage
rn
____________ 9
Version 2.5, March 25, 2007 International Electronics, Inc.
“TRUE” or “FALSE.” Supplying “TRUE” is the
same as a call to “RemovePerson.” Supplying
DELETED C
“FALSE” to a person who has been deleted
undeletes the Person.
8
In this command, DUPLICATE is a successful return indicating that the record was updated rather than
inserted. A return of SUCCESS indicates an inserted record. (No reference in text to this footnote –
actually, it’s there under <DETAILS> above.)
____________ 10
Version 2.5, March 25, 2007 International Electronics, Inc.
PERSONID for the Person whose record the
PERSONID C
caller wishes to have returned.
GetPerson
“SUCCESS” or “FAIL” returned as <CODE>. If
Result R successful, then <DETAILS> contains a block of
XML describing the Person (see below).
FIRSTNAME C
MIDDLENAME C
UDF1 C
UDF2 C
UDF3 C
UDF4 C
SearchPersonData
UDF5 C
ACCESSLEVELDESCRI
C Description
PTION
THREATLEVELGROUP
C Threat level group reference for this Access Level
KEY
10
GetCardFormats has no parameters.
____________ 12
Version 2.5, March 25, 2007 International Electronics, Inc.
ACCESSLEVELKEY R If success, the reference for this access level
ACCESSLEVELKEY C
ACCESSLEVELDESCRI
C Description
PTION
THREATLEVELGROUP
C Threat level group reference for this Access Level
KEY
RemoveAccessLevel ACCESSLEVELKEY C
ACCESSLEVELKEY C
ACCESSLEVELDESCRI
R Description
PTION
THREATLEVELGROUP
R Threat level group reference for this Access Level
KEY
11
GetAccessLevels has no call parameters.
____________ 13
Version 2.5, March 25, 2007 International Electronics, Inc.
12
PingApp RESULTCODE R “SUCCESS” returned in <CODE>.
12
The “application ping” command has no parameters in the call and returns either success or times out.
13
GetAPIVersion has no parameters, returns a version string, and is not supported before version 2.1 on
the server.
____________ 14
Version 2.5, March 25, 2007 International Electronics, Inc.
Optional: Display order for the threat level in
SEQNUM C
EMerge user interface displays.
____________ 15
Version 2.5, March 25, 2007 International Electronics, Inc.
Optional: used to start after a particular log ID that
AFTERLOGID C was previously returned. Implies an order of
“ASCENDING”
C
GetTimeSpec TIMESPECKEY Key for TimeSpec
DESCRIPTION C Description
MONDAY C 1/0
TUESDAY C 1/0
WEDNESDAY C 1/0
THURSDAY C 1/0
FRIDAY C 1/0
SATURDAY C 1/0
SUNDAY C 1/0
DESCRIPTION C Description
MONDAY C 1/0
ModifyTimeSpec TUESDAY C 1 /. 0
WEDNESDAY C 1/0
THURSDAY C 1/0
FRIDAY C 1/0
SATURDAY C 1/0
SUNDAY C 1/0
DeleteTimeSpec TIMESPECKEY C
C
GetTimeSpecGroup TIMESPECGROUPKEY Key for TimeSpecGroup
DESCRIPTION C Description
AddTimeSpecGroup
List of keys for timespecs to be included in the
TIMESPECKEYS C
group
DeleteTimeSpec TIMESPECKEY C
AddHoliday HOLIDAYNAME C
____________ 17
Version 2.5, March 25, 2007 International Electronics, Inc.
HOLIDAYGROUPS C Any of 1,2, or 3
STARTDATE C
ENDDATE C
HOLIDAYKEY C
HOLIDAYNAME C
ModifyHoliday HOLIDAYGROUPS C Any of 1,2, or 3
STARTDATE C
ENDDATE C
DeleteHoliday HOLIDAYKEY C
HOLIDAYKEY C
HOLIDAYNAME R
GetHoliday HOLIDAYGROUPS R
STARTDATE R
ENDDATE R
DESCRIPTION C Description
AddReaderGroup
READERKEYS C List of keys for readers to be included in the group
NAME C
ModifyReaderGroup
DESCRIPTION C
READERKEYS C
DeleteReaderGroup READERGROUPKEY C
READERGROUPKEY C
NAME R
GetReaderGroup
DESCRIPTION R
READERKEY C
GetReader NAME R
DESCRIPTION R
THREATLEVELGROUP
C Reference to threat level group
KEY
NAME C
DESCRIPTION C
PORTALKEYS C
THREATLEVELGROUP
C Reference to threat level group
KEY
DeletePortalGroup PORTALGROUPKEY C
GetPortalGroup PORTALGROUPKEY C
NAME R
DESCRIPTION R
THREATLEVELGROUP
C Reference to threat level group
KEY
Any access levels passed with the EditPerson API command replace all access levels in the Person
record. That is, access levels must be passed as a group. It is not necessary, however, to pass
empty access levels; any access levels not provided in an EditPerson command will be cleared by
the API.
____________ 19
Version 2.5, March 25, 2007 International Electronics, Inc.
Date Formats
There are different rules for supplying dates as input, and the dates that are retrieved. All dates are
in local time as of the time of the EMerge server.
Returned Dates
Returned dates are shown in 2 forms. If the command does not have the ‘dateformat=”tzoffset”’
attribute, the dates are returned as:
YYYY-MM-DD HH:MM:SS
Where, for example, EST timezone would be “-0500” (indicating -5 hours and 0 minutes offset from
GMT).
The “-“ represent bits that are ignored, the “FFFF” represents the facility code, and the “NNNN”
represent bits where the ENCODEDNUM is stored.
____________ 20
Version 2.5, March 25, 2007 International Electronics, Inc.
HOTSTAMP, while it defaults to the same value as ENCODEDNUM, is often a number that appears
on the credential itself as an externally visible integer and may be quite different than the
ENCODEDNUM.
In the NBAPI, either will be used for both if only one is supplied.
This value is equivalent to 0x05C1DF80 (hex) or “05C1DF80” in ASCII. Note that this 8-character
string represents 32 bits. Zeroes are added to the right to make 48 bits, resulting in the value
“05C1DF8000000”. The caller could have, of course, simply passed this fully padded value and
obtained the same result.
The raw data read from a credential in real time by the EMerge is interpreted using a set of rules
defined by the card format. Card formats are defined in the EMerge user interface with the SETUP >
ACCESS CONTROL > CARD FORMATS command and a list of the card format names can be
retrieved in the API using the GetCardFormats command.
The response to the GetCardFormats API command is similar to:
<NETBOX>
<RESPONSE command="GetCardFormats" num="1">
<CODE>SUCCESS</CODE>
<DETAILS>
<CARDFORMATS>
<CARDFORMAT>Wiegand26</CARDFORMAT>
<CARDFORMAT>ISO34bit</CARDFORMAT>
</CARDFORMATS>
</DETAILS>
</RESPONSE>
</NETBOX>
14
Only upper case characters may appear in the ASCII-equivalent representation of the hexadecimal
data.
____________ 21
Version 2.5, March 25, 2007 International Electronics, Inc.
Response to GetPerson
When the GetPerson command returns a <CODE> of “SUCCESS”, then <DETAILS> contains a block
of XML with data about the Person. The entire response appears as:
<NETBOX>
<RESPONSE command=”GetPerson” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<PERSONID>ID of Person record</PERSONID>
<FIRSTNAME>Person’s first name</FIRSTNAME>
<LASTNAME>Person’s last name</LASTNAME>
<DELETED>TRUE/FALSE</DELETED>
<ACCESSLEVELS>
<ACCESSLEVEL>access level 1</ACCESSLEVEL>
<ACCESSLEVEL>access level 2</ACCESSLEVEL>
.
.
.
<ACCESSLEVEL>access level 6</ACCESSLEVEL>
</ACCESSLEVELS>
</DETAILS>
</RESPONSE>
</NETBOX>
Note that only the access levels currently assigned are returned, and if there are none assigned,
then none are returned.
Calling SearchPersonData
When calling SearchPersonData, there are various options in making the call. If <PERSONID> is
supplied in the call, then exactly one matching person is returned. In the other cases, the call
retrieves the matching people.
In the boundary case, with no parameters supplied, all people on the EMerge are returned. If there
are more people than can be returned in a single response, a <NEXTKEY> element is returned that
allows the next call to be made. In this way, iterative calls can retrieve as many people as required,
by keeping all the other parameters the same, and supplying a new <NEXTKEY> element for each
successive call.
An example of a call to retrieve a single person is:
<NETBOX-API>
<COMMAND name=”SearchPersonData” num=”1” dateformat=”tzoffset”>
<PARAMS>
<PERSONID>_3</PERSONID>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
____________ 22
Version 2.5, March 25, 2007 International Electronics, Inc.
An example of a (second) call to retrieve multiple people with restrictions, after the first response
returned a <NEXTKEY> parameter is:
<NETBOX-API>
<COMMAND name=”SearchPersonData” num=”1”>
<PARAMS>
<LASTNAME>Smith</LASTNAME>
<STARTFROMKEY>32</STARTFROMKEY>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
Response to SearchPersonData
When the SearchPersonData command returns a <CODE> of “SUCCESS”, then <DETAILS>
contains a block of XML with data about one or more people. The entire response appears as:
<NETBOX>
<RESPONSE command=”SearchPersonData” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<PEOPLE>
<PERSON>
<PERSONID>ID of Person record</PERSONID>
<FIRSTNAME>Person’s first name</FIRSTNAME>
<LASTNAME>Person’s last name</LASTNAME>
<DELETED>TRUE/FALSE</DELETED>
…
<ACCESSLEVELS>
<ACCESSLEVEL>access level 1</ACCESSLEVEL>
<ACCESSLEVEL>access level 2</ACCESSLEVEL>
…
</ACCESSLEVELS>
<ACCESSCARDS>
<ACCESSCARD>
<ENCODEDNUM>encoded #</ENCODEDNUM>
<HOTSTAMP>hot stamp #</HOTSTAMP>
<CARDFORMAT>name of card format</CARDFORMAT>
<DISABLED>1 or 0</DISABLED>
</ACCESSCARD>
<ACCESSCARD>
…
</ACCESSCARD>
</ACCESSCARDS>
</PERSON>
<PERSON>
…
</PERSON>
</PEOPLE>
<NEXTKEY>internal key to pass into next request</NEXTKEY>
</DETAILS>
</RESPONSE>
</NETBOX>
____________ 23
Version 2.5, March 25, 2007 International Electronics, Inc.
The breakdown of information is as follows. As many people are returned as possible that match the
query. If there is insufficient space in the internal buffer, <NEXTKEY> is returned as the parameter to
use to retrieve the next set of people.
For each person, the list of access levels and access cards associated with that person are returned.
If there are no access levels, none are returned. For the access cards, the newer <ENCODEDNUM>
and <HOTSTAMP> attributes are returned (see AddCredential) in place of <CARDID> and
<CARDNUM>.
Response to GetAccessLevels
When the GetAccessLevels command returns a <CODE> of “SUCCESS” then <DETAILS> contains
a list of access level names currently defined in the system. The entire return would appears as
follows:
<NETBOX>
<RESPONSE command=”GetAccessLevels” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<ACCESSLEVELS>
<ACCESSLEVEL>access level 1</ACCESSLEVEL>
<ACCESSLEVEL>access level 2</ACCESSLEVEL>
.
.
.
<ACCESSLEVEL>access level 6</ACCESSLEVEL>
</ACCESSLEVELS>
</DETAILS>
</RESPONSE>
</NETBOX>
Note that only the access levels currently assigned are returned, and if there are none assigned,
then none are returned.
In this example, the most recent 3 access events are requested for a credential with ENCODEDNUM
3527and a CARDFORMAT called “Code30.” If the request succeeds (<CODE>SUCCESS</CODE>)
then the following are returned:
____________ 24
Version 2.5, March 25, 2007 International Electronics, Inc.
• PERSONID – the external person ID associated with the person who owns the credential
specified credential. This is the field in the person record labeled “ID #”.
• DISABLED – 1 if the credential is currently marked disabled, and 0 otherwise.
• DTTM – The date and time associated with the first access data log that exists for the stated
credential on the day the request is made to the API. Note that this field will be empty if there is
no such access.
• PORTALNAME – Name of the portal associated with the first access of the calendar day referred
to by the DTTM value.
• ACCESSES – a list of access data log records responsive to the request. Each data log returned
is enclosed within <ACCESS>…</ACCESS> tags, and includes the following fields:
o DTTM – The date and time associated with the data log.
o TYPE – 1 for a valid access, 2 for a rejected access attempt.
o PORTALNAME – name of the portal associated with the access.
o PORTALKEY – unique identifier for the portal that matches to the GetPortals query.
o READERKEY – unique identifier for the reader that had the access
o REASON – Reason code associated with a rejected access attempt. See the table
included with the description of GetAccessDataLog for details.
Reason codes are provided only for invalid access attempts, and are described in the table below:
Reason
Description
code
3 Wrong time
4 Wrong location
5 Card misread
6 Tailgate violation
7 Anti-passback violation
8 --unused--
9 Wrong day
10 – 13 --unused--
14 Card expired
____________ 26
Version 2.5, March 25, 2007 International Electronics, Inc.
By way of example, a call such as:
<NETBOX-API>
<COMMAND name=”GetAccessDataLog” num=”1”>
<PARAMS>
<LOGID>999</LOGID>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
In this case, an invalid access attempt at 23:57:21 on January 3, 2005 occurred at the “Garage-in”
reader by the Person whose ID is 1000. The reason for rejection was that the card was used at the
wrong location.
Calling EditThreatLevelGroup
EditThreatLevelGroup is called to add (if the group does not exist) or edit (if it does) a threat level
group. A call might appear like:
<NETBOX-API>
<COMMAND name=”EditThreatLevelGroup” num=”1”>
<PARAMS>
<LEVELGROUPNAME>Hot</LEVELGROUPNAME>
<LEVELNAMES>
<LEVELNAME>RedLevel</LEVELNAME>
<LEVELNAME>OrangeLevel</LEVELNAME>
</LEVELNAMES>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
Note that the names in the <LEVELNAMES> are names of individual levels that must already exist in
the system.
____________ 27
Version 2.5, March 25, 2007 International Electronics, Inc.
Calling GetPortals
An example of calling GetPortals successively if <NEXTKEY> was returned on a previous call is:
<NETBOX-API>
<COMMAND name=”GetPortals” num=”1”>
<PARAMS>
<STARTFROMKEY>32</STARTFROMKEY>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
The <PORTALORDER> element of a READER indicates whether it is in the first or the second
reader position in a Portal. While this is not guaranteed, the first position is always used as the
incoming reader; the second position is optional, and is used as the outgoing reader in a dual reader
door when it exists.
____________ 28
Version 2.5, March 25, 2007 International Electronics, Inc.
Calls and Responses to GetAccessHistory
GetAccessHistory serves multiple purposes:
• to retrieve at any one point in time a history of accesses that are available on the EMerge;
• over time to retrieve any new accesses that may have occurred.
• To retrieve a longer history of accesses for a particular card.
These three examples are illustrated below.
<NETBOX-API>
<COMMAND name=”GetAccessHistory” num=”1” dateformat=”tzoffset”>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
This will return the most recent access history records, in reverse time order, up to some internal
maximum, for example:
<NETBOX>
<RESPONSE command=” GetAccessHistory” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<ACCESSES>
<ACCESS>
<LOGID>402</LOGID>
<PERSONID>uid45</PERSONID>
<READER>reader 1</READER>
<DTTM>2006-06-23 10:31:06 -0400</DTTM>
<TYPE>1</TYPE>
<READERKEY>3</READERKEY>
<PORTALKEY>30</PORTALKEY>
</ACCESS>
<ACCESS>
<LOGID>397</LOGID>
<PERSONID>uid23</PERSONID>
<READER>reader 2</READER>
<DTTM>2006-06-23 10:15:06 -0400</DTTM>
<TYPE>1</TYPE>
<READERKEY>5</READERKEY>
<PORTALKEY>15</PORTALKEY>
</ACCESS>
…
</ACCESSES>
<NEXTLOGID>310</NEXTLOGID>
</DETAILS>
</RESPONSE>
</NETBOX>
____________ 29
Version 2.5, March 25, 2007 International Electronics, Inc.
A subsequent call using the <NEXTLOGID> value will retrieve the next older chunk of log records,
e.g.:
<NETBOX-API>
<COMMAND name=”GetAccessHistory” num=”1” dateformat=”tzoffset”>
<STARTLOGID>310</STARTLOGID>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
Another call later using <AFTERLOGID> will retrieve any records which have been created since the
first call, e.g.:
<NETBOX-API>
<COMMAND name=”GetAccessHistory” num=”1” dateformat=”tzoffset”>
<AFTERLOGID>402</AFTERLOGID>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
Calling GetTimeSpec
This works by supplying a TimeSpec Key. This will typically come from the list of Time Spec Keys in
a Time Spec Group.
<NETBOX-API>
<COMMAND name=”GetTimeSpec” num=”1”>
<TIMESPECKEY>3</TIMESPECKEY>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
____________ 31
Version 2.5, March 25, 2007 International Electronics, Inc.
Response to GetTimeSpec
Response to the GetTimeSpec command:
<NETBOX>
<RESPONSE command=”GetTimeSpec” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<TIMESPEC>
<TIMESPECKEY>unique id for timespec</TIMESPECKEY>
<TIMESPECNAME>name of timespec</TIMESPECNAME>
<DESCRIPTION>description for timespec</DESCRIPTION>
<MONDAY>TRUE</MONDAY>
<TUESDAY>TRUE</TUESDAY>
…
<STARTTIME>HH:MM</STARTTIME>
<ENDTIME>HH:MM</ENDTIME>
<HOLIDAYGROUPS>1,2,3</HOLIDAYGROUPS>
</TIMESPEC>
</DETAILS>
</RESPONSE>
</NETBOX>
Calling GetTimeSpecs
This works identically to GetPortals, in that a “STARTFROMKEY” can be passed in to return the next
set of Time Specs, if more than one call needs to be made.
Response to GetTimeSpecs
Responses to the GetTimeSpecs command list time specs
<NETBOX>
<RESPONSE command=”GetTimeSpecs” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<TIMESPECS>
<TIMESPEC>
<TIMESPECKEY>unique id for timespec</TIMESPECKEY>
<TIMESPECNAME>name of timespec</TIMESPECNAME>
<DESCRIPTION>description for timespec</DESCRIPTION>
<MONDAY>TRUE</MONDAY>
<TUESDAY>TRUE</TUESDAY>
…
<STARTTIME>HH:MM</STARTTIME>
<ENDTIME>HH:MM</ENDTIME>
<HOLIDAYGROUPS>1,2,3</HOLIDAYGROUPS>
</TIMESPEC>
<TIMESPEC>
…
</TIMESPEC>
</TIMESPECS>
<NEXTKEY>key of next timespec</NEXTKEY>
</DETAILS>
</RESPONSE>
</NETBOX>
____________ 32
Version 2.5, March 25, 2007 International Electronics, Inc.
Calling GetTimeSpecGroup
As with GetTimeSpec, this specifies a key that might be retrieved from another part of the system.
<NETBOX-API>
<COMMAND name=”GetTimeSpecGroup” num=”1”>
<TIMESPECGROUPKEY>4</TIMESPECGROUPKEY>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
Response to GetTimeSpecGroup
Responses to the GetTimeSpecGroup command:
<NETBOX>
<RESPONSE command=”GetTimeSpecGroups” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<TIMESPECGROUP>
<TIMESPECGROUPKEY>unique id for group</TIMESPECGROUPKEY>
<NAME>name of timespec</NAME>
<DESCRIPTION>description for group</DESCRIPTION>
<TIMESPECKEYS>
<TIMESPECKEY>ID for timespec</TIMESPECKEY>
<TIMESPECKEY>ID for timespec</TIMESPECKEY>
…
</TIMESPECKEYS>
</TIMESPECGROUP>
</DETAILS>
</RESPONSE>
</NETBOX>
Calling GetTimeSpecGroups
This also works identically to GetPortals, in that a “STARTFROMKEY” can be passed in to return the
next set of Time Spec Groups, if more than one call needs to be made.
Response to GetTimeSpecGroups
Responses to the GetTimeSpecGroups command list time specs
<NETBOX>
<RESPONSE command=”GetTimeSpecGroups” num=command-number>
<CODE>SUCCESS</CODE>
<DETAILS>
<TIMESPECGROUPS>
<TIMESPECGROUP>
<TIMESPECGROUPKEY>unique id for group</TIMESPECGROUPKEY>
<NAME>name of timespec</NAME>
<DESCRIPTION>description for group</DESCRIPTION>
<TIMESPECKEYS>
<TIMESPECKEY>ID for timespec</TIMESPECKEY>
<TIMESPECKEY>ID for timespec</TIMESPECKEY>
…
____________ 33
Version 2.5, March 25, 2007 International Electronics, Inc.
</TIMESPECKEYS>
</TIMESPECGROUP>
<TIMESPECGROUP>
…
</TIMESPECGROUP>
</TIMESPECGROUPS>
<NEXTKEY>key of next group</NEXTKEY>
</DETAILS>
</RESPONSE>
</NETBOX>
API_PARSE_ERROR 4 The APIcommand data could not be parsed by the XML parser
____________ 34
Version 2.5, March 25, 2007 International Electronics, Inc.
Message Authentication Code
The message authentication code (MAC) is a code based on the SHA-1 hashing algorithm that is
designed to be unique for every message and impossible to reverse in practice. The MAC is
transmitted in the <MAC> tag of the message and has the form:
111111111122222222223333333333444444444455555555556
123456789012345678901234567890123456789012345678901234567890
RAN RAN SEQ SHA-1 result as 40 hexadecimal
1 2 # digits
where RAN1 and RAN2 are two random numbers, each of five decimal digits; SEQ # is the
sequence number that is incremented for each message transmitted by the caller; and, the balance
is the 40-hex digit SHA-1 hash as produced by the algorithm provided.
// generate_mac:
// takes the msg, seq and secret and generates a SHA_MAC_LEN + 1
// byte mac (null terminated) which is then stored in mac
// and a pointer to mac is returned
//
// NOTES:
//
// 1. msg must be null terminated and should not contain the
// <MAC>...</MAC> tags.
//
// 2. secret must be null terminated and < SHA_SECRET_SZ bytes long
//
unsigned char *generate_mac(unsigned char *msg, unsigned long seq,
unsigned char *secret, unsigned short rand1, unsigned short rand2,
unsigned char *mac);
____________ 35
Version 2.5, March 25, 2007 International Electronics, Inc.
Examples
For example, the XML generated to add a person might appear as follows:
<NETBOX-API>
<COMMAND name=”EditPerson” num=”1”>
<PARAMS>
<LASTNAME>Doe</LASTNAME>
<FIRSTNAME>John</FIRSTNAME>
<ACCESSLEVELS>
<ACCESSLEVEL>GeneralAccess</ACCESSLEVEL>
<ACCESSLEVEL>ParkingAccess</ACCESSLEVEL>
</ACCESSLEVELS>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
If an error had occurred, then the ERRMSG tag would give a text description of the error condition as
in:
<NETBOX>
<RESPONSE command=”EditPerson” num=”1”>
<CODE>FAIL</CODE>
<DETAILS>
<ERRMSG>
Access level does not exist “ParkingAccess”
</ERRMSG>
</DETAILS>
</RESPONSE>
</NETBOX>
Once the person record has been instantiated, a credential (card) can be added to it as follows:
<NETBOX-API>
<COMMAND name=”AddCredential” num=”1”>
<PARAMS>
<PERSONID>_123</PERSONID>
<CARDNUM>AF2621B5</CARDNUM>
<CARDFORMAT>Wiegand26</CARDFORMAT>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
____________ 36
Version 2.5, March 25, 2007 International Electronics, Inc.
Because multiple commands can be included in a single XML call, the creation of a Person and
association of credentials can be accomplished in one transaction (if the caller provides the
PERSONID):
<NETBOX-API>
<COMMAND name=”EditPerson” num=”1”>
<PARAMS>
<LASTNAME>Doe</LASTNAME>
<FIRSTNAME>John</FIRSTNAME>
<ACCESSLEVELS>
<ACCESSLEVEL>GeneralAccess</ACCESSLEVEL>
<ACCESSLEVEL>ParkingAccess</ACCESSLEVEL>
</ACCESSLEVELS>
<PERSONID>X1000</PERSONID>
</PARAMS>
</COMMAND>
<COMMAND name=”AddCredential” num=”2”>
<PARAMS>
<PERSONID>X1000</PERSONID>
<CARDNUM>AF2621B5</CARDNUM>
<CARDFORMAT>Wiegand26</CARDFORMAT>
</PARAMS>
</COMMAND>
<MAC> …authentication code… </MAC>
</NETBOX-API>
Assuming that the commands above were successfully executed by the EMerge, the response would
be as follows:
<NETBOX>
<RESPONSE command=”EditPerson” num=”1”>
<CODE>SUCCESS</CODE>
<DETAILS>
<PERSONID>X1000</PERSONID>
</DETAILS>
</RESPONSE>
<RESPONSE command=”AddCredential” num=”2”>
<CODE>SUCCESS</CODE>
</RESPONSE>
</NETBOX>
____________ 37
Version 2.5, March 25, 2007 International Electronics, Inc.