API Authentication
AI agents & LLMs: read this documentation as Markdown at nextblog.ai/docs/authentication.md or browse the per-section Markdown index.
All API requests require a bearer credential. Three credentials work, and all are sent in the standard Authorization header:
Authorization: Bearer your_credential_hereBoth the Full REST API and the MCP Server accept the same credentials and enforce the same rules.
Three Kinds of Credential
An account key and OAuth both reach the whole account. A project key is deliberately bound to one project: an account-level call made with it fails with
403 ACCOUNT_SCOPE_REQUIRED— create or delete a project, rotate another project's key, disconnect Search Console. Use an account key or OAuth for those.Creating an Account API Key
- Open /agents and find Account API keys.
- Choose Create key, name it (for example
Hermes agent) and decide whether it is read-only. - Copy the secret (
nb_u_...) from the one-time dialog into your environment or secret manager.
The secret is shown once and cannot be retrieved later; if you lose it, revoke the key and create another. A read-only key can read every project, but publishing, generation, integration changes and billing links all answer
403 READ_ONLY_KEY. Revocation is immediate: the key stops working on the next request, unlike an OAuth access token, which stays valid until it expires (about an hour).Creating a Project API Key
To get a project's key:
- Log into your NextBlog dashboard
- Open your project → Settings → API & Agents
- Copy the key, or rotate it to create a new one (shown once)
- Keep this key secure and don't share it publicly
Every project has its own key. /agents lists all of them (masked), lets you rotate them and shows recent API/MCP activity.
Using Your API Key
Include your API key in the Authorization header using the Bearer token format:
Authorization: Bearer nb_u_your_account_api_keyExample Request
curl -H "Authorization: Bearer nb_u_your_account_api_key" \
https://nextblog.ai/api/v1/projects/123/posts?limit=10A project key works the same way for its one project:
curl -H "Authorization: Bearer nb_your_project_api_key" \
https://nextblog.ai/api/v1/projects/123/posts?limit=10401 Responses and Discovery
Unauthenticated requests return 401 with
WWW-Authenticate: Bearer resource_metadata="https://nextblog.ai/.well-known/oauth-protected-resource". The discovery document at https://nextblog.ai/.well-known/oauth-protected-resource is public and CORS-enabled, so MCP clients can start the OAuth flow automatically.Security Best Practices
- Never expose an API key in client-side code
- Use environment variables to store API keys
- Prefer a read-only account key for agents that only need to read
- Rotate project keys and revoke account keys from /agents
- Review connected agents and recent activity on /agents
- Monitor API usage for suspicious activity