Skip to main content

POST /v1/account/keys

Create a new API key for the authenticated account.

  • Method: POST
  • Path: /v1/account/keys
  • Auth: Bearer token (provisioning key) in Authorization header
  • Content-Type: application/json
Store Securely

The API key is only shown once during creation. Store it securely as it cannot be retrieved again.

Request Parameters

  • name (string, required): Name for the API key (1-255 characters)
  • credit_limit (number, optional): Optional credit limit for the API key (minimum: 0)

Example Request

import requests

response = requests.post(
"https://api.naga.ac/v1/account/keys",
headers={
"Authorization": "Bearer YOUR_PROVISIONING_KEY",
"Content-Type": "application/json"
},
json={
"name": "New Production Key",
"credit_limit": 500.00
}
)

key_data = response.json()
print(f"New API Key: {key_data['key']}")
print(f"Key ID: {key_data['id']}")

Response

{
"id": 3,
"name": "New Production Key",
"key": "naga_sk_1234567890abcdef",
"created_at": "2025-01-20T15:45:00Z",
"is_enabled": true,
"credit_limit": 500.00,
"message": "Store this key securely. It will not be shown again."
}

Authentication

Provide your provisioning key as a Bearer token:

Authorization: Bearer YOUR_PROVISIONING_KEY

Response Fields

  • id (integer): Unique key identifier
  • name (string): Key name
  • key (string): The actual API key (only shown once)
  • created_at (string): ISO 8601 timestamp
  • is_enabled (boolean): Key status (always true for new keys)
  • credit_limit (number | null): Optional spending limit
  • message (string): Security reminder