← Blog

API Key vs OAuth: When to Use Each

Guides · July 1, 2026

API keys and OAuth both authenticate requests, but they answer different questions. A key asks whether this is a trusted caller. OAuth asks whether this user approved this app to act for them.

Use an API key when

For browser use, a scoped, domain-locked publishable key is the safe middle ground. It can do one narrow thing and nothing else.

Use OAuth when

How ContactAPI uses both

Secret and publishable keys authenticate the REST API. The MCP server uses OAuth 2.1, because there an AI client is acting on a user's behalf and should ask permission rather than hold a key. Same data, two auth models, each matched to the caller.

Where ContactAPI fits

ContactAPI is an open-source REST API for saving and managing contacts. You POST an email plus any JSON fields, get simple CRUD back, and can reach the same data from an AI client over its MCP server. No CRM, no pipeline stages, no lock-in.

Get an API key