Skip to main content

Access Logs

Retrieve the complete access history for a policy.

Endpoint

GET /api/access-logs/{policyId}
Authorization: Bearer {token}

Parameters

ParameterTypeRequiredDescription
policyIdstringPolicy identifier

Response

Success (200)

{
  "success": true,
  "logs": [
    {
      "timestamp": "2025-02-22T10:30:00Z",
      "txHash": "0xabc...",
      "success": true,
      "blockNumber": 12345678
    },
    {
      "timestamp": "2025-02-22T11:15:00Z",
      "txHash": "0xdef...",
      "success": false,
      "error": "Policy expired"
    }
  ]
}

Log Entry Fields

FieldTypeDescription
timestampstringISO 8601 timestamp
txHashstringOn-chain transaction hash
successbooleanWhether access was granted
blockNumbernumberBlock containing transaction
errorstringError message (if failed)

Example Usage

async function getAccessLogs(policyId: string) {
  const response = await fetch(`/api/access-logs/${policyId}`, {
    headers: {
      'Authorization': `Bearer ${token}`,
    },
  });

  const data = await response.json();
  return data.logs;
}

// Usage
const logs = await getAccessLogs('0xabc...');
const successful = logs.filter(l => l.success);
console.log(`Accessed ${successful.length} times`);

Access Control

Only the sender or recipient of a policy can view its access logs.
{
  "error": "Unauthorized"
}

Rate Limits

LimitValue
Requests30 per minute

On-Chain Storage

Logs are stored on-chain via the logAttempt function. The API queries both:
  1. Blockchain events: VerificationAttempt events
  2. Database: Cached logs for performance

Data Retention

PlanRetention
Free30 days
Pro90 days
EnterpriseUnlimited