Skip to content

POST /api/keys

Summary

Creates a new API key for a given customer and returns the raw key value.

Intent

Allows provisioning of new API keys tied to a customer identity, enabling access control and key management for downstream services.

Parameters

NameTypeRequiredDescription
customerIdstringYesThe identifier of the customer for whom the API key is being created.
namestringYesA human-readable label for the API key to help identify its purpose or owner.

Request example

Terminal window
curl -X POST https://maps.google.com//api/keys \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"customerId": "cust-abc123", "name": "Production Key"}'

Response example

{
"keyId": "e3d1c2b4-f5a6-7890-abcd-ef1234567890",
"key": "tb_live_3f2a1b4c5d6e7f8a9b0c1d2e",
"keyPrefix": "tb_live_3f2a",
"name": "Production Key",
"createdAt": "2024-01-15T10:30:00.000Z"
}

Error cases

  • 400 — Either customerId or name is missing from the request body

Gotchas

  • The raw key (the key field) is only returned once at creation time and is never stored in plaintext — only a SHA-256 hash is persisted. Save the key immediately; it cannot be retrieved again.
  • The keyPrefix field (first 12 characters, e.g. tb_live_XXXX) is stored and can be used later to identify a key without exposing the full secret.
  • All generated keys are prefixed with tb_live_ followed by 32 hex characters (16 random bytes). Keys are always 40 characters long.
  • The response status on success is 201 Created, not 200 OK — ensure your client handles this correctly.