---
title: "Authentication · Docs · SocialToAI"
canonical: https://socialtoai.app/docs/authentication/
updated: 2026-11-20
---

# Authentication

SocialToAI authenticates with an API key. Send it in the Authorization header on every call to the API or the MCP server. A key starts with stai_live_, is shown once when you create it, and is stored only as a hash, so it can never be shown again. ChatGPT, Claude, Claude Code, Codex and Cursor connect to the MCP server by signing in instead: there is no key to paste.

- Page: https://socialtoai.app/docs/authentication/
- Last updated: 2026-11-20

## Where the key goes

| Where | How it is written | HTTP API | MCP |
| --- | --- | --- | --- |
| `Authorization` header | `Authorization: Bearer <YOUR_API_KEY>` | Yes | Yes |
| `X-API-Key` header | `X-API-Key: <YOUR_API_KEY>` | Yes | Yes |

**cURL**

```
curl https://socialtoai.app/v1/search \
  -H "Authorization: Bearer $SOCIALTOAI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"platform":"reddit","query":"saturn rings"}'
```

`X-API-Key` works the same way, for clients that cannot set `Authorization`. Send one of them; if you send several and they differ, the request is refused.

## Signing in from AI apps

ChatGPT, Claude (web, desktop and mobile), Claude Code, Codex and Cursor connect to `https://socialtoai.app/mcp` with OAuth: you add the address (or run the one command [the MCP page](https://socialtoai.app/mcp.md) gives for your client), sign in with Google or with the code we email you and press Allow. New here? Signing in creates your account; Google and an emailed code with the same address open the same account. The app gets a token that lasts an hour and renews itself; no key is copied anywhere. The connection shows up in the console under API keys, named after the app, where you can give it a daily cap or revoke it at once. It is billed and limited like a key.

No route takes a key in the address: a request that tries is refused, and the key should be replaced, because it has been exposed. [The MCP page](https://socialtoai.app/mcp.md) has the steps for each client.

## Without a key

No key needed for: capabilities, find, OpenAPI. Requests without a key are limited to 60 a minute per network address. Everything that returns data needs a key.

## When a key is refused

The answer is HTTP 401 with the code `unauthorized`, and `reason` says which case it is. Nothing is charged.

| reason | What the answer says |
| --- | --- |
| `missing` | The API key is missing, mistyped or does not exist. Nothing was charged. |
| `invalid` | The API key is missing, mistyped or does not exist. Nothing was charged. |
| `key_in_query` | This address does not take a key in the URL. The key is now exposed: revoke it, create a new one and send it in a header. Nothing was charged. |
| `suspended` | This account is suspended. Nothing was charged. |
| `expired` | This key has expired. Nothing was charged. |
| `revoked` | This key was revoked. Nothing was charged. |

## If a key leaks

Revoke it in the console and create a new one. A revoked key stops working at once. Keys are not rotated in place: a new key is a new secret.
