Install our SDK in your preferred language
Install-Package accessgrid.dll -Version 1.0.0
implementation "com.accessgrid.sdk:accessgrid:1.0.0"
composer require accessgrid/accessgrid
Authentication
We use a dual authentication mechanism, it consists of two parts:
A static account id to be sent in the X-ACCT-ID
header
A shared secret scheme to authenticate every API request with a signed payload in the X-PAYLOAD-SIG
header
You can find both keys in your AccessGrid console on the API keys page. If you're logged in, they're automatically embedded into this documentation.
The shared secret scheme works as follows…
Grab your shared secret from the API keys page in the AccessGrid console .
For every request that you make, you'll use your shared secret as the salt with a base64 encoded version of your payload as the input to a SHA256 hashing function. When there is no payload, simply use this JSON as the payload (like in suspend, unlink, and resume calls) or sig_payload
param for GET requests (replacing the value with the appropriate id, such as the card id or card template id for enterprise calls): {"id": "0xc4rd1d"}
You'll then need to use this SHA256 hash as the value for the X-PAYLOAD-SIG
header in your request. From a high-level, the code needed to create the signature is as follows: SHA256.update(shared_secret + base64.encode(payload)).hexdigest()
If you use one of our SDKs, this will all be handled for you!
Issue NFC key
Enable a pass to be added to be created and installed on their mobile device with the constraints set in the AccessGrid console and this API call. Returns a landing page for installing the access pass.
Unique identifier for the card template to use
Unique identifier for the employee
Physical tag identifier associated with the NFC key
allow_on_multiple_devices
boolean
Whether the card can be used on multiple devices simultaneously - will override the card template set in the AccessGrid console
Full name of the employee
Email address of the employee - if you have a SendGrid or Postmark integration, then we will send a text message on your behalf
Contact phone number for the employee - if you have a Twilio integration, then we will send a text message on your behalf
Employment classification (e.g., full_time, contractor)
ISO8601 timestamp when the card becomes active
ISO8601 timestamp when the card expires
Base64 encoded image of the employee
# Base64 encode the JSON
JSON=$(cat <<EOF
{
"card_template_id": "0xd3adb00b5",
"employee_id": "123456789",
"tag_id": "DDEADB33FB00B5",
"allow_on_multiple_devices": true,
"full_name": "Employee name",
"email": "[email protected] ",
"phone_number": "+19547212241",
"classification": "full_time",
"start_date": "$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")",
"expiration_date": "$(date -u -v+3m +"%Y-%m-%dT%H:%M:%S.%3NZ")",
"employee_photo": "[image_in_base64_encoded_format]"
}
EOF)
JSON_B64=$(echo $JSON | base64)
# Add salt and hash
HASH=$(echo -n "$SHARED_SECRET$JSON_B64" | openssl sha256 | awk '{print $2}')
# Send curl request
curl -v \
-X POST \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
-d '{"example": true}' \
"https://api.accessgrid.com/v1/key-cards"
require('accessgrid')
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KET']
client = AccessGrid.new(acct_id, secret_key)
card = client.access_cards.provision(
card_template_id: "0xd3adb00b5",
employee_id: "123456789",
tag_id: "DDEADB33FB00B5",
allow_on_multiple_devices: true,
full_name: "Employee name",
email: "[email protected] ",
phone_number: "+19547212241",
classification: "full_time",
start_date: "2024-12-22T17:46:33.692Z",
expiration_date: "2025-03-22T17:46:33.692Z",
employee_photo: "[image_in_base64_encoded_format]"
)
puts "Install URL: #{card.url}"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const provision = async () => {
try {
const card = await client.accessCards.provision({
cardTemplateId: "0xd3adb00b5",
employeeId: "123456789",
tagId: "DDEADB33FB00B5",
allowOnMultipleDevices: true,
fullName: "Employee name",
email: "[email protected] ",
phoneNumber: "+19547212241",
classification: "full_time",
start_date: "2024-12-22T17:46:33.692Z",
expiration_date: "2025-03-22T17:46:33.692Z",
employeePhoto: "[image_in_base64_encoded_format]"
});
console.log(`Install URL: ${card.url}`);
} catch (error) {
console.error('Error provisioning NFC key:', error);
}
};
provision();
from accessgrid import AccessGrid
import os
from datetime import datetime, timezone
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
# Current time in ISO format with UTC timezone
current_time = datetime.now(timezone.utc).isoformat(timespec='milliseconds')
card = client.access_cards.provision(
card_template_id="0xd3adb00b5",
employee_id="123456789",
tag_id="DDEADB33FB00B5",
allow_on_multiple_devices=True,
full_name="Employee name",
email="[email protected] ",
phone_number="+19547212241",
classification="full_time",
start_date="2024-12-22T17:46:33.692Z",
expiration_date="2025-03-22T17:46:33.692Z",
employee_photo="[image_in_base64_encoded_format]"
)
print(f"Install URL: {card.url}")
package main
import (
"fmt"
"os"
"time"
"github.com/accessgrid/accessgrid-go" // hypothetical import path
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
params := accessgrid.ProvisionParams{
CardTemplateID: "0xd3adb00b5",
EmployeeID: "123456789",
TagID: "DDEADB33FB00B5",
AllowOnMultipleDevices: true,
FullName: "Employee name",
Email: "[email protected] ",
PhoneNumber: "+19547212241",
Classification: "full_time",
StartDate: time.Now().UTC().Format(time.RFC3339Nano),
ExpirationDate: "2025-02-22T21:04:03.664Z",
EmployeePhoto: "[image_in_base64_encoded_format]",
}
card, err := client.AccessCards.Provision(params)
if err != nil {
fmt.Printf("Error provisioning card: %v\n", err)
return
}
fmt.Printf("Install URL: %s\n", card.URL)
}
using AccessGrid;
using Microsoft.Extensions.Configuration;
// Assuming you're in a class
public async Task ProvisionCardAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
var card = await client.AccessCards.ProvisionAsync(new ProvisionCardRequest
{
CardTemplateId = "0xd3adb00b5",
EmployeeId = "123456789",
TagId = "DDEADB33FB00B5",
AllowOnMultipleDevices = true,
FullName = "Employee name",
Email = "[email protected] ",
PhoneNumber = "+19547212241",
Classification = "full_time",
StartDate = DateTime.UtcNow,
ExpirationDate = DateTime.Parse("2025-02-22T21:04:03.664Z").ToUniversalTime(),
EmployeePhoto = "[image_in_base64_encoded_format]"
});
Console.WriteLine($"Install URL: {card.Url}");
}
// The request model would likely be defined like this
public class ProvisionCardRequest
{
public string CardTemplateId { get; set; } = string.Empty;
public string EmployeeId { get; set; } = string.Empty;
public string TagId { get; set; } = string.Empty;
public bool AllowOnMultipleDevices { get; set; }
public string FullName { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
public string PhoneNumber { get; set; } = string.Empty;
public string Classification { get; set; } = string.Empty;
public DateTime StartDate { get; set; }
public DateTime ExpirationDate { get; set; }
public string EmployeePhoto { get; set; } = string.Empty;
}
// And the response might look like this
public class ProvisionCardResponse
{
public string Url { get; set; } = string.Empty;
// Other properties that might come back from the API...
}
import com.organization.accessgrid.AccessGridClient;
import com.organization.accessgrid.model.ProvisionCardRequest;
import com.organization.accessgrid.model.Card;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class AccessCardService {
private final AccessGridClient client;
public AccessCardService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public Card provisionCard() throws AccessGridException {
ProvisionCardRequest request = ProvisionCardRequest.builder()
.cardTemplateId("0xd3adb00b5")
.employeeId("123456789")
.tagId("DDEADB33FB00B5")
.allowOnMultipleDevices(true)
.fullName("Employee name")
.email("[email protected] ")
.phoneNumber("+19547212241")
.classification("full_time")
.startDate(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))
.expirationDate("2025-02-22T21:04:03.664Z")
.employeePhoto("[image_in_base64_encoded_format]")
.build();
Card card = client.accessCards().provision(request);
System.out.printf("Install URL: %s%n", card.getUrl());
return card;
}
}
// The request model would likely be defined like this
@Getter
@Builder
public class ProvisionCardRequest {
private final String cardTemplateId;
private final String employeeId;
private final String tagId;
private final boolean allowOnMultipleDevices;
private final String fullName;
private final String email;
private final String phoneNumber;
private final String classification;
private final String startDate;
private final String expirationDate;
private final String employeePhoto;
}
// And the response model
@Getter
public class Card {
private final String url;
// Other properties...
}
// Usage example
public class Example {
public static void main(String[] args) {
try {
AccessCardService service = new AccessCardService();
Card card = service.provisionCard();
} catch (AccessGridException e) {
System.err.println("Error provisioning card: " + e.getMessage());
}
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$card = $client->accessCards->provision([
'card_template_id' => '0xd3adb00b5',
'employee_id' => '123456789',
'tag_id' => 'DDEADB33FB00B5',
'allow_on_multiple_devices' => true,
'full_name' => 'Employee name',
'email' => '[email protected] ',
'phone_number' => '+19547212241',
'classification' => 'full_time',
'start_date' => (new DateTime('now', new DateTimeZone('UTC')))->format('c'),
'expiration_date' => '2025-02-22T21:04:03.664Z',
'employee_photo' => '[image_in_base64_encoded_format]'
]);
echo "Install URL: {$card->url}\n";
Update NFC key
When you need to make an informational update to an NFC key such as name, photo, etc
Unique identifier of the NFC key to update, sent as part of the URL
employee_id
nullable string
Updated unique identifier for the employee
full_name
nullable string
Updated full name of the employee
classification
nullable string
Updated employment classification (e.g., full_time, contractor)
expiration_date
nullable string
Updated ISO8601 timestamp when the card expires
employee_photo
nullable string
Updated base64 encoded image of the employee
# Base64 encode the JSON
JSON=$(cat <<EOF
{
"employee_id": "987654321",
"full_name": "Updated Employee Name",
"classification": "contractor",
"expiration_date": "2025-02-22T21:04:03.664Z"
}
EOF)
JSON_B64=$(echo $JSON | base64)
# Add salt and hash
HASH=$(echo -n "$SHARED_SECRET$JSON_B64" | openssl sha256 | awk '{print $2}')
curl -v \
-X PATCH \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
-d '{
"card_id": "0xc4rd1d",
"employee_id": "987654321",
"full_name": "Updated Employee Name",
"classification": "contractor",
"expiration_date": "2025-02-22T21:04:03.664Z"
}' \
"https://api.accessgrid.com/v1/key-cards/{card_id}"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
card = client.access_cards.update(
card_id: "0xc4rd1d",
employee_id: "987654321",
full_name: "Updated Employee Name",
classification: "contractor",
expiration_date: "2025-03-22T17:46:33.692Z",
employee_photo: "[image_in_base64_encoded_format]"
)
puts "Card updated successfully"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const update = async () => {
try {
const card = await client.accessCards.update({
cardId: "0xc4rd1d",
employeeId: "987654321",
fullName: "Updated Employee Name",
classification: "contractor",
expirationDate: "2025-02-22T21:04:03.664Z",
employeePhoto: "[image_in_base64_encoded_format]"
});
console.log('Card updated successfully');
} catch (error) {
console.error('Error updating NFC key:', error);
}
};
update();
from accessgrid import AccessGrid
import os
from datetime import datetime, timezone, timedelta
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
card = client.access_cards.update(
card_id="0xc4rd1d",
employee_id="987654321",
full_name="Updated Employee Name",
classification="contractor",
expiration_date=(datetime.now(timezone.utc) + timedelta(days=90)).isoformat(),
employee_photo="[image_in_base64_encoded_format]"
)
print("Card updated successfully")
package main
import (
"fmt"
"os"
"time"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
params := accessgrid.UpdateParams{
CardID: "0xc4rd1d",
EmployeeID: "987654321",
FullName: "Updated Employee Name",
Classification: "contractor",
ExpirationDate: time.Now().UTC().AddDate(0, 3, 0).Format(time.RFC3339),
EmployeePhoto: "[image_in_base64_encoded_format]",
}
card, err := client.AccessCards.Update(params)
if err != nil {
fmt.Printf("Error updating card: %v\n", err)
return
}
fmt.Println("Card updated successfully")
}
using AccessGrid;
public async Task UpdateCardAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
await client.AccessCards.UpdateAsync(new UpdateCardRequest
{
CardId = "0xc4rd1d",
EmployeeId = "987654321",
FullName = "Updated Employee Name",
Classification = "contractor",
ExpirationDate = DateTime.UtcNow.AddMonths(3),
EmployeePhoto = "[image_in_base64_encoded_format]"
});
Console.WriteLine("Card updated successfully");
}
import com.organization.accessgrid.AccessGridClient;
import com.organization.accessgrid.model.UpdateCardRequest;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
public class AccessCardService {
private final AccessGridClient client;
public AccessCardService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public void updateCard() throws AccessGridException {
UpdateCardRequest request = UpdateCardRequest.builder()
.cardId("0xc4rd1d")
.employeeId("987654321")
.fullName("Updated Employee Name")
.classification("contractor")
.expirationDate(ZonedDateTime.now().plusMonths(3).format(DateTimeFormatter.ISO_INSTANT))
.employeePhoto("[image_in_base64_encoded_format]")
.build();
client.accessCards().update(request);
System.out.println("Card updated successfully");
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$card = $client->accessCards->update([
'card_id' => '0xc4rd1d',
'employee_id' => '987654321',
'full_name' => 'Updated Employee Name',
'classification' => 'contractor',
'expiration_date' => (new DateTime('now', new DateTimeZone('UTC')))->modify('+3 months')->format('c'),
'employee_photo' => '[image_in_base64_encoded_format]'
]);
echo "Card updated successfully\n";
Suspend NFC key
When you need to temporarily disable an NFC key for a short period of time
Unique identifier of the NFC key to suspend, sent as part of the URL
# Base64 encode the JSON
JSON='{ "card_id": "0xc4rd1d" }'
JSON_B64=$(echo $JSON | base64)
# Add salt and hash
HASH=$(echo -n "$SHARED_SECRET$JSON_B64" | openssl sha256 | awk '{print $2}')
curl -v \
-X POST \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
"https://api.accessgrid.com/v1/key-cards/{card_id}/suspend"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
card = client.access_cards.suspend(
card_id: "0xc4rd1d"
)
puts "Card suspended successfully"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const suspend = async () => {
try {
await client.accessCards.suspend({
cardId: "0xc4rd1d"
});
console.log('Card suspended successfully');
} catch (error) {
console.error('Error suspending NFC key:', error);
}
};
suspend();
from accessgrid import AccessGrid
import os
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
card = client.access_cards.suspend(
card_id="0xc4rd1d"
)
print("Card suspended successfully")
package main
import (
"fmt"
"os"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
err = client.AccessCards.Suspend("0xc4rd1d")
if err != nil {
fmt.Printf("Error suspending card: %v\n", err)
return
}
fmt.Println("Card suspended successfully")
}
using AccessGrid;
public async Task SuspendCardAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
await client.AccessCards.SuspendAsync("0xc4rd1d");
Console.WriteLine("Card suspended successfully");
}
import com.organization.accessgrid.AccessGridClient;
public class AccessCardService {
private final AccessGridClient client;
public AccessCardService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public void suspendCard() throws AccessGridException {
client.accessCards().suspend("0xc4rd1d");
System.out.println("Card suspended successfully");
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$client->accessCards->suspend([
'card_id' => '0xc4rd1d'
]);
echo "Card suspended successfully\n";
Resume NFC key
If you have previously suspended an NFC key, you can re-enable it with the resume action
Unique identifier of the NFC key to resume, sent as part of the URL
# Base64 encode the JSON
JSON='{ "card_id": "0xc4rd1d" }'
JSON_B64=$(echo $JSON | base64)
# Add salt and hash
HASH=$(echo -n "$SHARED_SECRET$JSON_B64" | openssl sha256 | awk '{print $2}')
curl -v \
-X POST \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
-d '{
"card_id": "0xc4rd1d"
}' \
"https://api.accessgrid.com/v1/key-cards/{card_id}/suspend"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
card = client.access_cards.resume(
card_id: "0xc4rd1d"
)
puts "Card resumed successfully"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const resume = async () => {
try {
await client.accessCards.resume({
cardId: "0xc4rd1d"
});
console.log('Card resumed successfully');
} catch (error) {
console.error('Error resuming NFC key:', error);
}
};
resume();
from accessgrid import AccessGrid
import os
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
card = client.access_cards.resume(
card_id="0xc4rd1d"
)
print("Card resumed successfully")
package main
import (
"fmt"
"os"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
err = client.AccessCards.Resume("0xc4rd1d")
if err != nil {
fmt.Printf("Error resuming card: %v\n", err)
return
}
fmt.Println("Card resumed successfully")
}
using AccessGrid;
public async Task ResumeCardAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
await client.AccessCards.ResumeAsync("0xc4rd1d");
Console.WriteLine("Card resumed successfully");
}
import com.organization.accessgrid.AccessGridClient;
public class AccessCardService {
private final AccessGridClient client;
public AccessCardService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public void resumeCard() throws AccessGridException {
client.accessCards().resume("0xc4rd1d");
System.out.println("Card resumed successfully");
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$client->accessCards->resume([
'card_id' => '0xc4rd1d'
]);
echo "Card resumed successfully\n";
Unlink NFC key
If you'd like to force the removal of an NFC key from it's current holder
Unique identifier of the NFC key to unlink from its current holder, sent as part of the URL
# Base64 encode the JSON
JSON='{ "card_id": "0xc4rd1d" }'
JSON_B64=$(echo $JSON | base64)
# Add salt and hash
HASH=$(echo -n "$SHARED_SECRET$JSON_B64" | openssl sha256 | awk '{print $2}')
curl -v \
-X POST \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
-d '{
"card_id": "0xc4rd1d"
}' \
"https://api.accessgrid.com/v1/key-cards/{card_id}/suspend"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
card = client.access_cards.unlink(
card_id: "0xc4rd1d"
)
puts "Card unlinked successfully"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const unlink = async () => {
try {
await client.accessCards.unlink({
cardId: "0xc4rd1d"
});
console.log('Card unlinked successfully');
} catch (error) {
console.error('Error unlinking NFC key:', error);
}
};
unlink();
from accessgrid import AccessGrid
import os
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
card = client.access_cards.unlink(
card_id="0xc4rd1d"
)
print("Card unlinked successfully")
package main
import (
"fmt"
"os"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
err = client.AccessCards.Unlink("0xc4rd1d")
if err != nil {
fmt.Printf("Error unlinking card: %v\n", err)
return
}
fmt.Println("Card unlinked successfully")
}
using AccessGrid;
public async Task UnlinkCardAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
await client.AccessCards.UnlinkAsync("0xc4rd1d");
Console.WriteLine("Card unlinked successfully");
}
import com.organization.accessgrid.AccessGridClient;
public class AccessCardService {
private final AccessGridClient client;
public AccessCardService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public void unlinkCard() throws AccessGridException {
client.accessCards().unlink("0xc4rd1d");
System.out.println("Card unlinked successfully");
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$client->accessCards->unlink([
'card_id' => '0xc4rd1d'
]);
echo "Card unlinked successfully\n";
Only available for enterprise customers - allows you to create an empty card template using our console API.
The name to display for this card template in the AccessGrid console UI
Must be one of `apple` or `google`
Must be `desfire` or `seos` - HID Seos only available for enterprise customers
allow_on_multiple_devices
nullable boolean
False by default. Set to true if you'd like to enable the NFC keys issued using this template to exist on multiple devices (think phone and watch)
watch_count
nullable integer
Only allowed to be set if `allow_on_multiple_devices` is set to true. Any number between 1-5 is acceptable.
iphone_count
nullable integer
Only allowed to be set if `allow_on_multiple_devices` is set to true. Any number between 1-5 is acceptable.
Object representing card template design
Child attributes
background_color
nullable string
Must be a 6 character hexadecimal value for the background color of the template, in the event that there is no background_image provided, i.e. #FFFFFF
label_color
nullable string
Must be a 6 character hexadecimal value for the label color for the template, i.e. #000000
label_secondary_color
nullable string
Must be a 6 character hexadecimal value for the secondary label color for the template, i.e. #333333
background_image
nullable string
Base64 encoded image of the card templates background
logo_image
nullable string
Base64 encoded image of the card templates logo (located in the top left)
icon_image
nullable string
Base64 encoded image of the card templates icon (used in sharing and notifications)
support_info
nullable object
Information for users that shows up on the back of the NFC key
Child attributes
support_url
nullable string
Shows on the back of the issued NFC key.
support_phone_number
nullable string
Shows on the back of the issued NFC key.
support_email
nullable string
Shows on the back of the issued NFC key.
privacy_policy_url
nullable string
Shows on the back of the issued NFC key.
terms_and_conditions_url
nullable string
Shows on the back of the issued NFC key.
curl -v \
-X POST \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
-d '{
"name": "Employee NFC key",
"platform": "apple",
"use_case": "employee_badge",
"protocol": "desfire",
"allow_on_multiple_devices": true,
"watch_count": 2,
"iphone_count": 3,
"design": {
"background_color": "#FFFFFF",
"label_color": "#000000",
"label_secondary_color": "#333333",
"background_image": "[image_in_base64_encoded_format]",
"logo_image": "[image_in_base64_encoded_format]",
"icon_image": "[image_in_base64_encoded_format]"
},
"support_info": {
"support_url": "https://help.yourcompany.com",
"support_phone_number": "+1-555-123-4567",
"support_email": "[email protected] ",
"privacy_policy_url": "https://yourcompany.com/privacy",
"terms_and_conditions_url": "https://yourcompany.com/terms"
}
}' \
"https://api.accessgrid.com/v1/console/card-templates/"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
template = client.console.create_template(
name: "Employee NFC key",
platform: "apple",
use_case: "employee_badge",
protocol: "desfire",
allow_on_multiple_devices: true,
watch_count: 2,
iphone_count: 3,
design: {
background_color: "#FFFFFF",
label_color: "#000000",
label_secondary_color: "#333333",
background_image: "[image_in_base64_encoded_format]",
logo_image: "[image_in_base64_encoded_format]",
icon_image: "[image_in_base64_encoded_format]"
},
support_info: {
support_url: "https://help.yourcompany.com",
support_phone_number: "+1-555-123-4567",
support_email: "[email protected] ",
privacy_policy_url: "https://yourcompany.com/privacy",
terms_and_conditions_url: "https://yourcompany.com/terms"
}
)
puts "Template created successfully: #{template.id}"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const createTemplate = async () => {
try {
const template = await client.console.createTemplate({
name: "Employee NFC key",
platform: "apple",
useCase: "employee_badge",
protocol: "desfire",
allowOnMultipleDevices: true,
watchCount: 2,
iphoneCount: 3,
design: {
backgroundColor: "#FFFFFF",
labelColor: "#000000",
labelSecondaryColor: "#333333",
backgroundImage: "[image_in_base64_encoded_format]",
logoImage: "[image_in_base64_encoded_format]",
iconImage: "[image_in_base64_encoded_format]"
},
supportInfo: {
supportUrl: "https://help.yourcompany.com",
supportPhoneNumber: "+1-555-123-4567",
supportEmail: "[email protected] ",
privacyPolicyUrl: "https://yourcompany.com/privacy",
termsAndConditionsUrl: "https://yourcompany.com/terms"
}
});
console.log(`Template created successfully: ${template.id}`);
} catch (error) {
console.error('Error creating template:', error);
}
};
createTemplate();
from accessgrid import AccessGrid
import os
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
template = client.console.create_template(
name="Employee NFC key",
platform="apple",
use_case="employee_badge",
protocol="desfire",
allow_on_multiple_devices=True,
watch_count=2,
iphone_count=3,
design={
"background_color": "#FFFFFF",
"label_color": "#000000",
"label_secondary_color": "#333333",
"background_image": "[image_in_base64_encoded_format]",
"logo_image": "[image_in_base64_encoded_format]",
"icon_image": "[image_in_base64_encoded_format]"
},
support_info={
"support_url": "https://help.yourcompany.com",
"support_phone_number": "+1-555-123-4567",
"support_email": "[email protected] ",
"privacy_policy_url": "https://yourcompany.com/privacy",
"terms_and_conditions_url": "https://yourcompany.com/terms"
}
)
print(f"Template created successfully: {template.id}")
package main
import (
"fmt"
"os"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
design := accessgrid.TemplateDesign{
BackgroundColor: "#FFFFFF",
LabelColor: "#000000",
LabelSecondaryColor: "#333333",
BackgroundImage: "[image_in_base64_encoded_format]",
LogoImage: "[image_in_base64_encoded_format]",
IconImage: "[image_in_base64_encoded_format]",
}
supportInfo := accessgrid.SupportInfo{
SupportURL: "https://help.yourcompany.com",
SupportPhoneNumber: "+1-555-123-4567",
SupportEmail: "[email protected] ",
PrivacyPolicyURL: "https://yourcompany.com/privacy",
TermsAndConditionsURL: "https://yourcompany.com/terms",
}
params := accessgrid.CreateTemplateParams{
Name: "Employee NFC key",
Platform: "apple",
UseCase: "employee_badge",
Protocol: "desfire",
AllowOnMultipleDevices: true,
WatchCount: 2,
IPhoneCount: 3,
Design: design,
SupportInfo: supportInfo,
}
template, err := client.Console.CreateTemplate(params)
if err != nil {
fmt.Printf("Error creating template: %v\n", err)
return
}
fmt.Printf("Template created successfully: %s\n", template.ID)
}
using AccessGrid;
public async Task CreateTemplateAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
var template = await client.Console.CreateTemplateAsync(new CreateTemplateRequest
{
Name = "Employee NFC key",
Platform = "apple",
UseCase = "employee_badge",
Protocol = "desfire",
AllowOnMultipleDevices = true,
WatchCount = 2,
IPhoneCount = 3,
Design = new TemplateDesign
{
BackgroundColor = "#FFFFFF",
LabelColor = "#000000",
LabelSecondaryColor = "#333333",
BackgroundImage = "[image_in_base64_encoded_format]",
LogoImage = "[image_in_base64_encoded_format]",
IconImage = "[image_in_base64_encoded_format]"
},
SupportInfo = new SupportInfo
{
SupportUrl = "https://help.yourcompany.com",
SupportPhoneNumber = "+1-555-123-4567",
SupportEmail = "[email protected] ",
PrivacyPolicyUrl = "https://yourcompany.com/privacy",
TermsAndConditionsUrl = "https://yourcompany.com/terms"
}
});
Console.WriteLine($"Template created successfully: {template.Id}");
}
import com.organization.accessgrid.AccessGridClient;
import com.organization.accessgrid.model.CreateTemplateRequest;
import com.organization.accessgrid.model.Template;
import com.organization.accessgrid.model.TemplateDesign;
import com.organization.accessgrid.model.SupportInfo;
public class ConsoleService {
private final AccessGridClient client;
public ConsoleService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public Template createTemplate() throws AccessGridException {
TemplateDesign design = TemplateDesign.builder()
.backgroundColor("#FFFFFF")
.labelColor("#000000")
.labelSecondaryColor("#333333")
.backgroundImage("[image_in_base64_encoded_format]")
.logoImage("[image_in_base64_encoded_format]")
.iconImage("[image_in_base64_encoded_format]")
.build();
SupportInfo supportInfo = SupportInfo.builder()
.supportUrl("https://help.yourcompany.com")
.supportPhoneNumber("+1-555-123-4567")
.supportEmail("[email protected] ")
.privacyPolicyUrl("https://yourcompany.com/privacy")
.termsAndConditionsUrl("https://yourcompany.com/terms")
.build();
CreateTemplateRequest request = CreateTemplateRequest.builder()
.name("Employee NFC key")
.platform("apple")
.useCase("employee_badge")
.protocol("desfire")
.allowOnMultipleDevices(true)
.watchCount(2)
.iphoneCount(3)
.design(design)
.supportInfo(supportInfo)
.build();
Template template = client.console().createTemplate(request);
System.out.printf("Template created successfully: %s%n", template.getId());
return template;
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$template = $client->console->createTemplate([
'name' => 'Employee NFC key',
'platform' => 'apple',
'use_case' => 'employee_badge',
'protocol' => 'desfire',
'allow_on_multiple_devices' => true,
'watch_count' => 2,
'iphone_count' => 3,
'design' => [
'background_color' => '#FFFFFF',
'label_color' => '#000000',
'label_secondary_color' => '#333333',
'background_image' => '[image_in_base64_encoded_format]',
'logo_image' => '[image_in_base64_encoded_format]',
'icon_image' => '[image_in_base64_encoded_format]'
],
'support_info' => [
'support_url' => 'https://help.yourcompany.com',
'support_phone_number' => '+1-555-123-4567',
'support_email' => '[email protected] ',
'privacy_policy_url' => 'https://yourcompany.com/privacy',
'terms_and_conditions_url' => 'https://yourcompany.com/terms'
]
]);
echo "Template created successfully: {$template->id}\n";
Only available for enterprise customers - allows you to update certain attributes of an existing card template using our console API.
The card template id you want to update
The name to display for this card template in the AccessGrid console UI
allow_on_multiple_devices
nullable boolean
False by default. Set to true if you'd like to enable the NFC keys issued using this template to exist on multiple devices (think phone and watch)
watch_count
nullable integer
Only allowed to be set if `allow_on_multiple_devices` is set to true. Any number between 1-5 is acceptable.
iphone_count
nullable integer
Only allowed to be set if `allow_on_multiple_devices` is set to true. Any number between 1-5 is acceptable.
support_info
nullable object
Information for users that shows up on the back of the NFC key
Child attributes
support_url
nullable string
Shows on the back of the issued NFC key.
support_phone_number
nullable string
Shows on the back of the issued NFC key.
support_email
nullable string
Shows on the back of the issued NFC key.
privacy_policy_url
nullable string
Shows on the back of the issued NFC key.
terms_and_conditions_url
nullable string
Shows on the back of the issued NFC key.
curl -v \
-X PATCH \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
-d '{
"card_template_id": "0xd3adb00b5",
"name": "Updated Employee NFC key",
"allow_on_multiple_devices": true,
"watch_count": 2,
"iphone_count": 3,
"support_info": {
"support_url": "https://help.yourcompany.com",
"support_phone_number": "+1-555-123-4567",
"support_email": "[email protected] ",
"privacy_policy_url": "https://yourcompany.com/privacy",
"terms_and_conditions_url": "https://yourcompany.com/terms"
}
}' \
"https://api.accessgrid.com/v1/console/card-templates/{template_id}"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
template = client.console.update_template(
card_template_id: "0xd3adb00b5",
name: "Updated Employee NFC key",
allow_on_multiple_devices: true,
watch_count: 2,
iphone_count: 3,
support_info: {
support_url: "https://help.yourcompany.com",
support_phone_number: "+1-555-123-4567",
support_email: "[email protected] ",
privacy_policy_url: "https://yourcompany.com/privacy",
terms_and_conditions_url: "https://yourcompany.com/terms"
}
)
puts "Template updated successfully: #{template.id}"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const updateTemplate = async () => {
try {
const template = await client.console.updateTemplate({
cardTemplateId: "0xd3adb00b5",
name: "Updated Employee NFC key",
allowOnMultipleDevices: true,
watchCount: 2,
iphoneCount: 3,
supportInfo: {
supportUrl: "https://help.yourcompany.com",
supportPhoneNumber: "+1-555-123-4567",
supportEmail: "[email protected] ",
privacyPolicyUrl: "https://yourcompany.com/privacy",
termsAndConditionsUrl: "https://yourcompany.com/terms"
}
});
console.log(`Template updated successfully: ${template.id}`);
} catch (error) {
console.error('Error updating template:', error);
}
};
updateTemplate();
from accessgrid import AccessGrid
import os
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
template = client.console.update_template(
card_template_id="0xd3adb00b5",
name="Updated Employee NFC key",
allow_on_multiple_devices=True,
watch_count=2,
iphone_count=3,
support_info={
"support_url": "https://help.yourcompany.com",
"support_phone_number": "+1-555-123-4567",
"support_email": "[email protected] ",
"privacy_policy_url": "https://yourcompany.com/privacy",
"terms_and_conditions_url": "https://yourcompany.com/terms"
}
)
print(f"Template updated successfully: {template.id}")
package main
import (
"fmt"
"os"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
supportInfo := accessgrid.SupportInfo{
SupportURL: "https://help.yourcompany.com",
SupportPhoneNumber: "+1-555-123-4567",
SupportEmail: "[email protected] ",
PrivacyPolicyURL: "https://yourcompany.com/privacy",
TermsAndConditionsURL: "https://yourcompany.com/terms",
}
params := accessgrid.UpdateTemplateParams{
CardTemplateID: "0xd3adb00b5",
Name: "Updated Employee NFC key",
AllowOnMultipleDevices: true,
WatchCount: 2,
IPhoneCount: 3,
SupportInfo: supportInfo,
}
template, err := client.Console.UpdateTemplate(params)
if err != nil {
fmt.Printf("Error updating template: %v\n", err)
return
}
fmt.Printf("Template updated successfully: %s\n", template.ID)
}
using AccessGrid;
public async Task UpdateTemplateAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
var template = await client.Console.UpdateTemplateAsync(
new UpdateTemplateRequest
{
CardTemplateId = "0xd3adb00b5",
Name = "Updated Employee NFC key",
AllowOnMultipleDevices = true,
WatchCount = 2,
IPhoneCount = 3,
SupportInfo = new SupportInfo
{
SupportUrl = "https://help.yourcompany.com",
SupportPhoneNumber = "+1-555-123-4567",
SupportEmail = "[email protected] ",
PrivacyPolicyUrl = "https://yourcompany.com/privacy",
TermsAndConditionsUrl = "https://yourcompany.com/terms"
}
}
);
Console.WriteLine($"Template updated successfully: {template.Id}");
}
import com.organization.accessgrid.AccessGridClient;
import com.organization.accessgrid.model.UpdateTemplateRequest;
import com.organization.accessgrid.model.Template;
import com.organization.accessgrid.model.SupportInfo;
public class ConsoleService {
private final AccessGridClient client;
public ConsoleService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public Template updateTemplate() throws AccessGridException {
SupportInfo supportInfo = SupportInfo.builder()
.supportUrl("https://help.yourcompany.com")
.supportPhoneNumber("+1-555-123-4567")
.supportEmail("[email protected] ")
.privacyPolicyUrl("https://yourcompany.com/privacy")
.termsAndConditionsUrl("https://yourcompany.com/terms")
.build();
UpdateTemplateRequest request = UpdateTemplateRequest.builder()
.cardTemplateId("0xd3adb00b5")
.name("Updated Employee NFC key")
.allowOnMultipleDevices(true)
.watchCount(2)
.iphoneCount(3)
.supportInfo(supportInfo)
.build();
Template template = client.console().updateTemplate(request);
System.out.printf("Template updated successfully: %s%n", template.getId());
return template;
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$template = $client->console->updateTemplate([
'card_template_id' => '0xd3adb00b5',
'name' => 'Updated Employee NFC key',
'allow_on_multiple_devices' => true,
'watch_count' => 2,
'iphone_count' => 3,
'support_info' => [
'support_url' => 'https://help.yourcompany.com',
'support_phone_number' => '+1-555-123-4567',
'support_email' => '[email protected] ',
'privacy_policy_url' => 'https://yourcompany.com/privacy',
'terms_and_conditions_url' => 'https://yourcompany.com/terms'
]
]);
echo "Template updated successfully: {$template->id}\n";
Only available for enterprise customers - allows you to read basic info about an existing card template using our console API.
card_template_id
nullable string
Unique identifier for the card template to look up
curl -v \
-X GET \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
"https://api.accessgrid.com/v1/console/card-templates/{template_id}"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
template = client.console.read_template(
card_template_id: "0xd3adb00b5"
)
puts "Template ID: #{template.id}"
puts "Name: #{template.name}"
puts "Platform: #{template.platform}"
puts "Protocol: #{template.protocol}"
puts "Multi-device: #{template.allow_on_multiple_devices}"
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const readTemplate = async () => {
try {
const template = await client.console.readTemplate({
cardTemplateId: "0xd3adb00b5"
});
console.log(`Template ID: ${template.id}`);
console.log(`Name: ${template.name}`);
console.log(`Platform: ${template.platform}`);
console.log(`Protocol: ${template.protocol}`);
console.log(`Multi-device: ${template.allowOnMultipleDevices}`);
} catch (error) {
console.error('Error reading template:', error);
}
};
readTemplate();
from accessgrid import AccessGrid
import os
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
template = client.console.read_template(
card_template_id="0xd3adb00b5"
)
print(f"Template ID: {template.id}")
print(f"Name: {template.name}")
print(f"Platform: {template.platform}")
print(f"Protocol: {template.protocol}")
print(f"Multi-device: {template.allow_on_multiple_devices}")
package main
import (
"fmt"
"os"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
template, err := client.Console.ReadTemplate("0xd3adb00b5")
if err != nil {
fmt.Printf("Error reading template: %v\n", err)
return
}
fmt.Printf("Template ID: %s\n", template.ID)
fmt.Printf("Name: %s\n", template.Name)
fmt.Printf("Platform: %s\n", template.Platform)
fmt.Printf("Protocol: %s\n", template.Protocol)
fmt.Printf("Multi-device: %v\n", template.AllowOnMultipleDevices)
}
using AccessGrid;
public async Task ReadTemplateAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
var template = await client.Console.ReadTemplateAsync("0xd3adb00b5");
Console.WriteLine($"Template ID: {template.Id}");
Console.WriteLine($"Name: {template.Name}");
Console.WriteLine($"Platform: {template.Platform}");
Console.WriteLine($"Protocol: {template.Protocol}");
Console.WriteLine($"Multi-device: {template.AllowOnMultipleDevices}");
}
import com.organization.accessgrid.AccessGridClient;
import com.organization.accessgrid.model.Template;
public class ConsoleService {
private final AccessGridClient client;
public ConsoleService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public void readTemplate() throws AccessGridException {
Template template = client.console().readTemplate("0xd3adb00b5");
System.out.printf("Template ID: %s%n", template.getId());
System.out.printf("Name: %s%n", template.getName());
System.out.printf("Platform: %s%n", template.getPlatform());
System.out.printf("Protocol: %s%n", template.getProtocol());
System.out.printf("Multi-device: %b%n", template.getAllowOnMultipleDevices());
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$template = $client->console->readTemplate([
'card_template_id' => '0xd3adb00b5'
]);
echo "Template ID: {$template->id}\n";
echo "Name: {$template->name}\n";
echo "Platform: {$template->platform}\n";
echo "Protocol: {$template->protocol}\n";
echo "Multi-device: {$template->allow_on_multiple_devices}\n";
Only available for enterprise customers - allows you to read full event log for a given card template, including which passes were issued, how and by whom using our console API.
card_template_id
nullable string
Unique identifier for the card template to look up
Filters to reduce result size of event logs
Child attributes
Must be either `mobile` or `watch`
start_date
nullable datetime
Must be in ISO8601 format
end_date
nullable datetime
Must be in ISO8601 format
event_type
nullable string
Must be either `issue`, `install`, `update`, `suspend`, `resume`, or `unlink`
curl -v \
-X GET \
-H 'X-ACCT-ID: 123' \
-H "X-PAYLOAD-SIG: $HASH" \
"https://api.accessgrid.com/v1/console/card-templates/{template_id}/logs"
require 'accessgrid'
acct_id = ENV['ACCOUNT_ID']
secret_key = ENV['SECRET_KEY']
client = AccessGrid.new(acct_id, secret_key)
events = client.console.event_log(
card_template_id: "0xd3adb00b5",
filters: {
device: "mobile",
start_date: "2024-11-22T17:46:33.692Z",
end_date: "2024-12-22T17:46:33.692Z",
event_type: "install"
}
)
events.each do |event|
puts "Event: #{event.type} at #{event.timestamp} by #{event.user_id}"
end
import AccessGrid from 'accessgrid';
const accountId = process.env.ACCOUNT_ID;
const secretKey = process.env.SECRET_KEY;
const client = new AccessGrid(accountId, secretKey);
const getEventLog = async () => {
try {
const events = await client.console.eventLog({
cardTemplateId: "0xd3adb00b5",
filters: {
device: "mobile",
startDate: new Date(Date.now() - 30 * 24 * 60 * 60 * 1000).toISOString(),
endDate: new Date().toISOString(),
eventType: "install"
}
});
events.forEach(event => {
console.log(`Event: ${event.type} at ${event.timestamp} by ${event.userId}`);
});
} catch (error) {
console.error('Error fetching event log:', error);
}
};
getEventLog();
from accessgrid import AccessGrid
import os
from datetime import datetime, timezone, timedelta
account_id = os.getenv('ACCOUNT_ID')
secret_key = os.getenv('SECRET_KEY')
client = AccessGrid(account_id, secret_key)
start_date = (datetime.now(timezone.utc) - timedelta(days=30)).isoformat()
end_date = datetime.now(timezone.utc).isoformat()
events = client.console.event_log(
card_template_id="0xd3adb00b5",
filters={
"device": "mobile",
"start_date": start_date,
"end_date": end_date,
"event_type": "install"
}
)
for event in events:
print(f"Event: {event.type} at {event.timestamp} by {event.user_id}")
package main
import (
"fmt"
"os"
"time"
"github.com/accessgrid/accessgrid-go"
)
func main() {
accountID := os.Getenv("ACCOUNT_ID")
secretKey := os.Getenv("SECRET_KEY")
client, err := accessgrid.NewClient(accountID, secretKey)
if err != nil {
fmt.Printf("Error creating client: %v\n", err)
return
}
filters := accessgrid.EventLogFilters{
Device: "mobile",
StartDate: time.Now().AddDate(0, 0, -30).UTC().Format(time.RFC3339),
EndDate: time.Now().UTC().Format(time.RFC3339),
EventType: "install",
}
events, err := client.Console.EventLog("0xd3adb00b5", filters)
if err != nil {
fmt.Printf("Error fetching event log: %v\n", err)
return
}
for _, event := range events {
fmt.Printf("Event: %s at %s by %s\n", event.Type, event.Timestamp, event.UserID)
}
}
using AccessGrid;
using System;
public async Task GetEventLogAsync()
{
var accountId = Environment.GetEnvironmentVariable("ACCOUNT_ID");
var secretKey = Environment.GetEnvironmentVariable("SECRET_KEY");
var client = new AccessGridClient(accountId, secretKey);
var events = await client.Console.EventLogAsync(
"0xd3adb00b5",
new EventLogFilters
{
Device = "mobile",
StartDate = DateTime.UtcNow.AddDays(-30),
EndDate = DateTime.UtcNow,
EventType = "install"
});
foreach (var evt in events)
{
Console.WriteLine($"Event: {evt.Type} at {evt.Timestamp} by {evt.UserId}");
}
}
import com.organization.accessgrid.AccessGridClient;
import com.organization.accessgrid.model.Event;
import com.organization.accessgrid.model.EventLogFilters;
import java.time.ZonedDateTime;
import java.util.List;
public class ConsoleService {
private final AccessGridClient client;
public ConsoleService() {
String accountId = System.getenv("ACCOUNT_ID");
String secretKey = System.getenv("SECRET_KEY");
this.client = new AccessGridClient(accountId, secretKey);
}
public void getEventLog() throws AccessGridException {
EventLogFilters filters = EventLogFilters.builder()
.device("mobile")
.startDate(ZonedDateTime.now().minusDays(30))
.endDate(ZonedDateTime.now())
.eventType("install")
.build();
List<Event> events = client.console().eventLog("0xd3adb00b5", filters);
for (Event event : events) {
System.out.printf("Event: %s at %s by %s%n",
event.getType(),
event.getTimestamp(),
event.getUserId());
}
}
}
<?php
require 'vendor/autoload.php';
use AccessGridClient;
$accountId = $_ENV['ACCOUNT_ID'];
$secretKey = $_ENV['SECRET_KEY'];
$client = new Client($accountId, $secretKey);
$events = $client->console->eventLog([
'card_template_id' => '0xd3adb00b5',
'filters' => [
'device' => 'mobile',
'start_date' => (new DateTime('30 days ago'))->format('c'),
'end_date' => (new DateTime('now'))->format('c'),
'event_type' => 'install'
]
]);
foreach ($events as $event) {
echo "Event: {$event->type} at {$event->timestamp} by {$event->user_id}\n";
}