Getting StartedAPI Keys & Authentication
API Keys & Authentication
Complete developer guide for authenticating HTTP requests, handling API keys, and error handling.
The Niravai REST API uses API Keys to authenticate requests. You can manage your API keys from the Niravai Dashboard under Organization Settings.
Quick Reference
| Parameter | Type | In | Description |
|---|---|---|---|
x-api-key | string | Header | (Recommended) Your secret API Key (starts with STD_) |
Authorization | string | Header | Alternative authentication (Bearer STD_...) |
x-org-id | string | Header | (Optional) Target Organization ID (e.g. org_...) |
1. Generating an API Key
- Log in to the Niravai Dashboard.
- Navigate to Organization Settings -> API Keys (
/org/api-keys). - Click Create New API Key.
- Enter a descriptive name (e.g.,
Production Server Integration). - Copy your generated raw API Key string (format:
STD_...).
Keep your keys secret
Your API Key gives full access to your organization's resources and credits. Never expose API keys in client-side code, public GitHub repositories, or browser JavaScript.
2. Authentication Methods
Method 1: x-api-key
Pass your API key in the x-api-key request header:
Method 2: Authorization Bearer
Pass your API key as a standard Bearer token:
3. Response & Error Handling
The API returns standard HTTP status codes along with a consistent JSON error object.
Success Response (200 OK)
Missing API Key (401 Unauthorized)
Invalid API Key (401 Unauthorized)
Missing Org Context (400 Bad Request)
4. Security Checklist
- Environment Variables: Always store your key in
.env.localor secret management tools (process.env.NIRAVAI_API_KEY). - Server-Side Execution: Execute requests only from server environments (Node.js, Next.js Server Components, Python backends).
- Immediate Revocation: If a key is leaked or compromised, revoke it immediately from the API Keys management dashboard.