Authentication

API key management and user authentication

User Login

post
/auth/login

Authenticate user and receive JWT token

Body
usernamestring · emailRequired

User's email address

Example: [email protected]
passwordstring · passwordRequired

User's password

Example: password
Responses
200

Login successful

application/json
post
/auth/login
POST /api/auth/login HTTP/1.1
Host: dev.granularregistry.com
Content-Type: application/x-www-form-urlencoded
Accept: */*
Content-Length: 51

"username='[email protected]'&password='password'"
{
  "access_token": "text",
  "token_type": "bearer",
  "user_id": 3
}

List API Keys

get
/auth/api-keys

Get all API keys for the current user

Authorizations
Responses
200

List of API keys

application/json
get
/auth/api-keys
GET /api/auth/api-keys HTTP/1.1
Host: dev.granularregistry.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*
[
  {
    "id": 1,
    "key_name": "Clean Incentive Marketplace Integration",
    "key_prefix": "gcreg_2f",
    "scopes": "read",
    "rate_limit": 1000,
    "is_active": true,
    "last_used": "2024-01-01T14:30:00Z",
    "expires_at": "2025-10-20T11:45:48.640Z",
    "created_at": "2024-01-01T13:10:00Z"
  }
]

Create API Key

post
/auth/api-keys

Create a new API key for external integrations

Authorizations
Body
key_namestringRequired

Human-readable name for the API key

Example: Clean Incentive Marketplace Integration
scopesstring · enumOptional

Comma-separated scopes

Default: readExample: readPossible values:
rate_limitintegerOptional

Hourly rate limit for this key

Default: 1000Example: 1000
expires_atstring · date-time | nullableOptional

When the key expires (optional)

Responses
201

API key created successfully

application/json
post
/auth/api-keys
POST /api/auth/api-keys HTTP/1.1
Host: dev.granularregistry.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 128

{
  "key_name": "Clean Incentive Marketplace Integration",
  "scopes": "read",
  "rate_limit": 1000,
  "expires_at": "2025-10-20T11:45:48.640Z"
}
{
  "id": 1,
  "key_name": "Clean Incentive Marketplace Integration",
  "key_prefix": "gcreg_2f",
  "api_key": "gcreg_2fCeA78CA62644eB55B0A36249245A27",
  "scopes": "read",
  "rate_limit": 1000,
  "expires_at": "2025-10-20T11:45:48.640Z",
  "created_at": "2024-01-01T13:10:00Z"
}

Delete API Key

delete
/auth/api-keys/{api_key_id}

Delete an existing API key

Authorizations
Path parameters
api_key_idintegerRequired

API key ID to delete

Example: 1
Responses
204

API key deleted successfully

No content

delete
/auth/api-keys/{api_key_id}
DELETE /api/auth/api-keys/{api_key_id} HTTP/1.1
Host: dev.granularregistry.com
Authorization: Bearer YOUR_SECRET_TOKEN
Accept: */*

No content

Update API Key

patch
/auth/api-keys/{api_key_id}

Update an existing API key's properties

Authorizations
Path parameters
api_key_idintegerRequired

API key ID to update

Example: 1
Body
key_namestringOptionalExample: Updated Marketplace Integration
is_activebooleanOptionalExample: true
rate_limitintegerOptionalExample: 2000
expires_atstring · date-time | nullableOptional
Responses
200

API key updated successfully

application/json
patch
/auth/api-keys/{api_key_id}
PATCH /api/auth/api-keys/{api_key_id} HTTP/1.1
Host: dev.granularregistry.com
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 121

{
  "key_name": "Updated Marketplace Integration",
  "is_active": true,
  "rate_limit": 2000,
  "expires_at": "2025-10-20T11:45:48.640Z"
}
{
  "id": 1,
  "key_name": "Clean Incentive Marketplace Integration",
  "key_prefix": "gcreg_2f",
  "scopes": "read",
  "rate_limit": 1000,
  "is_active": true,
  "last_used": "2024-01-01T14:30:00Z",
  "expires_at": "2025-10-20T11:45:48.640Z",
  "created_at": "2024-01-01T13:10:00Z"
}

Was this helpful?