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_here
Both the Full REST API and the MCP Server accept the same credentials and enforce the same rules.

Three Kinds of Credential

CredentialFormatScopeUse it for
Account API key (recommended)nb_u_...Every project in the account. The read-only switch blocks every write, including publishing, generation and billing links. Created at nextblog.ai/agents, shown once, revocable immediately.Agents, scripts and CI that work across several projects
Project API key (legacy)nb_...Exactly one project: its posts, integrations, connections and analytics, plus the owner's plan/credits and Stripe URLs. Shown in the project's Settings → API & Agents.Existing integrations and single-project embeds
OAuth 2.1 access tokenJWTThe whole account: every project, project create/delete, account key management, Search Console disconnect.GUI clients that complete a browser consent flow and cannot send custom headers — Claude, ChatGPT, Cursor, VS Code, Claude Code
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

  1. Open /agents and find Account API keys.
  2. Choose Create key, name it (for example Hermes agent) and decide whether it is read-only.
  3. 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:
  1. Log into your NextBlog dashboard
  2. Open your project → Settings → API & Agents
  3. Copy the key, or rotate it to create a new one (shown once)
  4. 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_key

Example Request

curl -H "Authorization: Bearer nb_u_your_account_api_key" \
  https://nextblog.ai/api/v1/projects/123/posts?limit=10
A 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=10

401 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