# Authentication

Use an API key for agents and scripts, and the session cookie for the website.


Every operation needs an account, except the agent sign-up. The API accepts two kinds of credentials. Both act for one account and see the same orders.

| Credential | Who uses it | How to send it |
| --- | --- | --- |
| API key | Agents and scripts | `Authorization: Bearer sm_…` |
| Session cookie | The website | The cookie `better-auth.session_token`, which the browser sends |

The remote MCP server uses OAuth instead. See [MCP server](/docs/agents/mcp).

## API keys

An API key starts with `sm_`. Send it in the `Authorization` header of each request:

```sh tab="curl"
curl https://summonmade.com/api/v1/orders \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY"
```

```js tab="JavaScript"
const headers = { Authorization: `Bearer ${process.env.SUMMONMADE_API_KEY}` };
const response = await fetch("https://summonmade.com/api/v1/orders", { headers });
```

```python tab="Python"
import os
import requests

headers = {"Authorization": f"Bearer {os.environ['SUMMONMADE_API_KEY']}"}
response = requests.get("https://summonmade.com/api/v1/orders", headers=headers)
```

There are two ways to get a key:

- **A person creates it.** Sign in on the website and open Account, then API keys. The key shows only once.
- **An agent signs up.** `POST /api/v1/agents/sign-up` answers with a new account and its key. See [Agents](/docs/api/agents).

:::callout{type="warning"}
A key acts for its account. Anyone who has it can read and change the orders of that account. Keep keys out of code, logs and shared files. Never send a key by email.
:::

A person can delete a key in Account, then API keys. A deleted key stops working at once.

## Session cookie

The website signs people in without passwords: with an email link, a passkey, Google or GitHub. After sign-in, the browser keeps the session cookie and sends it with each API request. The sign-in page is `https://summonmade.com/login/`.

Use the session cookie only from the website. Agents and scripts use an API key.

## Missing or wrong credentials

A request without valid credentials gets `401`:

```json
{
  "title": "Unauthorized",
  "status": 401,
  "detail": "Sign in first at /login/."
}
```

An order that is not in your account answers `404`, the same as an order that does not exist. See [Errors](/docs/api/errors).
