Get Key Metadata
Returns masked metadata, lifecycle status, configured caps (perRequestCap, monthlySpendCap), expiration timestamp, and UTC calendar-month spend for the currently presented API key only.
Never exposes keyHash or the plaintext secret.
- cURL
- JavaScript (fetch)
- Python (requests)
- PHP
curl -sS -X GET "https://api.example.com/api/v1/key" \
-H "x-api-key: YOUR_API_KEY" \
-H "Accept: application/json"
const res = await fetch("https://api.example.com/api/v1/key", {
method: "GET",
headers: {
"x-api-key": process.env.GPKEYS_API_KEY ?? "YOUR_API_KEY",
Accept: "application/json",
},
});
if (!res.ok) {
const err = await res.json().catch(() => ({}));
throw new Error(`HTTP ${res.status}: ${JSON.stringify(err)}`);
}
const data = await res.json();
console.log(data);
import os
import requests
headers = {
"x-api-key": os.environ.get("GPKEYS_API_KEY", "YOUR_API_KEY"),
"Accept": "application/json",
}
resp = requests.get("https://api.example.com/api/v1/key", headers=headers, timeout=15)
resp.raise_for_status()
print(resp.json())
<?php
$apiKey = getenv('GPKEYS_API_KEY') ?: 'YOUR_API_KEY';
$ch = curl_init('https://api.example.com/api/v1/key');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15,
CURLOPT_HTTPHEADER => [
'x-api-key: ' . $apiKey,
'Accept: application/json',
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "HTTP {$status}\n" . ($body) . "\n";
Parameters & Headers
| Location | Name | Required | Description |
|---|---|---|---|
| Header | x-api-key | Conditional | Your customer API key (YOUR_API_KEY), or pass Authorization: Bearer YOUR_API_KEY. |
Success Response (200 OK)
{
"apiKey": {
"id": "key_mock_01",
"userId": "usr_mock_01",
"name": "Production Storefront",
"keyPrefix": "gpk_live_mock0001",
"lastFour": "0001",
"maskedKey": "gpk_live_mock0001...0001",
"status": "ACTIVE",
"monthlySpendCap": "250.000000",
"perRequestCap": "50.000000",
"monthlySpent": "12.000000",
"expiresAt": null,
"lastUsedAt": "2026-11-30T18:10:00.000Z",
"lastUsedIp": "127.0.0.1",
"disabledAt": null,
"revokedAt": null,
"revokedReason": null,
"createdAt": "2026-11-01T10:00:00.000Z",
"updatedAt": "2026-11-30T18:10:00.000Z"
}
}
Error Responses
| HTTP | error.code | Example Reason |
|---|---|---|
401 | UNAUTHORIZED | Missing/malformed, unknown, revoked, or expired key |
402 | INSUFFICIENT_BALANCE | Account balance negative |
403 | FORBIDDEN | Key disabled or owning user account suspended |
403 | FRAUD_DETECTED | IP blocked or multi-IP anomaly triggered |
429 | RATE_LIMITED | General per-key (60/min) or per-user (120/min) limit exceeded |
500 | INTERNAL_ERROR | Unexpected server error |
{
"error": {
"code": "UNAUTHORIZED",
"message": "API key has been revoked"
}
}