# IdentityManager

The `IdentityManager` is responsible for managing the identity of the current user. It allows to identify the user, update its attributes, and send verification requests.

## Example

To access `IdentityManager`, you can use the `contact` property of the SDK instance.

```ts
Bird.contact.identify();
```

## Accessors

### anonymousId

```ts
get anonymousId(): string
```

The anonymousId is a unique identifier for the current user. It is used to track the user before they are identified.

#### Returns

`string`

### contactId

```ts
get contactId(): string
```

The `contactId` represents the current user's contact id. This is the unique identifier within Bird CRM that is assigned to the user once they are identified.

#### Returns

`string`

### isVerified

```ts
get isVerified(): boolean
```

The `isVerified` property indicates whether the user has been identified and verified using a trusted verification method.

#### Returns

`boolean`

## Methods

### getCurrent()

```ts
getCurrent(): Promise<ContactsContactMeResponse>
```

Returns the current contact information.

#### Returns

`Promise`<`ContactsContactMeResponse`>

### identify()

```ts
identify(claim: ContactIdentifierClaim, contactAttributes?: ContactsVerificationsV2RequestContactAttributes): Promise<{
  accessToken: res.token;
  contactId: res.contactId;
  identifierKeys: res.identifierKeys;
 } | {
  accessToken: undefined | string;
  contactId: string;
}>
```

The identify method is how you tell Bird CRM who the current visitor is. It includes a unique user ID, and any optional attributes you know about them. There's no need to call identify for anonymous visitors. The SDK automatically assigns them a visitor ID, so tracking events works just fine without having to identify the visitor.

> 💡 Make sure to call identify as soon as a visitor is identified either as a new user or a returning user. This will ensure that all events are correctly associated with the visitor.

#### Parameters

• **claim**: `ContactIdentifierClaim`

• **contactAttributes?**: `ContactsVerificationsV2RequestContactAttributes`

#### Returns

`Promise`<{ `accessToken`: `res.token`; `contactId`: `res.contactId`; `identifierKeys`: `res.identifierKeys`; } | { `accessToken`: `undefined` | `string`; `contactId`: `string`; }>

#### Example

To create a new contact with some known identifiers, you can call identify as:

<pre class="language-ts"><code class="lang-ts"><strong>Bird.contact.identify({
</strong>	strategy: 'Visitor',
	identifier: {
		key: 'emailaddress',
		value: 'michael@example.com',
	},
});
</code></pre>

### reset()

```ts
reset(): Promise<void>
```

Resets the current contact information. This will clear the current contact information and generate a new anonymousId if the `anonymousId` option is set to `refresh`.

#### Returns

`Promise`<`void`>

#### Example

To refresh the anonymousId, you can call `reset()` as:

```ts
Bird.contact.reset();
```

### sendVerificationRequest()

```ts
sendVerificationRequest(verificationRequest: OTPVerificationRequest): Promise<{
  expiresAt: res.expiresAt;
  id: res.id;
}>
```

Sends a verification request to the current user. The verification request is used to verify the user's identity using a trusted verification method like OTP.

#### Parameters

• **verificationRequest**: `OTPVerificationRequest`

#### Returns

`Promise`<{ `expiresAt`: `res.expiresAt`; `id`: `res.id`; }>

**expiresAt**

```ts
expiresAt: string = res.expiresAt;
```

**id**

```ts
id: string = res.id;
```

#### Example

To send an OTP verification request to the current user, you can call `sendVerificationRequest` as:

```ts
Bird.contact.sendVerificationRequest({
	strategy: 'OTP',
	identifier: {
		key: 'phonenumber',
		value: '+31612345678',
	},
});
```

### updateCurrent()

```ts
updateCurrent(attributes: Record<string, any>): Promise<ContactsContactMeResponse>
```

Updates the current contact information.

#### Parameters

• **attributes**: `Record`<`string`, `any`>

#### Returns

`Promise`<`ContactsContactMeResponse`>
