Skip to main content

Invalid Key Name

invalid_key_name422

Validation · Affects all endpoints

The API key name is empty or longer than 50 characters. Provide a name between 1 and 50 characters.

What this means

When creating a new API key, you can give it a human-readable name to help identify it later in the dashboard. The name field has length bounds: at least 1 character, at most 50. The value you supplied was either empty or too long. The key was not created.

When you'll see this

  • A form submitted an empty name field (no value or only whitespace).
  • A name longer than 50 characters was sent (often happens when generated names include long suffixes).
  • A name field was inadvertently set to a stringified object or array.
  • An automated key-rotation script used the calling timestamp as the name and exceeded length.
Learn more about how this works

Key names are display labels, not identifiers. The actual key ID is generated server-side; the name exists solely for human convenience in the dashboard. The 50-character limit keeps the dashboard list readable — longer names get truncated visually and lose their value as labels.

In practice: most occurrences of this error come from auto-generated names. If you're scripting key creation, use short, descriptive names like prod-web-2026-01 instead of automatically-rotated-production-web-application-key-2026-01-15-snapshot.

Example response

{
"success": false,
"error": "invalid_key_name",
"message": "Key name must be between 1 and 50 characters.",
"details": [],
"retry_after": null,
"doc_url": "https://docs.asterwise.com/reference/errors/invalid_key_name",
"request_id": "req_01HXYZABCDEFGH",
"timestamp": "2026-05-25T12:34:56Z"
}
NEW TO APIS?
Quick fix
  1. Use a name between 1 and 50 characters.
  2. Strip any leading or trailing whitespace before submission.
  3. If you're naming programmatically, pick a short pattern: environment + purpose + date, separated by hyphens.
PRODUCTION ENGINEER
Recovery pattern

Client-side validation is the right place for this — check the length before submitting.

Python:

Production handler

import httpx

def create_key(name, base_url, headers):
if not (1 <= len(name.strip()) <= 50):
raise ValueError("Key name must be 1-50 characters.")
response = httpx.post(
f"{base_url}/v1/keys",
headers=headers,
json={"name": name.strip()},
timeout=15,
)
response.raise_for_status()
return response.json()

Avoid this error by

  • Validate name length client-side before submission. Don't let users type past 50 characters in the input field.
  • For automated key creation, pick short consistent naming patterns: {env}-{service}-{date} is usually well under 50 characters.
  • Never use full timestamps in key names. 2026-05-25 is fine; 2026-05-25T13:45:22.123456Z-utc-prod-web-app is not.