API Keys API
API reference for managing API keys programmatically.
Generate, list, and revoke API keys via the API.
List API Keys
Section titled “List API Keys”GET /v1/api-keyscurl -X GET https://api.gopaylocal.com/v1/api-keys \ -H "Authorization: Bearer gpl_sk_live_xyz789"const res = await fetch('https://api.gopaylocal.com/v1/api-keys', { headers: { 'Authorization': 'Bearer gpl_sk_live_xyz789' },});const { data } = await res.json();Response:
{ "data": [ { "id": "key_abc123", "name": "Production Banner", "type": "public", "prefix": "gpl_pk_live_abc", "createdAt": "2025-01-15T10:30:00Z", "lastUsedAt": "2025-01-20T14:22:00Z" }, { "id": "key_def456", "name": "CI/CD Pipeline", "type": "secret", "prefix": "gpl_sk_live_def", "createdAt": "2025-01-15T10:30:00Z", "lastUsedAt": "2025-01-19T09:15:00Z" } ]}Generate API Key
Section titled “Generate API Key”POST /v1/api-keyscurl -X POST https://api.gopaylocal.com/v1/api-keys \ -H "Authorization: Bearer gpl_sk_live_xyz789" \ -H "Content-Type: application/json" \ -d '{ "name": "New Banner Key", "type": "public" }'const res = await fetch('https://api.gopaylocal.com/v1/api-keys', { method: 'POST', headers: { 'Authorization': 'Bearer gpl_sk_live_xyz789', 'Content-Type': 'application/json', }, body: JSON.stringify({ name: 'New Banner Key', type: 'public', }),});const { data } = await res.json();// data.key contains the full key — save it now, it won't be shown againRequest Body:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Descriptive name for the key |
type | string | Yes | "public" or "secret" |
Response: 201 Created
{ "data": { "id": "key_ghi789", "name": "New Banner Key", "type": "public", "key": "gpl_pk_live_abc123def456ghi789", "createdAt": "2025-01-20T15:00:00Z" }}Revoke API Key
Section titled “Revoke API Key”DELETE /v1/api-keys/:idcurl -X DELETE https://api.gopaylocal.com/v1/api-keys/key_abc123 \ -H "Authorization: Bearer gpl_sk_live_xyz789"await fetch('https://api.gopaylocal.com/v1/api-keys/key_abc123', { method: 'DELETE', headers: { 'Authorization': 'Bearer gpl_sk_live_xyz789' },});Response: 204 No Content
Revoked keys are immediately disabled. Any requests using a revoked key receive a 401 Unauthorized response.