# Verify an agent's email OTP

Operation ID: `fieldagent.verifyEmail`

Confirm the OTP emailed during fieldagent.register and mark the Cognito account's email as verified.

## Public method

`verifyEmail`

Signature: `fieldAgent.verifyEmail(request)`

Return type: `Promise<VerifiedResponse>`

## Authentication

Classification: **PUBLIC**

## Prerequisites

None documented.

## HTTP

`POST /auth/verify-email`

## Path parameters

None.

## Query parameters

None.

## Body parameters

| Name | Type | Required | Format | Allowed values | Default | Nullable | Description |
|---|---|---:|---|---|---|---:|---|
| `body` | [`fieldagent.VerifyEmailRequest`](../models/fieldagent.VerifyEmailRequest.md) | No |  |  |  | Yes |  |

Request model: [`fieldagent.VerifyEmailRequest`](../models/fieldagent.VerifyEmailRequest.md)

## Request example

```json
{
  "email": "test.user@example.com",
  "otp": "123456",
  "tenant_id": "tenant-example-001"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `200` | [`VerifyOtpResponse`](../models/VerifyOtpResponse.md) | application/json | Email verified |

## Success response examples

### 200

```json
{
  "verified": true
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | Required fields are missing, or the OTP is invalid/expired |
| `404` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | No account exists for the given email in this tenant |
| `500` | [`fieldagent.ErrorResponse`](../models/fieldagent.ErrorResponse.md) | application/json | Internal server error |

## Error examples

### 400 — The OTP is incorrect or expired (sanitized example)

```json
{
  "error": "Invalid or expired OTP"
}
```

### 400 — Required fields are missing

```json
{
  "error": "email, tenant_id and otp are required"
}
```

### 404 — No Cognito user matches email in tenant

```json
{
  "error": "User with email 'agent.user@example.com' not found in tenant 'tenant-example-001'"
}
```

### 500 — The Cognito user lookup itself failed (sanitized example)

```json
{
  "error": "Lookup failed: Internal server error"
}
```

## NodeJS / TypeScript implementation

```ts
import { HCSDK } from "@healthcloudai/hc-sdk";
import type { VerifyEmailRequest } from "@healthcloudai/hc-sdk";
```

```ts
const request = {
  "email": "test.user@example.com",
  "otp": "123456",
  "tenant_id": "tenant-example-001"
};

const result = await fieldAgent.verifyEmail(request);
```

## cURL

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"email":"test.user@example.com","otp":"123456","tenant_id":"tenant-example-001"}' \
  'https://dev-api-fieldagent.health.cloud/auth/verify-email'
```

## Notes

None.

## Prepared Test Console scenario

No canonical scenario is currently associated.

## Real response

No approved real integration response is currently published. Unapproved candidates are never rendered as examples.
