# API Documentation

Everything you need to interact with AccessGrid.

## Supported Languages

- Terminal
- JavaScript
- Ruby
- GO
- Python
- C#
- Java
- PHP
- Elixir

## List Credential Profiles

Enterprise only. Only available for enterprise customers. Returns all credential profiles for the authenticated account.

### Request

```
# Build the JSON payload
PAYLOAD="{}"

# Sign the payload
PAYLOAD_B64=$(printf '%s' "$PAYLOAD" | openssl base64 -A)
SIG=$(printf '%s' "$PAYLOAD_B64" | openssl dgst -sha256 -hmac "$SECRET_KEY" -hex | awk '{print $NF}')

# Send curl request
curl -G \
-H "X-ACCT-ID: $ACCOUNT_ID" \
-H "X-PAYLOAD-SIG: $SIG" \
--data-urlencode "sig_payload=$PAYLOAD" \
"https://api.accessgrid.com/v1/console/credential-profiles"
```

**Response Example**:
```json
[
    {
        "id": "a1b2c3d4e5f",
        "aid": "F56401",
        "name": "Main Office Profile",
        "apple_id": "desfire_accessgrid_v1",
        "created_at": "2025-01-15T12:00:00Z",
        "card_storage": "4K EV1",
        "keys": [
            {"ex_id": "00", "label": "Master", "keys_diversified": null, "source_key_index": null},
            {"ex_id": "01", "label": "Generic / Read", "keys_diversified": null, "source_key_index": null}
        ],
        "files": [
            {"ex_id": "00", "file_type": "standard", "file_size": null, "communication_settings": "encrypted_with_mac", "read_rights": "read", "write_rights": "master", "read_write_rights": "master", "change_rights": "no-keys"}
        ]
    },
    {
        "id": "f6e5d4c3b2a",
        "aid": "ACCE55",
        "name": "Warehouse Profile",
        "apple_id": "accessgrid_kdf_desfire_v1",
        "created_at": "2025-02-20T09:30:00Z",
        "card_storage": "4K EV1",
        "keys": [
            {"ex_id": "00", "label": "Master", "keys_diversified": false, "source_key_index": null},
            {"ex_id": "01", "label": "Generic / Read", "keys_diversified": true, "source_key_index": 0},
            {"ex_id": "02", "label": "Privacy", "keys_diversified": true, "source_key_index": 0}
        ],
        "files": [
            {"ex_id": "00", "file_type": "standard", "file_size": null, "communication_settings": "encrypted_with_mac", "read_rights": "read", "write_rights": "master", "read_write_rights": "master", "change_rights": "no-keys"}
        ]
    }
]
```

## Create Credential Profile

Enterprise only. Only available for enterprise customers. Creates a new credential profile with DESFire keys for the authenticated account.

### Request

```
# Build the JSON payload
PAYLOAD=$(cat <<EOF
{
    "name": "Main Office Profile",
    "app_name": "KEY-ID-main",
    "keys": [
        {"value": "your_32_char_hex_master_key_here"},
        {"value": "your_32_char_hex__read_key__here"}
    ]
}
EOF)

# Send curl request
curl -X POST \
-H "X-ACCT-ID: $ACCOUNT_ID" \
-H "X-PAYLOAD-SIG: $SIG" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" \
"https://api.accessgrid.com/v1/console/credential-profiles"
```

**Response Example**:
```json
{
    "id": "a1b2c3d4e5f",
    "aid": "F56401",
    "name": "Main Office Profile",
    "apple_id": "desfire_accessgrid_v1",
    "created_at": "2025-01-15T12:00:00Z",
    "card_storage": "4K EV1",
    "keys": [
        {"ex_id": "00", "label": "Master", "keys_diversified": null, "source_key_index": null},
        {"ex_id": "01", "label": "Generic / Read", "keys_diversified": null, "source_key_index": null}
    ],
    "files": [
        {"ex_id": "00", "file_type": "standard", "file_size": null, "communication_settings": "encrypted_with_mac", "read_rights": "read", "write_rights": "master", "read_write_rights": "master", "change_rights": "no-keys"}
    ]
}
```

## Delete Credential Profile

Enterprise only. Only available for enterprise customers - soft-deletes a credential profile.

### Request

```
# Build the JSON payload
PROFILE_ID="a1b2c3d4e5f"
PAYLOAD="{\"credential_profile_id\":\"$PROFILE_ID\"}"

curl -X DELETE -G \
-H "X-ACCT-ID: $ACCOUNT_ID" \
-H "X-PAYLOAD-SIG: $SIG" \
--data-urlencode "sig_payload=$PAYLOAD" \
"https://api.accessgrid.com/v1/console/credential-profiles/$PROFILE_ID"
```

**Response Example**:
```json
{
    "id": "a1b2c3d4e5f",
    "deactivated": true
}
```
