# Contacts

## Create Contact

`client.printMail.contacts.create(ContactCreateParamsbody, RequestOptionsoptions?): Contact`

**post** `/print-mail/v1/contacts`

Creates a contact. This will also verify the contact's address **if you create it using a live API key**. To sucessfully create a contact, either a `firstName`, a `companyName`, or both are required. You can supply both, but you **cannot** supply neither.

You have the option to supply the entire address (except for `countryCode`) via `addressLine1`, in which case PostGrid will parse it automatically. However, this is **not guaranteed to be correct**, so we recommend passing along the structured address fields (`city`, `provinceOrState`, etc) if you have them.

_Note that if you create a contact that has identical information to another contact, this will simply update the description of the existing contact and return it. This avoids creating duplicate contacts._

### Parameters

- `ContactCreateParams = ContactCreateWithFirstName | ContactCreateWithCompanyName`

  - `ContactCreateParamsBase`

    - `addressLine1: string`

      The first line of the contact's address.

    - `countryCode: string`

      The ISO 3611-1 country code of the contact's address.

    - `firstName: string`

    - `addressLine2?: string`

      Second line of the contact's address, if applicable.

    - `city?: string`

      The city of the contact's address.

    - `companyName?: string`

      Company name of the contact.

    - `description?: string`

      An optional string describing this resource. Will be visible in the API and the dashboard.

    - `email?: string`

      Email of the contact.

    - `forceVerifiedStatus?: boolean`

      If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

    - `jobTitle?: string`

      Job title of the contact.

    - `lastName?: string`

      Last name of the contact.

    - `metadata?: Record<string, unknown>`

      See the section on Metadata.

    - `phoneNumber?: string`

      Phone number of the contact.

    - `postalOrZip?: string`

      The postal or ZIP code of the contact's address.

    - `provinceOrState?: string`

      Province or state of the contact's address.

    - `secret?: boolean`

      If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

    - `skipVerification?: boolean`

      If `true`, PostGrid will skip running this contact's address through our address verification system.

  - `ContactCreateWithFirstName extends ContactCreateParamsBase`

  - `ContactCreateWithCompanyName extends ContactCreateParamsBase`

### Returns

- `Contact`

  - `id: string`

    A unique ID prefixed with contact_

  - `addressLine1: string`

    The first line of the contact's address.

  - `addressStatus: "verified" | "corrected" | "failed"`

    One of `verified`, `corrected`, or `failed`.

    - `"verified"`

    - `"corrected"`

    - `"failed"`

  - `countryCode: string`

    The ISO 3611-1 country code of the contact's address.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `live: boolean`

    `true` if this is a live mode resource else `false`.

  - `object: "contact"`

    Always `contact`.

    - `"contact"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `addressErrors?: string`

    A series of human-readable errors/warnings that were raised when running the provided address through our address verification.

  - `addressLine2?: string`

    Second line of the contact's address, if applicable.

  - `city?: string`

    The city of the contact's address.

  - `companyName?: string`

    Company name of the contact.

  - `description?: string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `email?: string`

    Email of the contact.

  - `firstName?: string`

    First name of the contact.

  - `forceVerifiedStatus?: boolean`

    If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

  - `jobTitle?: string`

    Job title of the contact.

  - `lastName?: string`

    Last name of the contact.

  - `metadata?: Record<string, unknown>`

    See the section on Metadata.

  - `phoneNumber?: string`

    Phone number of the contact.

  - `postalOrZip?: string`

    The postal or ZIP code of the contact's address.

  - `provinceOrState?: string`

    Province or state of the contact's address.

  - `secret?: boolean`

    If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

  - `skipVerification?: boolean`

    If `true`, PostGrid will skip running this contact's address through our address verification system.

### Example

```typescript
import PostGrid from 'postgrid-node';

const client = new PostGrid({
  printMailAPIKey: process.env['POSTGRID_PRINT_MAIL_API_KEY'], // This is the default and can be omitted
});

const contact = await client.printMail.contacts.create({
  addressLine1: '90 Canal St Suite 600, Boston MA 90210',
  countryCode: 'US',
  firstName: 'Kevin',
  companyName: 'PostGrid',
});

console.log(contact.id);
```

#### Response

```json
{
  "id": "contact_pxd7wnnD1xY6H6etKNvjb4",
  "object": "contact",
  "live": false,
  "companyName": "PostGrid",
  "addressLine1": "90 CANAL ST STE 600",
  "city": "BOSTON",
  "provinceOrState": "MA",
  "postalOrZip": "90210-1234",
  "countryCode": "US",
  "skipVerification": false,
  "forceVerifiedStatus": false,
  "addressStatus": "verified",
  "createdAt": "2022-02-16T15:08:41.052Z",
  "updatedAt": "2022-02-16T15:08:41.052Z"
}
```

## List Contacts

`client.printMail.contacts.list(ContactListParamsquery?, RequestOptionsoptions?): SkipLimit<Contact>`

**get** `/print-mail/v1/contacts`

Get a list of contacts.

### Parameters

- `query: ContactListParams`

  - `limit?: number`

  - `search?: string`

    You can supply any string to help narrow down the list of resources. For example, if you pass `"New York"` (quoted), it will return resources that have that string present somewhere in their response. Alternatively, you can supply a structured search query. See the documentation on `StructuredSearchQuery` for more details.

  - `skip?: number`

### Returns

- `Contact`

  - `id: string`

    A unique ID prefixed with contact_

  - `addressLine1: string`

    The first line of the contact's address.

  - `addressStatus: "verified" | "corrected" | "failed"`

    One of `verified`, `corrected`, or `failed`.

    - `"verified"`

    - `"corrected"`

    - `"failed"`

  - `countryCode: string`

    The ISO 3611-1 country code of the contact's address.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `live: boolean`

    `true` if this is a live mode resource else `false`.

  - `object: "contact"`

    Always `contact`.

    - `"contact"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `addressErrors?: string`

    A series of human-readable errors/warnings that were raised when running the provided address through our address verification.

  - `addressLine2?: string`

    Second line of the contact's address, if applicable.

  - `city?: string`

    The city of the contact's address.

  - `companyName?: string`

    Company name of the contact.

  - `description?: string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `email?: string`

    Email of the contact.

  - `firstName?: string`

    First name of the contact.

  - `forceVerifiedStatus?: boolean`

    If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

  - `jobTitle?: string`

    Job title of the contact.

  - `lastName?: string`

    Last name of the contact.

  - `metadata?: Record<string, unknown>`

    See the section on Metadata.

  - `phoneNumber?: string`

    Phone number of the contact.

  - `postalOrZip?: string`

    The postal or ZIP code of the contact's address.

  - `provinceOrState?: string`

    Province or state of the contact's address.

  - `secret?: boolean`

    If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

  - `skipVerification?: boolean`

    If `true`, PostGrid will skip running this contact's address through our address verification system.

### Example

```typescript
import PostGrid from 'postgrid-node';

const client = new PostGrid({
  printMailAPIKey: process.env['POSTGRID_PRINT_MAIL_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const contact of client.printMail.contacts.list()) {
  console.log(contact.id);
}
```

#### Response

```json
{
  "skip": 0,
  "limit": 10,
  "totalCount": 1,
  "object": "list",
  "data": [
    {
      "id": "contact_pxd7wnnD1xY6H6etKNvjb4",
      "object": "contact",
      "live": false,
      "companyName": "PostGrid",
      "addressLine1": "90 CANAL ST STE 600",
      "city": "BOSTON",
      "provinceOrState": "MA",
      "postalOrZip": "90210-1234",
      "countryCode": "US",
      "skipVerification": false,
      "forceVerifiedStatus": false,
      "addressStatus": "verified",
      "createdAt": "2022-02-16T15:08:41.052Z",
      "updatedAt": "2022-02-16T15:08:41.052Z"
    }
  ]
}
```

## Get Contact

`client.printMail.contacts.retrieve(stringid, RequestOptionsoptions?): Contact`

**get** `/print-mail/v1/contacts/{id}`

Retrieve a contact.

### Parameters

- `id: string`

### Returns

- `Contact`

  - `id: string`

    A unique ID prefixed with contact_

  - `addressLine1: string`

    The first line of the contact's address.

  - `addressStatus: "verified" | "corrected" | "failed"`

    One of `verified`, `corrected`, or `failed`.

    - `"verified"`

    - `"corrected"`

    - `"failed"`

  - `countryCode: string`

    The ISO 3611-1 country code of the contact's address.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `live: boolean`

    `true` if this is a live mode resource else `false`.

  - `object: "contact"`

    Always `contact`.

    - `"contact"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `addressErrors?: string`

    A series of human-readable errors/warnings that were raised when running the provided address through our address verification.

  - `addressLine2?: string`

    Second line of the contact's address, if applicable.

  - `city?: string`

    The city of the contact's address.

  - `companyName?: string`

    Company name of the contact.

  - `description?: string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `email?: string`

    Email of the contact.

  - `firstName?: string`

    First name of the contact.

  - `forceVerifiedStatus?: boolean`

    If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

  - `jobTitle?: string`

    Job title of the contact.

  - `lastName?: string`

    Last name of the contact.

  - `metadata?: Record<string, unknown>`

    See the section on Metadata.

  - `phoneNumber?: string`

    Phone number of the contact.

  - `postalOrZip?: string`

    The postal or ZIP code of the contact's address.

  - `provinceOrState?: string`

    Province or state of the contact's address.

  - `secret?: boolean`

    If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

  - `skipVerification?: boolean`

    If `true`, PostGrid will skip running this contact's address through our address verification system.

### Example

```typescript
import PostGrid from 'postgrid-node';

const client = new PostGrid({
  printMailAPIKey: process.env['POSTGRID_PRINT_MAIL_API_KEY'], // This is the default and can be omitted
});

const contact = await client.printMail.contacts.retrieve('id');

console.log(contact.id);
```

#### Response

```json
{
  "id": "contact_pxd7wnnD1xY6H6etKNvjb4",
  "object": "contact",
  "live": false,
  "companyName": "PostGrid",
  "addressLine1": "90 CANAL ST STE 600",
  "city": "BOSTON",
  "provinceOrState": "MA",
  "postalOrZip": "90210-1234",
  "countryCode": "US",
  "skipVerification": false,
  "forceVerifiedStatus": false,
  "addressStatus": "verified",
  "createdAt": "2022-02-16T15:08:41.052Z",
  "updatedAt": "2022-02-16T15:08:41.052Z"
}
```

## Delete Contact

`client.printMail.contacts.delete(stringid, RequestOptionsoptions?): ContactDeleteResponse`

**delete** `/print-mail/v1/contacts/{id}`

Delete a contact. Note that this will not affect orders that were sent to this contact.

### Parameters

- `id: string`

### Returns

- `ContactDeleteResponse`

  - `id: string`

    A unique ID prefixed with contact_

  - `deleted: true`

    - `true`

  - `object: "contact"`

    Always `contact`.

    - `"contact"`

### Example

```typescript
import PostGrid from 'postgrid-node';

const client = new PostGrid({
  printMailAPIKey: process.env['POSTGRID_PRINT_MAIL_API_KEY'], // This is the default and can be omitted
});

const contact = await client.printMail.contacts.delete('id');

console.log(contact.id);
```

#### Response

```json
{
  "id": "contact_sqF12lZ1VlBb",
  "deleted": true,
  "object": "contact"
}
```

## Domain Types

### Contact

- `Contact`

  - `id: string`

    A unique ID prefixed with contact_

  - `addressLine1: string`

    The first line of the contact's address.

  - `addressStatus: "verified" | "corrected" | "failed"`

    One of `verified`, `corrected`, or `failed`.

    - `"verified"`

    - `"corrected"`

    - `"failed"`

  - `countryCode: string`

    The ISO 3611-1 country code of the contact's address.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `live: boolean`

    `true` if this is a live mode resource else `false`.

  - `object: "contact"`

    Always `contact`.

    - `"contact"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `addressErrors?: string`

    A series of human-readable errors/warnings that were raised when running the provided address through our address verification.

  - `addressLine2?: string`

    Second line of the contact's address, if applicable.

  - `city?: string`

    The city of the contact's address.

  - `companyName?: string`

    Company name of the contact.

  - `description?: string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `email?: string`

    Email of the contact.

  - `firstName?: string`

    First name of the contact.

  - `forceVerifiedStatus?: boolean`

    If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

  - `jobTitle?: string`

    Job title of the contact.

  - `lastName?: string`

    Last name of the contact.

  - `metadata?: Record<string, unknown>`

    See the section on Metadata.

  - `phoneNumber?: string`

    Phone number of the contact.

  - `postalOrZip?: string`

    The postal or ZIP code of the contact's address.

  - `provinceOrState?: string`

    Province or state of the contact's address.

  - `secret?: boolean`

    If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

  - `skipVerification?: boolean`

    If `true`, PostGrid will skip running this contact's address through our address verification system.

### Contact Create

- `ContactCreate = ContactCreateWithFirstName | ContactCreateWithCompanyName`

  - `ContactCreateWithFirstName`

    - `addressLine1: string`

      The first line of the contact's address.

    - `countryCode: string`

      The ISO 3611-1 country code of the contact's address.

    - `firstName: string`

    - `addressLine2?: string`

      Second line of the contact's address, if applicable.

    - `city?: string`

      The city of the contact's address.

    - `companyName?: string`

      Company name of the contact.

    - `description?: string`

      An optional string describing this resource. Will be visible in the API and the dashboard.

    - `email?: string`

      Email of the contact.

    - `forceVerifiedStatus?: boolean`

      If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

    - `jobTitle?: string`

      Job title of the contact.

    - `lastName?: string`

      Last name of the contact.

    - `metadata?: Record<string, unknown>`

      See the section on Metadata.

    - `phoneNumber?: string`

      Phone number of the contact.

    - `postalOrZip?: string`

      The postal or ZIP code of the contact's address.

    - `provinceOrState?: string`

      Province or state of the contact's address.

    - `secret?: boolean`

      If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

    - `skipVerification?: boolean`

      If `true`, PostGrid will skip running this contact's address through our address verification system.

  - `ContactCreateWithCompanyName`

    - `addressLine1: string`

      The first line of the contact's address.

    - `companyName: string`

    - `countryCode: string`

      The ISO 3611-1 country code of the contact's address.

    - `addressLine2?: string`

      Second line of the contact's address, if applicable.

    - `city?: string`

      The city of the contact's address.

    - `description?: string`

      An optional string describing this resource. Will be visible in the API and the dashboard.

    - `email?: string`

      Email of the contact.

    - `firstName?: string`

      First name of the contact.

    - `forceVerifiedStatus?: boolean`

      If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

    - `jobTitle?: string`

      Job title of the contact.

    - `lastName?: string`

      Last name of the contact.

    - `metadata?: Record<string, unknown>`

      See the section on Metadata.

    - `phoneNumber?: string`

      Phone number of the contact.

    - `postalOrZip?: string`

      The postal or ZIP code of the contact's address.

    - `provinceOrState?: string`

      Province or state of the contact's address.

    - `secret?: boolean`

      If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

    - `skipVerification?: boolean`

      If `true`, PostGrid will skip running this contact's address through our address verification system.

### Contact Create With Company Name

- `ContactCreateWithCompanyName`

  - `addressLine1: string`

    The first line of the contact's address.

  - `companyName: string`

  - `countryCode: string`

    The ISO 3611-1 country code of the contact's address.

  - `addressLine2?: string`

    Second line of the contact's address, if applicable.

  - `city?: string`

    The city of the contact's address.

  - `description?: string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `email?: string`

    Email of the contact.

  - `firstName?: string`

    First name of the contact.

  - `forceVerifiedStatus?: boolean`

    If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

  - `jobTitle?: string`

    Job title of the contact.

  - `lastName?: string`

    Last name of the contact.

  - `metadata?: Record<string, unknown>`

    See the section on Metadata.

  - `phoneNumber?: string`

    Phone number of the contact.

  - `postalOrZip?: string`

    The postal or ZIP code of the contact's address.

  - `provinceOrState?: string`

    Province or state of the contact's address.

  - `secret?: boolean`

    If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

  - `skipVerification?: boolean`

    If `true`, PostGrid will skip running this contact's address through our address verification system.

### Contact Create With First Name

- `ContactCreateWithFirstName`

  - `addressLine1: string`

    The first line of the contact's address.

  - `countryCode: string`

    The ISO 3611-1 country code of the contact's address.

  - `firstName: string`

  - `addressLine2?: string`

    Second line of the contact's address, if applicable.

  - `city?: string`

    The city of the contact's address.

  - `companyName?: string`

    Company name of the contact.

  - `description?: string`

    An optional string describing this resource. Will be visible in the API and the dashboard.

  - `email?: string`

    Email of the contact.

  - `forceVerifiedStatus?: boolean`

    If `true`, PostGrid will force this contact to have an `addressStatus` of `verified` even if our address verification system says otherwise.

  - `jobTitle?: string`

    Job title of the contact.

  - `lastName?: string`

    Last name of the contact.

  - `metadata?: Record<string, unknown>`

    See the section on Metadata.

  - `phoneNumber?: string`

    Phone number of the contact.

  - `postalOrZip?: string`

    The postal or ZIP code of the contact's address.

  - `provinceOrState?: string`

    Province or state of the contact's address.

  - `secret?: boolean`

    If `true`, the contact's details are hidden from the dashboard and API responses apart from the final print. The contact ID can then be used as a token for sending mail without giving access to the underlying data.

  - `skipVerification?: boolean`

    If `true`, PostGrid will skip running this contact's address through our address verification system.

### Contact Delete Response

- `ContactDeleteResponse`

  - `id: string`

    A unique ID prefixed with contact_

  - `deleted: true`

    - `true`

  - `object: "contact"`

    Always `contact`.

    - `"contact"`
