# Verify TOTP during invite setup

> Source: https://docs.clonepartner.com/api-reference/auth/verify-invite-totp/

`POST /api/auth/verify-invite-totp`

Verifies the TOTP code during invite acceptance. On success, marks the user's TOTP
as verified, creates a session, and sets the session cookie. The invite must first
be accepted with /api/auth/accept-invite so the password is set before TOTP verification.

**Operation ID:** `verifyInviteTotp`

## Authentication

No authentication is required.

## Request body

The request body is required.

### `application/json`

- Type: `object`
- Properties:
  - `token` (`string`, `required`)
  - `code` (`string`, `required`)

## Success responses

### 200

TOTP verified, session created

**Content type:** `application/json`

- Type: `object`
- Properties:
  - `success` (`boolean`)

## Error responses

### 400

Invalid token or incomplete setup


### 401

Invalid TOTP code


### 429

Too many requests

**Content type:** `application/json`

- Reference: `Error`
  - Type: `object`
  - Properties:
    - `error` (`string`)
      - Example: `NOT_FOUND`
    - `message` (`string`)
      - Example: `Resource not found`

Example:

```json
{
  "error": "RATE_LIMITED",
  "message": "Too many failed TOTP attempts. Try again later."
}
```

## Examples

### cURL

```bash
curl --request POST \
  --url 'https://your-envoy.example.com/api/auth/verify-invite-totp' \
  --header 'Content-Type: application/json' \
  --data '{
  "token": "string",
  "code": "string"
}'
```

### JavaScript (fetch)

```javascript
const response = await fetch('https://your-envoy.example.com/api/auth/verify-invite-totp', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "token": "string",
    "code": "string"
  }),
});

if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = response.status === 204 ? null : await response.json();
console.log(data);
```
