Skip to content

ApiKey Model

The API key object represents credentials for authenticating with the HEIR API.

Object Structure

json
{
  "_id": "65abc123def456ghi789",
  "name": "Production Key",
  "tier": "partner",
  "scopes": ["contracts", "webhooks", "embed"],
  "owner": "user_123abc",
  "status": "active",
  "usage": {
    "totalRequests": 15420,
    "lastUsed": "2024-01-15T10:30:00.000Z"
  },
  "metadata": {
    "ip_whitelist": ["203.0.113.10"],
    "webhook_url": "https://your-app.com/webhooks"
  },
  "expiresAt": "2024-12-31T23:59:59.000Z",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "updatedAt": "2024-01-15T10:30:00.000Z"
}

Properties

PropertyTypeDescription
_idstringUnique identifier
namestringHuman-readable name
tierstringpublic, partner, or internal
scopesarrayPermissions granted to this key
ownerstringUser ID who owns this key
statusstringactive, revoked, or expired
usageobjectUsage statistics
usage.totalRequestsnumberTotal API calls made
usage.lastUsedstringISO 8601 timestamp
metadataobjectAdditional configuration
metadata.ip_whitelistarrayAllowed IP addresses
metadata.webhook_urlstringDefault webhook URL
expiresAtstringISO 8601 expiration date
createdAtstringISO 8601 creation date
updatedAtstringISO 8601 last update date

Tiers

TierPrefixRate LimitFeatures
publicheir_pk_100/15minBasic API access
partnerheir_pt_1,000/15min+ Embedding, webhooks
internalheir_in_10,000/15min+ Admin features

Scopes

ScopeDescription
contractsGenerate and manage contracts
vaultsAccess vault information
usersUser management (admin only)
paymentsPayment processing
webhooksWebhook management
adminAdministrative operations
embedEmbeddable wizard access

Status Values

StatusDescription
activeKey is valid and usable
revokedKey has been manually revoked
expiredKey has passed its expiration date

Notes

  • The actual API key value (with prefix like heir_pk_xxx...) is only returned once when the key is created
  • Keys are stored as SHA-256 hashes internally
  • Revoked keys cannot be reactivated

Released under the MIT License.