# Register a person

Operation ID: `person.register`

Create a Cognito user (role=person) and a matching FHIR Person resource. Unless the deployment sets AUTO_VERIFY_EMAIL=true, the account starts unverified and an email OTP is sent — call person.verifyEmail before person.login will treat the account as fully onboarded. When AUTO_VERIFY_EMAIL=true, the email is verified immediately and this call attempts an automatic login; on success the response also carries access_token/id_token/expires_in so the caller can skip a separate login.

## Public method

`register`

Signature: `person.register(request)`

Return type: `Promise<RegisterPersonResponse>`

## Authentication

Classification: **PUBLIC**

## Prerequisites

None documented.

## HTTP

`POST /auth/register`

## Path parameters

None.

## Query parameters

None.

## Body parameters

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

Request model: [`person.RegisterRequest`](../models/person.RegisterRequest.md)

## Request example

```json
{
  "address": {
    "city": "Boston",
    "country": "US",
    "state": "MA",
    "street1": "100 Example Avenue",
    "zip_code": "02108"
  },
  "attributes": {},
  "date_of_birth": "1990-01-01",
  "email": "person.user@example.com",
  "first_name": "Alex",
  "gender": "female",
  "last_name": "Smith",
  "password": "PasswordTest1234$",
  "person_type": "family_member",
  "phone": "+15550100000",
  "race": "white",
  "relationship": "self",
  "tenant_id": "tenant-example-001"
}
```

## Success responses

| Status | Shape | Content type | Description |
|---|---|---|---|
| `201` | [`person.RegisterResponse`](../models/person.RegisterResponse.md) | application/json | Person registered |

## Success response examples

### 201

```json
{
  "access_token": "example-access-token",
  "cognito_sub": "00000000-0000-4000-8000-000000000000",
  "email_otp_sent": true,
  "email_verified": false,
  "expires_in": 3600,
  "fhir_person_id": "person-example-001",
  "id_token": "example-id-token",
  "person_type": "family_member"
}
```

## Common errors

| Status | Shape | Content type | Description |
|---|---|---|---|
| `400` | [`person.ErrorResponse`](../models/person.ErrorResponse.md) | application/json | Required fields are missing, invalid, or Cognito/FHIR rejected the registration |

## Error examples

### 400 — Required fields are missing

```json
{
  "error": "tenant_id, first_name, last_name, email and password are required"
}
```

### 400 — person_type was not supplied

```json
{
  "error": "person_type is required"
}
```

### 400 — Password does not meet the minimum length

```json
{
  "error": "password must be at least 8 characters"
}
```

## NodeJS / TypeScript implementation

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

```ts
const request = {
  "address": {
    "city": "Boston",
    "country": "US",
    "state": "MA",
    "street1": "100 Example Avenue",
    "zip_code": "02108"
  },
  "attributes": {},
  "date_of_birth": "1990-01-01",
  "email": "person.user@example.com",
  "first_name": "Alex",
  "gender": "female",
  "last_name": "Smith",
  "password": "PasswordTest1234$",
  "person_type": "family_member",
  "phone": "+15550100000",
  "race": "white",
  "relationship": "self",
  "tenant_id": "tenant-example-001"
};

const result = await person.register(request);
```

## cURL

```bash
curl -X POST \
  -H 'Content-Type: application/json' \
  -d '{"address":{"city":"Boston","country":"US","state":"MA","street1":"100 Example Avenue","zip_code":"02108"},"attributes":{},"date_of_birth":"1990-01-01","email":"person.user@example.com","first_name":"Alex","gender":"female","last_name":"Smith","password":"PasswordTest1234$","person_type":"family_member","phone":"+15550100000","race":"white","relationship":"self","tenant_id":"tenant-example-001"}' \
  'https://dev-api-person.health.cloud/auth/register'
```

## 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.
