# Verify the code and get an API key

Checks the code from the email. A new address gets a free account and needs accept_terms: true here as well; an existing account keeps everything and gets an additional live key. The key is in the response once. Accounts with two-factor authentication create keys in the dashboard instead. No API key needed.

`POST https://api.switchfile.io/v1/signup/verify`

No API key needed.

## Example

cURL:

```bash
curl "https://api.switchfile.io/v1/signup/verify" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "agent@example.com",
    "code": "48213907",
    "accept_terms": true
  }'
```

Node.js:

```js
const res = await fetch("https://api.switchfile.io/v1/signup/verify", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    email: "agent@example.com",
    code: "48213907",
    accept_terms: true
  }),
});
if (!res.ok) throw new Error(`HTTP ${res.status}: ${await res.text()}`);
console.log(await res.json());
```

PHP:

```php
<?php
$ch = curl_init('https://api.switchfile.io/v1/signup/verify');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode([
        'email' => 'agent@example.com',
        'code' => '48213907',
        'accept_terms' => true,
    ]),
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch);

if ($status >= 400) {
    throw new RuntimeException("HTTP $status: $response");
}
print_r(json_decode($response, true));
```

Python:

```python
import requests

res = requests.post(
    "https://api.switchfile.io/v1/signup/verify",
    json={
        "email": "agent@example.com",
        "code": "48213907",
        "accept_terms": True,
    },
)
res.raise_for_status()
print(res.json())
```

## Request body

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `accept_terms` | boolean | no | Must be true when this creates a new account: the owner of the inbox accepts the terms (https://switchfile.io/terms). See the privacy policy at https://switchfile.io/privacy |
| `code` | string | yes | The 8-digit code from the email. Spaces and hyphens are ignored (1 to 32 characters) |
| `email` | string | yes | The same email address as in POST /v1/signup (3 to 254 characters) |

## Responses

### 201: The new key. It is shown only in this response

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `account_created` | boolean | yes | true: a new account was created. false: the account existed and got an additional key |
| `api_key` | string | yes | The full API key. It is shown only in this response; store it now |
| `email` | string | yes | Email address of the account |
| `key` | object | yes |  |
| `key.created_at` | string | yes | ISO 8601 timestamp |
| `key.id` | string (uuid) | yes |  |
| `key.mode` | string | yes | (one of "live") |
| `key.name` | string \| null | yes |  |
| `key.prefix` | string | yes | Start of the key, as shown in the dashboard |
| `message` | string | yes |  |

Example (application/json):

```json
{
  "api_key": "sf_live_3kQ9vT2mX8pL5wR7nB4cY6dF1hJ0sA2e",
  "key": {
    "id": "6a4f1d2e-8b3c-4e5f-9a7b-1c2d3e4f5a6b",
    "name": "API sign-up",
    "mode": "live",
    "prefix": "sf_live_3kQ9vT",
    "created_at": "2026-11-06T18:00:00+00:00"
  },
  "email": "agent@example.com",
  "account_created": true,
  "message": "Store this key now, it is shown only once. Send it as Authorization: Bearer <key>. Manage your keys in the dashboard."
}
```

### 400: The code does not match or has expired; each code works once (INVALID_CODE). After 5 wrong tries a code stops working. A new account needs accept_terms: true here as well (TERMS_NOT_ACCEPTED, the code stays valid) (`INVALID_CODE`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-invalid-code",
  "title": "Invalid code",
  "status": 400,
  "code": "INVALID_CODE",
  "detail": "This code does not match, or it expired. Each code works once. Request a new one with POST /v1/signup."
}
```

### 403: The account uses two-factor authentication (TWO_FACTOR_ENABLED) or is suspended (ACCOUNT_SUSPENDED) (`TWO_FACTOR_ENABLED`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-two-factor-enabled",
  "title": "Two factor enabled",
  "status": 403,
  "code": "TWO_FACTOR_ENABLED",
  "detail": "This account uses two-factor authentication. Sign in and create API keys in the dashboard: https://switchfile.io/dashboard/keys"
}
```

### 409: The account already has the maximum number of active keys (KEY_LIMIT) (`KEY_LIMIT`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-key-limit",
  "title": "Key limit",
  "status": 409,
  "code": "KEY_LIMIT",
  "detail": "This account has reached the limit of active keys. Revoke a key you no longer use in the dashboard: https://switchfile.io/dashboard/keys"
}
```

### 422: The email address or the code is not valid (`INVALID_DATA`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-invalid-data",
  "title": "Invalid data",
  "status": 422,
  "code": "INVALID_DATA",
  "detail": "The request contains invalid data.",
  "errors": {
    "code": [
      "Enter the 8-digit code from the email."
    ]
  }
}
```

### 429: Too many tries for this address (10 per hour) or from this IP address (30 per hour). See Retry-After (`RATE_LIMIT_EXCEEDED`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-rate-limit-exceeded",
  "title": "Rate limit exceeded",
  "status": 429,
  "code": "RATE_LIMIT_EXCEEDED",
  "detail": "Too many attempts. Try again in 42 minutes."
}
```

### 503: Email or sign-up is not available right now (MAIL_NOT_CONFIGURED, MAIL_SEND_FAILED, SIGNUP_UNAVAILABLE). See Retry-After (`MAIL_SEND_FAILED`)

Example (application/problem+json):

```json
{
  "type": "https://switchfile.io/docs/api/v1#errors-mail-send-failed",
  "title": "Mail send failed",
  "status": 503,
  "code": "MAIL_SEND_FAILED",
  "detail": "We couldn't send the email right now. Try again in a few minutes."
}
```

Error bodies and codes are explained in [Errors](https://switchfile.io/docs/errors).
