# Authentication

Sign in or send a key, and the CLI, code and API act as you.

## Before you start

You need a Veryfront account. [Sign in](/sign-in) or create one.

## Methods

Veryfront supports these authentication methods across its surfaces:

|            | Studio | Code | API | MCP |
| ---------- | :----: | :--: | :-: | :-: |
| Google     |    ✓   |   ✓  |     |  ✓  |
| GitHub     |    ✓   |   ✓  |     |  ✓  |
| Microsoft  |    ✓   |   ✓  |     |  ✓  |
| Email link |    ✓   |      |     |  ✓  |
| API key    |        |   ✓  |  ✓  |  ✓  |

## Sign in

**Studio**

1. Open the [sign-in page](/sign-in).
2. Click **Continue with Google**. You should now see Google's **Sign in**, or its account list if you are signed in to Google.
3. Sign in to Google, or choose your account. You should now see **Projects**.

**Continue with GitHub** and **Continue with Microsoft** work the same way. With an email address:

1. Open the [sign-in page](/sign-in).
2. Enter your email address at **Email address**.
3. Click **Continue**. You should now see **Check your email**.
4. Open the email Veryfront sent you.
5. Click the sign-in link in it. You should now see **Projects**.

**Code**

1. Run `login`. You should now see **Choose authentication method:**:

```bash
npx veryfront login
```

2. Choose **Google**. Your browser opens.
3. Sign in to Google. You should now see `✓ Logged in as` and your email in the terminal.
4. Check who the CLI is. You should now see `✓ Logged in as` and your email:

```bash
npx veryfront whoami
```

**GitHub** and **Microsoft** work the same way; `--google`, `--github` and `--microsoft` skip the list.

See the [CLI reference](/docs/reference/cli.md).

## Get an API key

**Studio**

1. In your project, open **Settings** > **API keys**.
2. Click **New API key**.
3. Enter `Support bot` as the **Name**.
4. Click **Create API key**. You should now see the key. Studio shows it once.
5. Click the copy button beside the key.

To set its expiry, permissions or limits, see [Create an API key](/docs/authentication/api-keys.md).

**API**

1. Set `PROJECT` to your project's ID ([Find your IDs](/docs/authentication/api-keys.md#find-your-ids)): `export PROJECT=<id>`.
2. Create the key with a key that can manage the project:

```bash
curl -X POST https://api.veryfront.com/api-keys \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"project_reference": "'$PROJECT'", "name": "Support bot", "scopes": ["read", "write"]}'
```

3. Copy the `key` in the answer. You should now see it start with `vf_`. It is shown once.

See [Create an API key](/docs/reference/rest/identity-access/create-api-key.md) in the REST API reference.

## Authenticate with an API key

**Code**

1. Add [your key](#get-an-api-key) to your project's `.env`:

```bash title=".env"
VERYFRONT_API_KEY=vf_…
```

2. Check who the CLI is. You should now see `✓ Authenticated with an API key`:

```bash
npx veryfront whoami
```

**API**

1. Set `VERYFRONT_API_KEY` to [your key](#get-an-api-key): `export VERYFRONT_API_KEY=vf_…`
2. Call the API with it. You should now see `200`:

```bash
curl -s -o /dev/null -w "%{http_code}\n" "https://api.veryfront.com/projects?limit=1" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY"
```

`X-API-Key: $VERYFRONT_API_KEY` works in place of the `Authorization` header.

### Troubleshooting

**If the API says "Missing or invalid Authorization header"**, the call sent no key. Check that `VERYFRONT_API_KEY` is set in this shell.

**If the API says "Invalid or expired API key"**, the key is not one Veryfront knows. Check it for a typo, or create a new one.

See the [Authentication reference](/docs/reference/authentication.md).

## With MCP

1. Call `veryfront__get_current_user`. The MCP connection is the key you sent. It worked when the answer holds your user's profile.
2. To get a key, call `veryfront__create_api_key` with `{ "project_reference": "my-project", "name": "Support bot" }`. The key is shown once, and it can only read: for a key that writes, create it in Studio or with the API.

## Next steps

* [Create an API key](/docs/authentication/api-keys.md)
* [Connect a coding agent](/docs/mcp/connect.md)
