# API Documentation

Everything you need to interact with AccessGrid.

## Create Card Template

**Enterprise only**  
Only available for enterprise customers - allows you to create an empty card template using our console API.

### Fields

#### name
- **Type:** string  
- **Description:** The name to display for this card template in the AccessGrid console UI

#### platform
- **Type:** string  
- **Description:** Must be one of `"apple"` or `"android"`

#### use_case
- **Type:** string  
- **Description:** Must be one of `"corporate_id"`, `"student_id"`, `"multi_family"`, `"hotel"`, `"member"`, or `"loyalty"`.

#### protocol
- **Type:** string  
- **Description:** Must be `"desfire"` (Apple), `"seos"` (HID - enterprise only; Apple or Android), `"smart_tap"` (Android), or `"qr"` (Apple or Android).

#### allow_on_multiple_devices
- **Type:** nullable boolean  
- **Default:** false  
- **Description:** Set to true if you'd like to enable the Access Passes issued using this template to exist on multiple devices (think phone and watch)

### Example Request
```json
{
  "name": "Employee Access Pass",
  "platform": "apple",
  "use_case": "corporate_id",
  "protocol": "desfire",
  "allow_on_multiple_devices": true,
  "watch_count": 2,
  "iphone_count": 3,
  "background_color": "#FFFFFF",
  "label_color": "#000000",
  "label_secondary_color": "#333333",
  "support_url": "https://help.yourcompany.com",
  "support_phone_number": "+1-555-123-4567",
  "support_email": "support@yourcompany.com",
  "privacy_policy_url": "https://yourcompany.com/privacy",
  "terms_and_conditions_url": "https://yourcompany.com/terms",
  "metadata": {
    "version": "2.1",
    "approval_status": "approved"
  }
}
```

### Response
```json
{
  "id": "tpl_0xd3adb00b5",
  "estimated_publishing_date": "2026-01-05T12:00:00Z",
  "images": {
    "logo": "https://example.com/rails/active_storage/blobs/logo.png",
    "background_image": "https://example.com/rails/active_storage/blobs/background.png",
    "icon": null,
    "member_photo": null
  },
  "metadata": {
    "version": "2.1",
    "approvalStatus": "approved"
  }
}
```

## Update Card Template

**Enterprise only**  
Only available for enterprise customers - allows you to update certain attributes of an existing card template using our console API.

### Fields

#### card_template_id
- **Type:** string  
- **Description:** The card template id you want to update

### Example Request
```json
{
  "card_template_id": "tpl_0xd3adb00b5",
  "name": "Updated Employee Access Pass",
  "allow_on_multiple_devices": true,
  "watch_count": 2,
  "iphone_count": 3,
  "background_color": "#FFFFFF",
  "label_color": "#000000",
  "label_secondary_color": "#333333",
  "support_url": "https://help.yourcompany.com",
  "support_phone_number": "+1-555-123-4567",
  "support_email": "support@yourcompany.com",
  "privacy_policy_url": "https://yourcompany.com/privacy",
  "terms_and_conditions_url": "https://yourcompany.com/terms",
  "metadata": {
    "version": "2.2",
    "last_updated_by": "admin"
  }
}
```

### Response
```json
{
  "id": "tpl_0xd3adb00b5",
  "estimated_publishing_date": "2026-01-05T12:00:00Z"
}
```

## Read Card Template

**Enterprise only**  
Only available for enterprise customers - allows you to read basic info about an existing card template using our console API.

### Example Request
```json
{
  "card_template_id": "0xd3adb00b5"
}
```

### Response
```json
{
  "id": "tpl_0xd3adb00b5",
  "name": "Employee Access Pass",
  "platform": "apple",
  "use_case": "corporate_id",
  "protocol": "desfire"
}
```

## Publish Card Template

**Enterprise only**  
Only available for enterprise customers - submits a card template for publishing.

### Example Request
```json
{
  "card_template_id": "0xd3adb00b5"
}
```

### Response
```json
{
  "id": "tpl_0xd3adb00b5",
  "status": "in-review"
}
```

## Delete Card Template

**Enterprise only**  
Only available for enterprise customers - soft-deletes a card template.

### Example Request
```json
{
  "card_template_id": "0xd3adb00b5"
}
```

### Response
```json
{
  "id": "tpl_0xd3adb00b5",
  "deactivated": true
}
```

## Reveal SmartTap Private Key

**Enterprise only**  
Only available for enterprise customers with a Google Wallet SmartTap template.

### Example Request
```json
{
  "card_template_id": "0xd3adb00b5",
  "client_public_key": "-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----"
}
```

### Response
```json
{
  "key_version": 42,
  "collector_id": 12345678,
  "fingerprint": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",
  "encrypted_private_key": {
    "alg": "ECDH-ES+A256GCM",
    "ephemeral_public_key": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE...\n-----END PUBLIC KEY-----\n",
    "iv": "gK7B5Jh1dQwHn2Qp",
    "ciphertext": "xS9hQ0aV0...base64...0r2k=",
    "tag": "4K7x3p9VYpAqY1Zc9C2nLw=="
  }
}
```
