> ## Documentation Index
> Fetch the complete documentation index at: https://docs.smokeball.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Contacts

[**@smokeballdev/smokeball-client-sdk**](./../../../../README)

***

# Interface: Api

Entry point for contacts to Smokeball.

## Methods

### create()

> **create**(`request`): `Promise`\<[`Contact`](./Contact)>

Create a new contact and returns the contact.

Currently only Person and Company contacts are supported.

#### Parameters

##### request

[`CreateContactRequest`](./CreateContactRequest)

the create request.

#### Returns

`Promise`\<[`Contact`](./Contact)>

#### Example

```
const request: CreateContactRequest = {
 // Specify the fields here.
};
const contact = await sdk.contacts.create(request);
```

***

### get()

> **get**(`contactId`): `Promise`\<[`Contact`](./Contact)>

Gets the contact associated to the specified contact id.

#### Parameters

##### contactId

`string`

the contact to retrieve.

#### Returns

`Promise`\<[`Contact`](./Contact)>

the specified contact.

#### Example

```
// Returns the contact with the specified contact id.
const contact = await sdk.contacts.get('e9b9084b-c9b4-4f3c-9f5a-4c83ed3ac265');
```

***

### observe()

> **observe**(`callback`): `void`

Creates a subscription for all contacts. Check against the contact you are interested in within your registered callback.

To prevent doubling up of changes, notifications triggered by the contact update call will not be notified here.

Only one subscription will be made per session. Regardless of how many times this function is called, the last registered callback will be used.

#### Parameters

##### callback

(`contact`) => `void`

the function to execute when a change is made to contact(s) in Smokeball.

#### Returns

`void`

#### Example

```
sdk.contacts.observe(contacts => {
  for (let i = 0; i < contacts.length; i++) {
    let contacts = contacts[i];
    // Check the contact id here.
    if (contact.id = 'e9b9084b-c9b4-4f3c-9f5a-4c83ed3ac265') {
      // Perform syncing code here.
    }
  }
});
```

***

### open()

> **open**(`contactId`): `void`

Opens the contact associated to the specified contact id.

#### Parameters

##### contactId

`string`

#### Returns

`void`

#### Example

```
// Opens the contact with the specified id.
sdk.contacts.open('e9b9084b-c9b4-4f3c-9f5a-4c83ed3ac265');
```

***

### update()

> **update**(`request`): `Promise`\<[`Contact`](./Contact)>

Updates the contact associated to the specified contact id and returns the contact.

Currently only Person and Company contacts are supported.

#### Parameters

##### request

[`UpdateContactRequest`](./UpdateContactRequest)

the update request.

#### Returns

`Promise`\<[`Contact`](./Contact)>

#### Example

```
const request: UpdateContactRequest = {
 id: 'e9b9084b-c9b4-4f3c-9f5a-4c83ed3ac265',
 // Specify the fields to update here.
};
const contact = await sdk.contacts.update(request);
```
