← Blog

Claude API Authentication OAuth Setup Guide

2026-10-19 · 5 min read · SubToAPI Team

Does the Claude API Use OAuth?

Short answer: no, not for standard developer access. Anthropic's Claude API authenticates requests with a static API key sent in an x-api-key header (or Authorization: Bearer in some tooling), not an OAuth 2.0 authorization code flow. If you landed here expecting a /oauth/authorize endpoint and a redirect dance, that's the source of the confusion — Claude.ai (the consumer chat product) uses session-based login for humans, and separately Anthropic's enterprise console supports SSO for team management. Neither of those is the mechanism your code uses to call the API.

This guide covers both paths so you set up the right one: the native Anthropic API key flow for direct access, and the OAuth-style subscription bridge you need if you want to turn an existing Claude Pro/Max login into something your backend can call like a normal REST API.

Native Anthropic API Key Setup

If you're building directly against Anthropic's API, authentication is a one-time setup:

  1. Create an account at the Anthropic console and add billing.
  2. Generate an API key from the console dashboard.
  3. Store it as an environment variable — never hardcode it in source or commit it to version control.
  4. Send it on every request.
curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello Claude"}]
  }'

There's no refresh token, no client secret, no redirect URI. The key itself is the credential, and it doesn't expire on a schedule — you rotate it manually when needed. This is simpler than OAuth but puts more responsibility on you to guard the secret: treat it like a database password, scope it to a server-side environment, and never expose it in frontend JavaScript.

Where OAuth Actually Shows Up

There are two legitimate places OAuth-like flows exist around Claude:

The practical gap this leaves: if your team already pays for Claude Pro or Max subscriptions and wants to call Claude from code without provisioning a separate pay-per-token API account, there's no native Anthropic feature for that. Subscription access and API access are billed and authenticated differently by design.

Bridging Subscription Access to an API: The SubToAPI Flow

This is the actual setup most teams searching for "OAuth" end up needing. SubToAPI connects to your existing Claude access and exposes it as a standard HTTPS API with its own key format, so your app authenticates the normal way — a bearer token — regardless of what's happening behind the scenes with the subscription.

Setup looks like this:

  1. Sign up at /signup and connect your Claude account.
  2. SubToAPI issues an application API key in the format sub_live_... from your dashboard.
  3. Use that key as a standard Bearer token on every request to SubToAPI's endpoint.
curl https://api.subtoapi.app/v1/messages \
  -H "Authorization: Bearer $SUBTOAPI_KEY" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello Claude"}]
  }'
const res = await fetch("https://api.subtoapi.app/v1/messages", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SUBTOAPI_KEY}`,
    "content-type": "application/json",
  },
  body: JSON.stringify({
    model: "claude-sonnet-4-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello Claude" }],
  }),
});

No OAuth client registration, no scopes to configure, no redirect URIs to whitelist. The sub_live_ key is scoped to your account and visible in a dashboard alongside usage metadata per key, so you can see exactly which key made which call and revoke individual keys without touching others. Full request/response shapes are documented at /docs/messages, and streaming responses work the same way — see /docs/streaming if you're building a chat UI that needs token-by-token output.

Setting Up Keys for a Team

Whether you're on native Anthropic billing or a subscription bridge, the same key-hygiene rules apply when more than one person touches the credential:

If you're running a team, SubToAPI's Team plan gives each seat its own key and usage view, which matters more than it sounds — it's the difference between "someone's script is burning tokens" and "I know exactly which key and which seat is burning tokens."

Quick Checklist Before You Ship

If you're just getting started, the fastest path is the quickstart, which walks through the first authenticated call end to end, including tool use setup at /docs/tools if your use case needs function calling.

Questions

Does Claude API support OAuth 2.0 for application authentication? No. The standard Claude API uses static API keys sent via a header, not OAuth authorization flows. OAuth-style login exists for human access to Claude.ai and for enterprise SSO into the console, not for your application's API calls.

How do I authenticate if I only have a Claude Pro/Max subscription, not an API account? Anthropic doesn't offer a native way to call the API using subscription credentials. Services like SubToAPI bridge that gap by connecting to your existing access and issuing a standard bearer-token API key you can use in any HTTP client.

Is an API key as secure as OAuth tokens? Yes, if handled correctly — the risk profile is different, not worse. OAuth tokens expire and refresh automatically; API keys don't, so you're responsible for rotation, scoping per environment, and never exposing the key client-side.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →