# Letters

## Create Letter Create Letter

`client.printMail.letters.create(LetterCreateParamsparams, RequestOptionsoptions?): LetterCreateResponse`

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

Create a letter. Note that you can supply one of the following:

- HTML content for the letter
- A template ID for the letter
- A URL for a PDF for the letter Create a letter via a multipart/form-data request. Accepts the same
  fields as the JSON create body (nested objects are bracket-encoded form
  fields, e.g. `to[firstName]`); use this content type to upload the PDF
  file directly.

### Parameters

- `LetterCreateParams = LetterCreateWithHTML | LetterCreateWithTemplate | LetterCreateWithPdf`

  - `LetterCreateParamsBase`

    - `from: ContactCreateWithFirstName | ContactCreateWithCompanyName | string`

      Body param: The contact information of the sender. You can pass contact information inline here just like you can for the `to`.

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

      - `string`

    - `html: string`

      Body param: The HTML content for the letter. You can supply _either_ this or `template` but not both.

    - `to: ContactCreateWithFirstName | ContactCreateWithCompanyName | string`

      Body param: The recipient of this order. You can either supply the contact information inline here or provide a contact ID. PostGrid will automatically deduplicate contacts regardless of whether you provide the information inline here or call the contact creation endpoint.

      - `ContactCreateWithFirstName`

      - `ContactCreateWithCompanyName`

      - `string`

    - `addressPlacement?: AddressPlacement`

      Body param: Enum representing the placement of the address on the letter.

      - `"top_first_page"`

      - `"insert_blank_page"`

    - `attachedPDF?: AttachedPdf`

      Body param: Model representing an attached PDF.

      - `file: string | Uploadable`

        The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

        - `string`

        - `Uploadable`

      - `placement: "before_template" | "after_template"`

        Enum representing the placement of the attached PDF.

        - `"before_template"`

        - `"after_template"`

    - `color?: boolean`

      Body param: Indicates if the letter is in color.

    - `description?: string`

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

    - `doubleSided?: boolean`

      Body param: Indicates if the letter is double-sided.

    - `envelope?: string`

      Body param: The envelope (ID) for the letter. You can either specify a custom envelope ID or use the default `standard` envelope.

    - `mailingClass?: "first_class" | "standard_class" | "express" | 23 more`

      Body param: The mailing class of this order. If not provided, automatically set to `first_class`.

      - `"first_class"`

      - `"standard_class"`

      - `"express"`

      - `"certified"`

      - `"certified_return_receipt"`

      - `"registered"`

      - `"usps_first_class"`

      - `"usps_standard_class"`

      - `"usps_eddm"`

      - `"usps_express_2_day"`

      - `"usps_express_3_day"`

      - `"usps_first_class_certified"`

      - `"usps_first_class_certified_return_receipt"`

      - `"usps_first_class_registered"`

      - `"usps_express_3_day_signature_confirmation"`

      - `"usps_express_3_day_certified"`

      - `"usps_express_3_day_certified_return_receipt"`

      - `"ca_post_lettermail"`

      - `"ca_post_personalized"`

      - `"ca_post_neighbourhood_mail"`

      - `"ups_express_overnight"`

      - `"ups_express_2_day"`

      - `"ups_express_3_day"`

      - `"royal_mail_first_class"`

      - `"royal_mail_second_class"`

      - `"au_post_second_class"`

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

      Body param: These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

      Body param: See the section on Metadata.

    - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

      Body param: Premium paper selection used for this letter.

      Available values include:

      - `standard`
      - `premium_paper_letter_standard_white_70lb`
      - `premium_paper_letter_standard_white_80lb`

      Not all premium paper options are enabled for all organizations.
      If omitted, the organization default letter paper is used when configured; otherwise `standard`.

      - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

        - `"standard"`

        - `"premium_paper_letter_standard_white_70lb"`

        - `"premium_paper_letter_standard_white_80lb"`

      - `(string & {})`

    - `perforatedPage?: 1`

      Body param: If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

      - `1`

    - `plasticCard?: PlasticCard`

      Body param: Model representing a plastic card.

      - `size: "standard"`

        Enum representing the size of the plastic card.

        - `"standard"`

      - `doubleSided?: DoubleSided`

        Model representing a double-sided plastic card.

        - `backHTML?: string`

          The HTML content for the back side of the double-sided plastic card.

        - `backTemplate?: string`

          The template ID for the back side of the double-sided plastic card.

        - `frontHTML?: string`

          The HTML content for the front side of the double-sided plastic card.

        - `frontTemplate?: string`

          The template ID for the front side of the double-sided plastic card.

        - `pdf?: string | Uploadable`

          A URL pointing to a PDF file for the double-sided plastic card or the file itself.

          - `string`

          - `Uploadable`

      - `singleSided?: SingleSided`

        Model representing a single-sided plastic card.

        - `html?: string`

          The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

        - `pdf?: string | Uploadable`

          A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

          - `string`

          - `Uploadable`

        - `template?: string`

          The template ID for the single-sided plastic card.

    - `returnEnvelope?: string`

      Body param: The return envelope (ID) sent out with the letter, if any.

    - `sendDate?: string`

      Body param: This order will transition from `ready` to `printing` on the day after this date. You can use this parameter to schedule orders for a future date.

    - `size?: LetterSize`

      Body param: Enum representing the supported letter sizes.

      - `"us_letter"`

      - `"a4"`

    - `idempotencyKey?: string`

      Header param

  - `LetterCreateWithHTML extends LetterCreateParamsBase`

  - `LetterCreateWithTemplate extends LetterCreateParamsBase`

  - `LetterCreateWithPdf extends LetterCreateParamsBase`

### Returns

- `LetterCreateResponse = Letter | Letter`

  - `Letter`

    - `id: string`

      A unique ID prefixed with letter_

    - `addressPlacement: AddressPlacement`

      Enum representing the placement of the address on the letter.

      - `"top_first_page"`

      - `"insert_blank_page"`

    - `color: boolean`

      Indicates if the letter is in color.

    - `createdAt: string`

      The UTC time at which this resource was created.

    - `doubleSided: boolean`

      Indicates if the letter is double-sided.

    - `envelope: string`

      The envelope (ID) for the letter or the default `standard` envelope.

    - `from: Contact`

      The contact information of the sender.

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

    - `live: boolean`

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

    - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

      The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

      - `"first_class"`

      - `"standard_class"`

      - `"express"`

      - `"certified"`

      - `"certified_return_receipt"`

      - `"registered"`

      - `"usps_first_class"`

      - `"usps_standard_class"`

      - `"usps_eddm"`

      - `"usps_express_2_day"`

      - `"usps_express_3_day"`

      - `"usps_first_class_certified"`

      - `"usps_first_class_certified_return_receipt"`

      - `"usps_first_class_registered"`

      - `"usps_express_3_day_signature_confirmation"`

      - `"usps_express_3_day_certified"`

      - `"usps_express_3_day_certified_return_receipt"`

      - `"ca_post_lettermail"`

      - `"ca_post_personalized"`

      - `"ca_post_neighbourhood_mail"`

      - `"ups_express_overnight"`

      - `"ups_express_2_day"`

      - `"ups_express_3_day"`

      - `"royal_mail_first_class"`

      - `"royal_mail_second_class"`

      - `"au_post_second_class"`

    - `object: "letter"`

      Always `letter`.

      - `"letter"`

    - `sendDate: string`

      This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

    - `size: LetterSize`

      Enum representing the supported letter sizes.

      - `"us_letter"`

      - `"a4"`

    - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

      See `OrderStatus` for more details on the status of this order.

      - `"ready"`

      - `"printing"`

      - `"processed_for_delivery"`

      - `"completed"`

      - `"cancelled"`

    - `to: Contact`

      The recipient of this order. This will be provided even if you delete the underlying contact.

    - `updatedAt: string`

      The UTC time at which this resource was last updated.

    - `attachedPDF?: AttachedPdf`

      Model representing an attached PDF.

      - `file: string | Uploadable`

        The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

        - `string`

        - `Uploadable`

      - `placement: "before_template" | "after_template"`

        Enum representing the placement of the attached PDF.

        - `"before_template"`

        - `"after_template"`

    - `cancellation?: Cancellation`

      The cancellation details of this order. Populated if the order has been cancelled.

      - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

        The reason for the cancellation.

        - `"user_initiated"`

        - `"invalid_content"`

        - `"invalid_order_mailing_class"`

      - `cancelledByUser?: string`

        The user ID who cancelled the order.

      - `note?: string`

        An optional note provided by the user who cancelled the order.

    - `description?: string`

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

    - `html?: string`

      The HTML content for the letter. You can supply _either_ this or `template` but not both.

    - `imbDate?: string`

      The last date that the IMB status was updated. See `imbStatus` for more details.

    - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

      The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

      - `"entered_mail_stream"`

      - `"out_for_delivery"`

      - `"returned_to_sender"`

    - `imbZIPCode?: string`

      The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

      These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

      See the section on Metadata.

    - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

      Premium paper selection used for this letter.

      Available values include:

      - `standard`
      - `premium_paper_letter_standard_white_70lb`
      - `premium_paper_letter_standard_white_80lb`

      Not all premium paper options are enabled for all organizations.
      If omitted, the organization default letter paper is used when configured; otherwise `standard`.

      - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

        - `"standard"`

        - `"premium_paper_letter_standard_white_70lb"`

        - `"premium_paper_letter_standard_white_80lb"`

      - `(string & {})`

    - `pdfWorkflowRun?: string`

      The ID of the PDF workflow run that created the letter, if any.

    - `perforatedPage?: 1`

      If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

      - `1`

    - `plasticCard?: PlasticCard`

      Model representing a plastic card.

      - `size: "standard"`

        Enum representing the size of the plastic card.

        - `"standard"`

      - `doubleSided?: DoubleSided`

        Model representing a double-sided plastic card.

        - `backHTML?: string`

          The HTML content for the back side of the double-sided plastic card.

        - `backTemplate?: string`

          The template ID for the back side of the double-sided plastic card.

        - `frontHTML?: string`

          The HTML content for the front side of the double-sided plastic card.

        - `frontTemplate?: string`

          The template ID for the front side of the double-sided plastic card.

        - `pdf?: string | Uploadable`

          A URL pointing to a PDF file for the double-sided plastic card or the file itself.

          - `string`

          - `Uploadable`

      - `singleSided?: SingleSided`

        Model representing a single-sided plastic card.

        - `html?: string`

          The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

        - `pdf?: string | Uploadable`

          A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

          - `string`

          - `Uploadable`

        - `template?: string`

          The template ID for the single-sided plastic card.

    - `returnEnvelope?: string`

      The return envelope (ID) sent out with the letter, if any.

    - `template?: string`

      The template ID used for the letter. You can supply _either_ this or `html` but not both.

    - `trackingNumber?: string`

      The tracking number of this order. Populated after an express/certified order has been processed for delivery.

    - `uploadedPDF?: string`

      If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

    - `url?: string`

      PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

      This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

  - `Letter`

### 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 letter = await client.printMail.letters.create({
  from: 'contact_123',
  html: '<html>Content</html>',
  to: 'contact_123',
  paper: 'standard',
});

console.log(letter);
```

#### Response

```json
{
  "id": "letter_sqF12lZ1VlBb",
  "addressPlacement": "top_first_page",
  "color": true,
  "createdAt": "2019-12-27T18:11:19.117Z",
  "doubleSided": true,
  "envelope": "envelope",
  "from": {
    "id": "contact_sqF12lZ1VlBb",
    "addressLine1": "addressLine1",
    "addressStatus": "verified",
    "countryCode": "countryCode",
    "createdAt": "2019-12-27T18:11:19.117Z",
    "live": true,
    "object": "contact",
    "updatedAt": "2019-12-27T18:11:19.117Z",
    "addressErrors": "addressErrors",
    "addressLine2": "addressLine2",
    "city": "city",
    "companyName": "companyName",
    "description": "description",
    "email": "email",
    "firstName": "firstName",
    "forceVerifiedStatus": true,
    "jobTitle": "jobTitle",
    "lastName": "lastName",
    "metadata": {
      "foo": "bar"
    },
    "phoneNumber": "phoneNumber",
    "postalOrZip": "postalOrZip",
    "provinceOrState": "provinceOrState",
    "secret": true,
    "skipVerification": true
  },
  "live": true,
  "mailingClass": "first_class",
  "object": "letter",
  "sendDate": "2019-12-27T18:11:19.117Z",
  "size": "us_letter",
  "status": "ready",
  "to": {
    "id": "contact_sqF12lZ1VlBb",
    "addressLine1": "addressLine1",
    "addressStatus": "verified",
    "countryCode": "countryCode",
    "createdAt": "2019-12-27T18:11:19.117Z",
    "live": true,
    "object": "contact",
    "updatedAt": "2019-12-27T18:11:19.117Z",
    "addressErrors": "addressErrors",
    "addressLine2": "addressLine2",
    "city": "city",
    "companyName": "companyName",
    "description": "description",
    "email": "email",
    "firstName": "firstName",
    "forceVerifiedStatus": true,
    "jobTitle": "jobTitle",
    "lastName": "lastName",
    "metadata": {
      "foo": "bar"
    },
    "phoneNumber": "phoneNumber",
    "postalOrZip": "postalOrZip",
    "provinceOrState": "provinceOrState",
    "secret": true,
    "skipVerification": true
  },
  "updatedAt": "2019-12-27T18:11:19.117Z",
  "attachedPDF": {
    "file": "https://example.com",
    "placement": "before_template"
  },
  "cancellation": {
    "reason": "user_initiated",
    "cancelledByUser": "cancelledByUser",
    "note": "note"
  },
  "description": "description",
  "html": "html",
  "imbDate": "2019-12-27T18:11:19.117Z",
  "imbStatus": "entered_mail_stream",
  "imbZIPCode": "imbZIPCode",
  "mergeVariables": {
    "foo": "bar"
  },
  "metadata": {
    "foo": "bar"
  },
  "paper": "standard",
  "pdfWorkflowRun": "pdfWorkflowRun",
  "perforatedPage": 1,
  "plasticCard": {
    "size": "standard",
    "doubleSided": {
      "backHTML": "backHTML",
      "backTemplate": "backTemplate",
      "frontHTML": "frontHTML",
      "frontTemplate": "frontTemplate",
      "pdf": "https://example.com"
    },
    "singleSided": {
      "html": "html",
      "pdf": "https://example.com",
      "template": "template"
    }
  },
  "returnEnvelope": "returnEnvelope",
  "template": "template",
  "trackingNumber": "trackingNumber",
  "uploadedPDF": "https://example.com",
  "url": "https://example.com"
}
```

## List Letters

`client.printMail.letters.list(LetterListParamsquery?, RequestOptionsoptions?): SkipLimit<Letter>`

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

Get a list of letters.

### Parameters

- `query: LetterListParams`

  - `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

- `Letter`

  - `id: string`

    A unique ID prefixed with letter_

  - `addressPlacement: AddressPlacement`

    Enum representing the placement of the address on the letter.

    - `"top_first_page"`

    - `"insert_blank_page"`

  - `color: boolean`

    Indicates if the letter is in color.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `doubleSided: boolean`

    Indicates if the letter is double-sided.

  - `envelope: string`

    The envelope (ID) for the letter or the default `standard` envelope.

  - `from: Contact`

    The contact information of the sender.

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

  - `live: boolean`

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

  - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

    The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

    - `"first_class"`

    - `"standard_class"`

    - `"express"`

    - `"certified"`

    - `"certified_return_receipt"`

    - `"registered"`

    - `"usps_first_class"`

    - `"usps_standard_class"`

    - `"usps_eddm"`

    - `"usps_express_2_day"`

    - `"usps_express_3_day"`

    - `"usps_first_class_certified"`

    - `"usps_first_class_certified_return_receipt"`

    - `"usps_first_class_registered"`

    - `"usps_express_3_day_signature_confirmation"`

    - `"usps_express_3_day_certified"`

    - `"usps_express_3_day_certified_return_receipt"`

    - `"ca_post_lettermail"`

    - `"ca_post_personalized"`

    - `"ca_post_neighbourhood_mail"`

    - `"ups_express_overnight"`

    - `"ups_express_2_day"`

    - `"ups_express_3_day"`

    - `"royal_mail_first_class"`

    - `"royal_mail_second_class"`

    - `"au_post_second_class"`

  - `object: "letter"`

    Always `letter`.

    - `"letter"`

  - `sendDate: string`

    This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

  - `size: LetterSize`

    Enum representing the supported letter sizes.

    - `"us_letter"`

    - `"a4"`

  - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

    See `OrderStatus` for more details on the status of this order.

    - `"ready"`

    - `"printing"`

    - `"processed_for_delivery"`

    - `"completed"`

    - `"cancelled"`

  - `to: Contact`

    The recipient of this order. This will be provided even if you delete the underlying contact.

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `attachedPDF?: AttachedPdf`

    Model representing an attached PDF.

    - `file: string | Uploadable`

      The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

      - `string`

      - `Uploadable`

    - `placement: "before_template" | "after_template"`

      Enum representing the placement of the attached PDF.

      - `"before_template"`

      - `"after_template"`

  - `cancellation?: Cancellation`

    The cancellation details of this order. Populated if the order has been cancelled.

    - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

      The reason for the cancellation.

      - `"user_initiated"`

      - `"invalid_content"`

      - `"invalid_order_mailing_class"`

    - `cancelledByUser?: string`

      The user ID who cancelled the order.

    - `note?: string`

      An optional note provided by the user who cancelled the order.

  - `description?: string`

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

  - `html?: string`

    The HTML content for the letter. You can supply _either_ this or `template` but not both.

  - `imbDate?: string`

    The last date that the IMB status was updated. See `imbStatus` for more details.

  - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

    The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

    - `"entered_mail_stream"`

    - `"out_for_delivery"`

    - `"returned_to_sender"`

  - `imbZIPCode?: string`

    The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

    These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

    See the section on Metadata.

  - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

    Premium paper selection used for this letter.

    Available values include:

    - `standard`
    - `premium_paper_letter_standard_white_70lb`
    - `premium_paper_letter_standard_white_80lb`

    Not all premium paper options are enabled for all organizations.
    If omitted, the organization default letter paper is used when configured; otherwise `standard`.

    - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

      - `"standard"`

      - `"premium_paper_letter_standard_white_70lb"`

      - `"premium_paper_letter_standard_white_80lb"`

    - `(string & {})`

  - `pdfWorkflowRun?: string`

    The ID of the PDF workflow run that created the letter, if any.

  - `perforatedPage?: 1`

    If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

    - `1`

  - `plasticCard?: PlasticCard`

    Model representing a plastic card.

    - `size: "standard"`

      Enum representing the size of the plastic card.

      - `"standard"`

    - `doubleSided?: DoubleSided`

      Model representing a double-sided plastic card.

      - `backHTML?: string`

        The HTML content for the back side of the double-sided plastic card.

      - `backTemplate?: string`

        The template ID for the back side of the double-sided plastic card.

      - `frontHTML?: string`

        The HTML content for the front side of the double-sided plastic card.

      - `frontTemplate?: string`

        The template ID for the front side of the double-sided plastic card.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the double-sided plastic card or the file itself.

        - `string`

        - `Uploadable`

    - `singleSided?: SingleSided`

      Model representing a single-sided plastic card.

      - `html?: string`

        The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

        - `string`

        - `Uploadable`

      - `template?: string`

        The template ID for the single-sided plastic card.

  - `returnEnvelope?: string`

    The return envelope (ID) sent out with the letter, if any.

  - `template?: string`

    The template ID used for the letter. You can supply _either_ this or `html` but not both.

  - `trackingNumber?: string`

    The tracking number of this order. Populated after an express/certified order has been processed for delivery.

  - `uploadedPDF?: string`

    If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

  - `url?: string`

    PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

    This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

### 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 letter of client.printMail.letters.list()) {
  console.log(letter.id);
}
```

#### Response

```json
{
  "object": "list",
  "limit": 10,
  "skip": 0,
  "totalCount": 1,
  "data": [
    {
      "id": "letter_123456",
      "object": "letter",
      "status": "ready",
      "live": false,
      "to": {
        "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"
      },
      "from": {
        "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"
      },
      "size": "us_letter",
      "doubleSided": true,
      "color": false,
      "paper": "standard",
      "sendDate": "2020-11-12T23:23:47.974Z",
      "createdAt": "2020-11-12T23:23:47.974Z",
      "updatedAt": "2020-11-12T23:23:47.974Z",
      "mailingClass": "first_class",
      "envelope": "standard",
      "addressPlacement": "top_first_page",
      "html": "<html>Content</html>"
    }
  ]
}
```

## Get Letter

`client.printMail.letters.retrieve(stringid, RequestOptionsoptions?): Letter`

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

Retrieve a letter by ID.

### Parameters

- `id: string`

### Returns

- `Letter`

  - `id: string`

    A unique ID prefixed with letter_

  - `addressPlacement: AddressPlacement`

    Enum representing the placement of the address on the letter.

    - `"top_first_page"`

    - `"insert_blank_page"`

  - `color: boolean`

    Indicates if the letter is in color.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `doubleSided: boolean`

    Indicates if the letter is double-sided.

  - `envelope: string`

    The envelope (ID) for the letter or the default `standard` envelope.

  - `from: Contact`

    The contact information of the sender.

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

  - `live: boolean`

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

  - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

    The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

    - `"first_class"`

    - `"standard_class"`

    - `"express"`

    - `"certified"`

    - `"certified_return_receipt"`

    - `"registered"`

    - `"usps_first_class"`

    - `"usps_standard_class"`

    - `"usps_eddm"`

    - `"usps_express_2_day"`

    - `"usps_express_3_day"`

    - `"usps_first_class_certified"`

    - `"usps_first_class_certified_return_receipt"`

    - `"usps_first_class_registered"`

    - `"usps_express_3_day_signature_confirmation"`

    - `"usps_express_3_day_certified"`

    - `"usps_express_3_day_certified_return_receipt"`

    - `"ca_post_lettermail"`

    - `"ca_post_personalized"`

    - `"ca_post_neighbourhood_mail"`

    - `"ups_express_overnight"`

    - `"ups_express_2_day"`

    - `"ups_express_3_day"`

    - `"royal_mail_first_class"`

    - `"royal_mail_second_class"`

    - `"au_post_second_class"`

  - `object: "letter"`

    Always `letter`.

    - `"letter"`

  - `sendDate: string`

    This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

  - `size: LetterSize`

    Enum representing the supported letter sizes.

    - `"us_letter"`

    - `"a4"`

  - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

    See `OrderStatus` for more details on the status of this order.

    - `"ready"`

    - `"printing"`

    - `"processed_for_delivery"`

    - `"completed"`

    - `"cancelled"`

  - `to: Contact`

    The recipient of this order. This will be provided even if you delete the underlying contact.

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `attachedPDF?: AttachedPdf`

    Model representing an attached PDF.

    - `file: string | Uploadable`

      The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

      - `string`

      - `Uploadable`

    - `placement: "before_template" | "after_template"`

      Enum representing the placement of the attached PDF.

      - `"before_template"`

      - `"after_template"`

  - `cancellation?: Cancellation`

    The cancellation details of this order. Populated if the order has been cancelled.

    - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

      The reason for the cancellation.

      - `"user_initiated"`

      - `"invalid_content"`

      - `"invalid_order_mailing_class"`

    - `cancelledByUser?: string`

      The user ID who cancelled the order.

    - `note?: string`

      An optional note provided by the user who cancelled the order.

  - `description?: string`

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

  - `html?: string`

    The HTML content for the letter. You can supply _either_ this or `template` but not both.

  - `imbDate?: string`

    The last date that the IMB status was updated. See `imbStatus` for more details.

  - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

    The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

    - `"entered_mail_stream"`

    - `"out_for_delivery"`

    - `"returned_to_sender"`

  - `imbZIPCode?: string`

    The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

    These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

    See the section on Metadata.

  - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

    Premium paper selection used for this letter.

    Available values include:

    - `standard`
    - `premium_paper_letter_standard_white_70lb`
    - `premium_paper_letter_standard_white_80lb`

    Not all premium paper options are enabled for all organizations.
    If omitted, the organization default letter paper is used when configured; otherwise `standard`.

    - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

      - `"standard"`

      - `"premium_paper_letter_standard_white_70lb"`

      - `"premium_paper_letter_standard_white_80lb"`

    - `(string & {})`

  - `pdfWorkflowRun?: string`

    The ID of the PDF workflow run that created the letter, if any.

  - `perforatedPage?: 1`

    If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

    - `1`

  - `plasticCard?: PlasticCard`

    Model representing a plastic card.

    - `size: "standard"`

      Enum representing the size of the plastic card.

      - `"standard"`

    - `doubleSided?: DoubleSided`

      Model representing a double-sided plastic card.

      - `backHTML?: string`

        The HTML content for the back side of the double-sided plastic card.

      - `backTemplate?: string`

        The template ID for the back side of the double-sided plastic card.

      - `frontHTML?: string`

        The HTML content for the front side of the double-sided plastic card.

      - `frontTemplate?: string`

        The template ID for the front side of the double-sided plastic card.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the double-sided plastic card or the file itself.

        - `string`

        - `Uploadable`

    - `singleSided?: SingleSided`

      Model representing a single-sided plastic card.

      - `html?: string`

        The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

        - `string`

        - `Uploadable`

      - `template?: string`

        The template ID for the single-sided plastic card.

  - `returnEnvelope?: string`

    The return envelope (ID) sent out with the letter, if any.

  - `template?: string`

    The template ID used for the letter. You can supply _either_ this or `html` but not both.

  - `trackingNumber?: string`

    The tracking number of this order. Populated after an express/certified order has been processed for delivery.

  - `uploadedPDF?: string`

    If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

  - `url?: string`

    PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

    This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

### 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 letter = await client.printMail.letters.retrieve('id');

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

#### Response

```json
{
  "id": "letter_123456",
  "object": "letter",
  "status": "ready",
  "live": false,
  "to": {
    "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"
  },
  "from": {
    "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"
  },
  "size": "us_letter",
  "doubleSided": true,
  "color": false,
  "paper": "standard",
  "sendDate": "2020-11-12T23:23:47.974Z",
  "createdAt": "2020-11-12T23:23:47.974Z",
  "updatedAt": "2020-11-12T23:23:47.974Z",
  "mailingClass": "first_class",
  "envelope": "standard",
  "addressPlacement": "top_first_page",
  "html": "<html>Content</html>"
}
```

## Cancel Letter

`client.printMail.letters.delete(stringid, RequestOptionsoptions?): Letter`

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

Cancel a letter by ID. Note that this operation cannot be undone.

### Parameters

- `id: string`

### Returns

- `Letter`

  - `id: string`

    A unique ID prefixed with letter_

  - `addressPlacement: AddressPlacement`

    Enum representing the placement of the address on the letter.

    - `"top_first_page"`

    - `"insert_blank_page"`

  - `color: boolean`

    Indicates if the letter is in color.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `doubleSided: boolean`

    Indicates if the letter is double-sided.

  - `envelope: string`

    The envelope (ID) for the letter or the default `standard` envelope.

  - `from: Contact`

    The contact information of the sender.

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

  - `live: boolean`

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

  - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

    The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

    - `"first_class"`

    - `"standard_class"`

    - `"express"`

    - `"certified"`

    - `"certified_return_receipt"`

    - `"registered"`

    - `"usps_first_class"`

    - `"usps_standard_class"`

    - `"usps_eddm"`

    - `"usps_express_2_day"`

    - `"usps_express_3_day"`

    - `"usps_first_class_certified"`

    - `"usps_first_class_certified_return_receipt"`

    - `"usps_first_class_registered"`

    - `"usps_express_3_day_signature_confirmation"`

    - `"usps_express_3_day_certified"`

    - `"usps_express_3_day_certified_return_receipt"`

    - `"ca_post_lettermail"`

    - `"ca_post_personalized"`

    - `"ca_post_neighbourhood_mail"`

    - `"ups_express_overnight"`

    - `"ups_express_2_day"`

    - `"ups_express_3_day"`

    - `"royal_mail_first_class"`

    - `"royal_mail_second_class"`

    - `"au_post_second_class"`

  - `object: "letter"`

    Always `letter`.

    - `"letter"`

  - `sendDate: string`

    This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

  - `size: LetterSize`

    Enum representing the supported letter sizes.

    - `"us_letter"`

    - `"a4"`

  - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

    See `OrderStatus` for more details on the status of this order.

    - `"ready"`

    - `"printing"`

    - `"processed_for_delivery"`

    - `"completed"`

    - `"cancelled"`

  - `to: Contact`

    The recipient of this order. This will be provided even if you delete the underlying contact.

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `attachedPDF?: AttachedPdf`

    Model representing an attached PDF.

    - `file: string | Uploadable`

      The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

      - `string`

      - `Uploadable`

    - `placement: "before_template" | "after_template"`

      Enum representing the placement of the attached PDF.

      - `"before_template"`

      - `"after_template"`

  - `cancellation?: Cancellation`

    The cancellation details of this order. Populated if the order has been cancelled.

    - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

      The reason for the cancellation.

      - `"user_initiated"`

      - `"invalid_content"`

      - `"invalid_order_mailing_class"`

    - `cancelledByUser?: string`

      The user ID who cancelled the order.

    - `note?: string`

      An optional note provided by the user who cancelled the order.

  - `description?: string`

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

  - `html?: string`

    The HTML content for the letter. You can supply _either_ this or `template` but not both.

  - `imbDate?: string`

    The last date that the IMB status was updated. See `imbStatus` for more details.

  - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

    The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

    - `"entered_mail_stream"`

    - `"out_for_delivery"`

    - `"returned_to_sender"`

  - `imbZIPCode?: string`

    The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

    These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

    See the section on Metadata.

  - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

    Premium paper selection used for this letter.

    Available values include:

    - `standard`
    - `premium_paper_letter_standard_white_70lb`
    - `premium_paper_letter_standard_white_80lb`

    Not all premium paper options are enabled for all organizations.
    If omitted, the organization default letter paper is used when configured; otherwise `standard`.

    - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

      - `"standard"`

      - `"premium_paper_letter_standard_white_70lb"`

      - `"premium_paper_letter_standard_white_80lb"`

    - `(string & {})`

  - `pdfWorkflowRun?: string`

    The ID of the PDF workflow run that created the letter, if any.

  - `perforatedPage?: 1`

    If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

    - `1`

  - `plasticCard?: PlasticCard`

    Model representing a plastic card.

    - `size: "standard"`

      Enum representing the size of the plastic card.

      - `"standard"`

    - `doubleSided?: DoubleSided`

      Model representing a double-sided plastic card.

      - `backHTML?: string`

        The HTML content for the back side of the double-sided plastic card.

      - `backTemplate?: string`

        The template ID for the back side of the double-sided plastic card.

      - `frontHTML?: string`

        The HTML content for the front side of the double-sided plastic card.

      - `frontTemplate?: string`

        The template ID for the front side of the double-sided plastic card.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the double-sided plastic card or the file itself.

        - `string`

        - `Uploadable`

    - `singleSided?: SingleSided`

      Model representing a single-sided plastic card.

      - `html?: string`

        The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

        - `string`

        - `Uploadable`

      - `template?: string`

        The template ID for the single-sided plastic card.

  - `returnEnvelope?: string`

    The return envelope (ID) sent out with the letter, if any.

  - `template?: string`

    The template ID used for the letter. You can supply _either_ this or `html` but not both.

  - `trackingNumber?: string`

    The tracking number of this order. Populated after an express/certified order has been processed for delivery.

  - `uploadedPDF?: string`

    If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

  - `url?: string`

    PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

    This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

### 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 letter = await client.printMail.letters.delete('id');

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

#### Response

```json
{
  "id": "letter_123456",
  "object": "letter",
  "status": "cancelled",
  "live": false,
  "to": {
    "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"
  },
  "from": {
    "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"
  },
  "size": "us_letter",
  "doubleSided": true,
  "color": false,
  "paper": "standard",
  "sendDate": "2020-11-12T23:23:47.974Z",
  "createdAt": "2020-11-12T23:23:47.974Z",
  "updatedAt": "2020-11-12T23:23:47.974Z",
  "mailingClass": "first_class",
  "envelope": "standard",
  "addressPlacement": "top_first_page",
  "html": "<html>Content</html>"
}
```

## Get Letter Preview

`client.printMail.letters.retrieveURL(stringid, RequestOptionsoptions?): LetterRetrieveURLResponse`

**get** `/print-mail/v1/letters/{id}/url`

Retrieve a letter preview URL.

This is only available for customers with our document management addon, which offers
document generation and hosting capabilities. This endpoint has a much higher rate limit
than the regular order retrieval endpoint, so it is suitable for customer-facing use-cases.

### Parameters

- `id: string`

### Returns

- `LetterRetrieveURLResponse`

  - `id: string`

    A unique ID prefixed with letter_

  - `object: string`

  - `url: string`

    A signed URL linking to the order preview PDF. The link remains valid for 15 minutes from the time of the API call.

### 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 response = await client.printMail.letters.retrieveURL('id');

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

#### Response

```json
{
  "id": "letter_123456",
  "object": "letter_url",
  "url": "https://pg-prod-bucket-1.s3.amazonaws.com/test/letter_uzTtdAPiBVC25hjEYDvyLk?AWSAccessKeyId=AKIA5GFUILSULWTWCR64&Expires=1736192587&Signature=GS6kJK3fgWWy49jq1Yb%2FRn%2BQjD4%3D"
}
```

## Cancel Letter With Note

`client.printMail.letters.cancel(stringid, LetterCancelParamsbody, RequestOptionsoptions?): Letter`

**post** `/print-mail/v1/letters/{id}/cancellation`

Cancel a letter by ID with a note. Note that this operation
cannot be undone and that only letters with a status of `ready` can be
cancelled.

### Parameters

- `id: string`

- `body: LetterCancelParams`

  - `note: string`

### Returns

- `Letter`

  - `id: string`

    A unique ID prefixed with letter_

  - `addressPlacement: AddressPlacement`

    Enum representing the placement of the address on the letter.

    - `"top_first_page"`

    - `"insert_blank_page"`

  - `color: boolean`

    Indicates if the letter is in color.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `doubleSided: boolean`

    Indicates if the letter is double-sided.

  - `envelope: string`

    The envelope (ID) for the letter or the default `standard` envelope.

  - `from: Contact`

    The contact information of the sender.

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

  - `live: boolean`

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

  - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

    The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

    - `"first_class"`

    - `"standard_class"`

    - `"express"`

    - `"certified"`

    - `"certified_return_receipt"`

    - `"registered"`

    - `"usps_first_class"`

    - `"usps_standard_class"`

    - `"usps_eddm"`

    - `"usps_express_2_day"`

    - `"usps_express_3_day"`

    - `"usps_first_class_certified"`

    - `"usps_first_class_certified_return_receipt"`

    - `"usps_first_class_registered"`

    - `"usps_express_3_day_signature_confirmation"`

    - `"usps_express_3_day_certified"`

    - `"usps_express_3_day_certified_return_receipt"`

    - `"ca_post_lettermail"`

    - `"ca_post_personalized"`

    - `"ca_post_neighbourhood_mail"`

    - `"ups_express_overnight"`

    - `"ups_express_2_day"`

    - `"ups_express_3_day"`

    - `"royal_mail_first_class"`

    - `"royal_mail_second_class"`

    - `"au_post_second_class"`

  - `object: "letter"`

    Always `letter`.

    - `"letter"`

  - `sendDate: string`

    This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

  - `size: LetterSize`

    Enum representing the supported letter sizes.

    - `"us_letter"`

    - `"a4"`

  - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

    See `OrderStatus` for more details on the status of this order.

    - `"ready"`

    - `"printing"`

    - `"processed_for_delivery"`

    - `"completed"`

    - `"cancelled"`

  - `to: Contact`

    The recipient of this order. This will be provided even if you delete the underlying contact.

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `attachedPDF?: AttachedPdf`

    Model representing an attached PDF.

    - `file: string | Uploadable`

      The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

      - `string`

      - `Uploadable`

    - `placement: "before_template" | "after_template"`

      Enum representing the placement of the attached PDF.

      - `"before_template"`

      - `"after_template"`

  - `cancellation?: Cancellation`

    The cancellation details of this order. Populated if the order has been cancelled.

    - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

      The reason for the cancellation.

      - `"user_initiated"`

      - `"invalid_content"`

      - `"invalid_order_mailing_class"`

    - `cancelledByUser?: string`

      The user ID who cancelled the order.

    - `note?: string`

      An optional note provided by the user who cancelled the order.

  - `description?: string`

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

  - `html?: string`

    The HTML content for the letter. You can supply _either_ this or `template` but not both.

  - `imbDate?: string`

    The last date that the IMB status was updated. See `imbStatus` for more details.

  - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

    The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

    - `"entered_mail_stream"`

    - `"out_for_delivery"`

    - `"returned_to_sender"`

  - `imbZIPCode?: string`

    The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

    These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

    See the section on Metadata.

  - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

    Premium paper selection used for this letter.

    Available values include:

    - `standard`
    - `premium_paper_letter_standard_white_70lb`
    - `premium_paper_letter_standard_white_80lb`

    Not all premium paper options are enabled for all organizations.
    If omitted, the organization default letter paper is used when configured; otherwise `standard`.

    - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

      - `"standard"`

      - `"premium_paper_letter_standard_white_70lb"`

      - `"premium_paper_letter_standard_white_80lb"`

    - `(string & {})`

  - `pdfWorkflowRun?: string`

    The ID of the PDF workflow run that created the letter, if any.

  - `perforatedPage?: 1`

    If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

    - `1`

  - `plasticCard?: PlasticCard`

    Model representing a plastic card.

    - `size: "standard"`

      Enum representing the size of the plastic card.

      - `"standard"`

    - `doubleSided?: DoubleSided`

      Model representing a double-sided plastic card.

      - `backHTML?: string`

        The HTML content for the back side of the double-sided plastic card.

      - `backTemplate?: string`

        The template ID for the back side of the double-sided plastic card.

      - `frontHTML?: string`

        The HTML content for the front side of the double-sided plastic card.

      - `frontTemplate?: string`

        The template ID for the front side of the double-sided plastic card.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the double-sided plastic card or the file itself.

        - `string`

        - `Uploadable`

    - `singleSided?: SingleSided`

      Model representing a single-sided plastic card.

      - `html?: string`

        The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

        - `string`

        - `Uploadable`

      - `template?: string`

        The template ID for the single-sided plastic card.

  - `returnEnvelope?: string`

    The return envelope (ID) sent out with the letter, if any.

  - `template?: string`

    The template ID used for the letter. You can supply _either_ this or `html` but not both.

  - `trackingNumber?: string`

    The tracking number of this order. Populated after an express/certified order has been processed for delivery.

  - `uploadedPDF?: string`

    If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

  - `url?: string`

    PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

    This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

### 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 letter = await client.printMail.letters.cancel('id', { note: 'Cancelling this letter' });

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

#### Response

```json
{
  "id": "letter_123456",
  "object": "letter",
  "status": "cancelled",
  "live": false,
  "to": {
    "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"
  },
  "from": {
    "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"
  },
  "size": "us_letter",
  "doubleSided": true,
  "color": false,
  "paper": "standard",
  "sendDate": "2020-11-12T23:23:47.974Z",
  "createdAt": "2020-11-12T23:23:47.974Z",
  "updatedAt": "2020-11-12T23:23:47.974Z",
  "mailingClass": "first_class",
  "envelope": "standard",
  "addressPlacement": "top_first_page",
  "html": "<html>Content</html>"
}
```

## Progress Status

`client.printMail.letters.progress(stringid, RequestOptionsoptions?): Letter`

**post** `/print-mail/v1/letters/{id}/progressions`

Progresses a letter's `status` to the next stage. This is only
available in test mode and can be used to simulate how a live order would
progress through the different statuses.

Note: this will fail with an `invalid_progression_error` if the status
is one of `completed` or `cancelled`.

### Parameters

- `id: string`

### Returns

- `Letter`

  - `id: string`

    A unique ID prefixed with letter_

  - `addressPlacement: AddressPlacement`

    Enum representing the placement of the address on the letter.

    - `"top_first_page"`

    - `"insert_blank_page"`

  - `color: boolean`

    Indicates if the letter is in color.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `doubleSided: boolean`

    Indicates if the letter is double-sided.

  - `envelope: string`

    The envelope (ID) for the letter or the default `standard` envelope.

  - `from: Contact`

    The contact information of the sender.

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

  - `live: boolean`

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

  - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

    The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

    - `"first_class"`

    - `"standard_class"`

    - `"express"`

    - `"certified"`

    - `"certified_return_receipt"`

    - `"registered"`

    - `"usps_first_class"`

    - `"usps_standard_class"`

    - `"usps_eddm"`

    - `"usps_express_2_day"`

    - `"usps_express_3_day"`

    - `"usps_first_class_certified"`

    - `"usps_first_class_certified_return_receipt"`

    - `"usps_first_class_registered"`

    - `"usps_express_3_day_signature_confirmation"`

    - `"usps_express_3_day_certified"`

    - `"usps_express_3_day_certified_return_receipt"`

    - `"ca_post_lettermail"`

    - `"ca_post_personalized"`

    - `"ca_post_neighbourhood_mail"`

    - `"ups_express_overnight"`

    - `"ups_express_2_day"`

    - `"ups_express_3_day"`

    - `"royal_mail_first_class"`

    - `"royal_mail_second_class"`

    - `"au_post_second_class"`

  - `object: "letter"`

    Always `letter`.

    - `"letter"`

  - `sendDate: string`

    This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

  - `size: LetterSize`

    Enum representing the supported letter sizes.

    - `"us_letter"`

    - `"a4"`

  - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

    See `OrderStatus` for more details on the status of this order.

    - `"ready"`

    - `"printing"`

    - `"processed_for_delivery"`

    - `"completed"`

    - `"cancelled"`

  - `to: Contact`

    The recipient of this order. This will be provided even if you delete the underlying contact.

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `attachedPDF?: AttachedPdf`

    Model representing an attached PDF.

    - `file: string | Uploadable`

      The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

      - `string`

      - `Uploadable`

    - `placement: "before_template" | "after_template"`

      Enum representing the placement of the attached PDF.

      - `"before_template"`

      - `"after_template"`

  - `cancellation?: Cancellation`

    The cancellation details of this order. Populated if the order has been cancelled.

    - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

      The reason for the cancellation.

      - `"user_initiated"`

      - `"invalid_content"`

      - `"invalid_order_mailing_class"`

    - `cancelledByUser?: string`

      The user ID who cancelled the order.

    - `note?: string`

      An optional note provided by the user who cancelled the order.

  - `description?: string`

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

  - `html?: string`

    The HTML content for the letter. You can supply _either_ this or `template` but not both.

  - `imbDate?: string`

    The last date that the IMB status was updated. See `imbStatus` for more details.

  - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

    The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

    - `"entered_mail_stream"`

    - `"out_for_delivery"`

    - `"returned_to_sender"`

  - `imbZIPCode?: string`

    The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

    These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

    See the section on Metadata.

  - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

    Premium paper selection used for this letter.

    Available values include:

    - `standard`
    - `premium_paper_letter_standard_white_70lb`
    - `premium_paper_letter_standard_white_80lb`

    Not all premium paper options are enabled for all organizations.
    If omitted, the organization default letter paper is used when configured; otherwise `standard`.

    - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

      - `"standard"`

      - `"premium_paper_letter_standard_white_70lb"`

      - `"premium_paper_letter_standard_white_80lb"`

    - `(string & {})`

  - `pdfWorkflowRun?: string`

    The ID of the PDF workflow run that created the letter, if any.

  - `perforatedPage?: 1`

    If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

    - `1`

  - `plasticCard?: PlasticCard`

    Model representing a plastic card.

    - `size: "standard"`

      Enum representing the size of the plastic card.

      - `"standard"`

    - `doubleSided?: DoubleSided`

      Model representing a double-sided plastic card.

      - `backHTML?: string`

        The HTML content for the back side of the double-sided plastic card.

      - `backTemplate?: string`

        The template ID for the back side of the double-sided plastic card.

      - `frontHTML?: string`

        The HTML content for the front side of the double-sided plastic card.

      - `frontTemplate?: string`

        The template ID for the front side of the double-sided plastic card.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the double-sided plastic card or the file itself.

        - `string`

        - `Uploadable`

    - `singleSided?: SingleSided`

      Model representing a single-sided plastic card.

      - `html?: string`

        The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

        - `string`

        - `Uploadable`

      - `template?: string`

        The template ID for the single-sided plastic card.

  - `returnEnvelope?: string`

    The return envelope (ID) sent out with the letter, if any.

  - `template?: string`

    The template ID used for the letter. You can supply _either_ this or `html` but not both.

  - `trackingNumber?: string`

    The tracking number of this order. Populated after an express/certified order has been processed for delivery.

  - `uploadedPDF?: string`

    If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

  - `url?: string`

    PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

    This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

### 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 letter = await client.printMail.letters.progress('id');

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

#### Response

```json
{
  "id": "letter_123456",
  "object": "letter",
  "status": "ready",
  "live": false,
  "to": {
    "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"
  },
  "from": {
    "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"
  },
  "size": "us_letter",
  "doubleSided": true,
  "color": false,
  "paper": "standard",
  "sendDate": "2020-11-12T23:23:47.974Z",
  "createdAt": "2020-11-12T23:23:47.974Z",
  "updatedAt": "2020-11-12T23:23:47.974Z",
  "mailingClass": "first_class",
  "envelope": "standard",
  "addressPlacement": "top_first_page",
  "html": "<html>Content</html>"
}
```

## Domain Types

### Address Placement

- `AddressPlacement = "top_first_page" | "insert_blank_page"`

  Enum representing the placement of the address on the letter.

  - `"top_first_page"`

  - `"insert_blank_page"`

### Attached Pdf

- `AttachedPdf`

  Model representing an attached PDF.

  - `file: string | Uploadable`

    The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

    - `string`

    - `Uploadable`

  - `placement: "before_template" | "after_template"`

    Enum representing the placement of the attached PDF.

    - `"before_template"`

    - `"after_template"`

### Letter

- `Letter`

  - `id: string`

    A unique ID prefixed with letter_

  - `addressPlacement: AddressPlacement`

    Enum representing the placement of the address on the letter.

    - `"top_first_page"`

    - `"insert_blank_page"`

  - `color: boolean`

    Indicates if the letter is in color.

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `doubleSided: boolean`

    Indicates if the letter is double-sided.

  - `envelope: string`

    The envelope (ID) for the letter or the default `standard` envelope.

  - `from: Contact`

    The contact information of the sender.

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

  - `live: boolean`

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

  - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

    The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

    - `"first_class"`

    - `"standard_class"`

    - `"express"`

    - `"certified"`

    - `"certified_return_receipt"`

    - `"registered"`

    - `"usps_first_class"`

    - `"usps_standard_class"`

    - `"usps_eddm"`

    - `"usps_express_2_day"`

    - `"usps_express_3_day"`

    - `"usps_first_class_certified"`

    - `"usps_first_class_certified_return_receipt"`

    - `"usps_first_class_registered"`

    - `"usps_express_3_day_signature_confirmation"`

    - `"usps_express_3_day_certified"`

    - `"usps_express_3_day_certified_return_receipt"`

    - `"ca_post_lettermail"`

    - `"ca_post_personalized"`

    - `"ca_post_neighbourhood_mail"`

    - `"ups_express_overnight"`

    - `"ups_express_2_day"`

    - `"ups_express_3_day"`

    - `"royal_mail_first_class"`

    - `"royal_mail_second_class"`

    - `"au_post_second_class"`

  - `object: "letter"`

    Always `letter`.

    - `"letter"`

  - `sendDate: string`

    This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

  - `size: LetterSize`

    Enum representing the supported letter sizes.

    - `"us_letter"`

    - `"a4"`

  - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

    See `OrderStatus` for more details on the status of this order.

    - `"ready"`

    - `"printing"`

    - `"processed_for_delivery"`

    - `"completed"`

    - `"cancelled"`

  - `to: Contact`

    The recipient of this order. This will be provided even if you delete the underlying contact.

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `attachedPDF?: AttachedPdf`

    Model representing an attached PDF.

    - `file: string | Uploadable`

      The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

      - `string`

      - `Uploadable`

    - `placement: "before_template" | "after_template"`

      Enum representing the placement of the attached PDF.

      - `"before_template"`

      - `"after_template"`

  - `cancellation?: Cancellation`

    The cancellation details of this order. Populated if the order has been cancelled.

    - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

      The reason for the cancellation.

      - `"user_initiated"`

      - `"invalid_content"`

      - `"invalid_order_mailing_class"`

    - `cancelledByUser?: string`

      The user ID who cancelled the order.

    - `note?: string`

      An optional note provided by the user who cancelled the order.

  - `description?: string`

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

  - `html?: string`

    The HTML content for the letter. You can supply _either_ this or `template` but not both.

  - `imbDate?: string`

    The last date that the IMB status was updated. See `imbStatus` for more details.

  - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

    The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

    - `"entered_mail_stream"`

    - `"out_for_delivery"`

    - `"returned_to_sender"`

  - `imbZIPCode?: string`

    The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

    These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

    See the section on Metadata.

  - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

    Premium paper selection used for this letter.

    Available values include:

    - `standard`
    - `premium_paper_letter_standard_white_70lb`
    - `premium_paper_letter_standard_white_80lb`

    Not all premium paper options are enabled for all organizations.
    If omitted, the organization default letter paper is used when configured; otherwise `standard`.

    - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

      - `"standard"`

      - `"premium_paper_letter_standard_white_70lb"`

      - `"premium_paper_letter_standard_white_80lb"`

    - `(string & {})`

  - `pdfWorkflowRun?: string`

    The ID of the PDF workflow run that created the letter, if any.

  - `perforatedPage?: 1`

    If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

    - `1`

  - `plasticCard?: PlasticCard`

    Model representing a plastic card.

    - `size: "standard"`

      Enum representing the size of the plastic card.

      - `"standard"`

    - `doubleSided?: DoubleSided`

      Model representing a double-sided plastic card.

      - `backHTML?: string`

        The HTML content for the back side of the double-sided plastic card.

      - `backTemplate?: string`

        The template ID for the back side of the double-sided plastic card.

      - `frontHTML?: string`

        The HTML content for the front side of the double-sided plastic card.

      - `frontTemplate?: string`

        The template ID for the front side of the double-sided plastic card.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the double-sided plastic card or the file itself.

        - `string`

        - `Uploadable`

    - `singleSided?: SingleSided`

      Model representing a single-sided plastic card.

      - `html?: string`

        The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

      - `pdf?: string | Uploadable`

        A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

        - `string`

        - `Uploadable`

      - `template?: string`

        The template ID for the single-sided plastic card.

  - `returnEnvelope?: string`

    The return envelope (ID) sent out with the letter, if any.

  - `template?: string`

    The template ID used for the letter. You can supply _either_ this or `html` but not both.

  - `trackingNumber?: string`

    The tracking number of this order. Populated after an express/certified order has been processed for delivery.

  - `uploadedPDF?: string`

    If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

  - `url?: string`

    PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

    This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

### Letter Size

- `LetterSize = "us_letter" | "a4"`

  Enum representing the supported letter sizes.

  - `"us_letter"`

  - `"a4"`

### Plastic Card

- `PlasticCard`

  Model representing a plastic card.

  - `size: "standard"`

    Enum representing the size of the plastic card.

    - `"standard"`

  - `doubleSided?: DoubleSided`

    Model representing a double-sided plastic card.

    - `backHTML?: string`

      The HTML content for the back side of the double-sided plastic card.

    - `backTemplate?: string`

      The template ID for the back side of the double-sided plastic card.

    - `frontHTML?: string`

      The HTML content for the front side of the double-sided plastic card.

    - `frontTemplate?: string`

      The template ID for the front side of the double-sided plastic card.

    - `pdf?: string | Uploadable`

      A URL pointing to a PDF file for the double-sided plastic card or the file itself.

      - `string`

      - `Uploadable`

  - `singleSided?: SingleSided`

    Model representing a single-sided plastic card.

    - `html?: string`

      The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

    - `pdf?: string | Uploadable`

      A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

      - `string`

      - `Uploadable`

    - `template?: string`

      The template ID for the single-sided plastic card.

### Letter Create Response

- `LetterCreateResponse = Letter | Letter`

  - `Letter`

    - `id: string`

      A unique ID prefixed with letter_

    - `addressPlacement: AddressPlacement`

      Enum representing the placement of the address on the letter.

      - `"top_first_page"`

      - `"insert_blank_page"`

    - `color: boolean`

      Indicates if the letter is in color.

    - `createdAt: string`

      The UTC time at which this resource was created.

    - `doubleSided: boolean`

      Indicates if the letter is double-sided.

    - `envelope: string`

      The envelope (ID) for the letter or the default `standard` envelope.

    - `from: Contact`

      The contact information of the sender.

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

    - `live: boolean`

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

    - `mailingClass: "first_class" | "standard_class" | "express" | 23 more`

      The mailing class of this order. This determines the speed and cost of delivery. See `OrderMailingClass` for more details.

      - `"first_class"`

      - `"standard_class"`

      - `"express"`

      - `"certified"`

      - `"certified_return_receipt"`

      - `"registered"`

      - `"usps_first_class"`

      - `"usps_standard_class"`

      - `"usps_eddm"`

      - `"usps_express_2_day"`

      - `"usps_express_3_day"`

      - `"usps_first_class_certified"`

      - `"usps_first_class_certified_return_receipt"`

      - `"usps_first_class_registered"`

      - `"usps_express_3_day_signature_confirmation"`

      - `"usps_express_3_day_certified"`

      - `"usps_express_3_day_certified_return_receipt"`

      - `"ca_post_lettermail"`

      - `"ca_post_personalized"`

      - `"ca_post_neighbourhood_mail"`

      - `"ups_express_overnight"`

      - `"ups_express_2_day"`

      - `"ups_express_3_day"`

      - `"royal_mail_first_class"`

      - `"royal_mail_second_class"`

      - `"au_post_second_class"`

    - `object: "letter"`

      Always `letter`.

      - `"letter"`

    - `sendDate: string`

      This order will transition from `ready` to `printing` on the day after this date. For example, if this is a date on Tuesday, the order will transition to `printing` on Wednesday at midnight eastern time.

    - `size: LetterSize`

      Enum representing the supported letter sizes.

      - `"us_letter"`

      - `"a4"`

    - `status: "ready" | "printing" | "processed_for_delivery" | 2 more`

      See `OrderStatus` for more details on the status of this order.

      - `"ready"`

      - `"printing"`

      - `"processed_for_delivery"`

      - `"completed"`

      - `"cancelled"`

    - `to: Contact`

      The recipient of this order. This will be provided even if you delete the underlying contact.

    - `updatedAt: string`

      The UTC time at which this resource was last updated.

    - `attachedPDF?: AttachedPdf`

      Model representing an attached PDF.

      - `file: string | Uploadable`

        The file (multipart form upload) or URL pointing to a PDF for the attached PDF.

        - `string`

        - `Uploadable`

      - `placement: "before_template" | "after_template"`

        Enum representing the placement of the attached PDF.

        - `"before_template"`

        - `"after_template"`

    - `cancellation?: Cancellation`

      The cancellation details of this order. Populated if the order has been cancelled.

      - `reason: "user_initiated" | "invalid_content" | "invalid_order_mailing_class"`

        The reason for the cancellation.

        - `"user_initiated"`

        - `"invalid_content"`

        - `"invalid_order_mailing_class"`

      - `cancelledByUser?: string`

        The user ID who cancelled the order.

      - `note?: string`

        An optional note provided by the user who cancelled the order.

    - `description?: string`

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

    - `html?: string`

      The HTML content for the letter. You can supply _either_ this or `template` but not both.

    - `imbDate?: string`

      The last date that the IMB status was updated. See `imbStatus` for more details.

    - `imbStatus?: "entered_mail_stream" | "out_for_delivery" | "returned_to_sender"`

      The Intelligent Mail Barcode (IMB) status of this order. Only populated for US-printed and US-destined orders. This is the most detailed way to track non-express/certified orders.

      - `"entered_mail_stream"`

      - `"out_for_delivery"`

      - `"returned_to_sender"`

    - `imbZIPCode?: string`

      The most recent ZIP code of the USPS facility that the order has been processed through. Only populated when an `imbStatus` is present.

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

      These will be merged with the variables in the template or HTML you create this order with. The keys in this object should match the variable names in the template _exactly_ as they are case-sensitive. Note that these _do not_ apply to PDFs uploaded with the order.

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

      See the section on Metadata.

    - `paper?: "standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb" | (string & {})`

      Premium paper selection used for this letter.

      Available values include:

      - `standard`
      - `premium_paper_letter_standard_white_70lb`
      - `premium_paper_letter_standard_white_80lb`

      Not all premium paper options are enabled for all organizations.
      If omitted, the organization default letter paper is used when configured; otherwise `standard`.

      - `"standard" | "premium_paper_letter_standard_white_70lb" | "premium_paper_letter_standard_white_80lb"`

        - `"standard"`

        - `"premium_paper_letter_standard_white_70lb"`

        - `"premium_paper_letter_standard_white_80lb"`

      - `(string & {})`

    - `pdfWorkflowRun?: string`

      The ID of the PDF workflow run that created the letter, if any.

    - `perforatedPage?: 1`

      If specified, indicates which letter page is perforated. Currently, only the first page can be perforated.

      - `1`

    - `plasticCard?: PlasticCard`

      Model representing a plastic card.

      - `size: "standard"`

        Enum representing the size of the plastic card.

        - `"standard"`

      - `doubleSided?: DoubleSided`

        Model representing a double-sided plastic card.

        - `backHTML?: string`

          The HTML content for the back side of the double-sided plastic card.

        - `backTemplate?: string`

          The template ID for the back side of the double-sided plastic card.

        - `frontHTML?: string`

          The HTML content for the front side of the double-sided plastic card.

        - `frontTemplate?: string`

          The template ID for the front side of the double-sided plastic card.

        - `pdf?: string | Uploadable`

          A URL pointing to a PDF file for the double-sided plastic card or the file itself.

          - `string`

          - `Uploadable`

      - `singleSided?: SingleSided`

        Model representing a single-sided plastic card.

        - `html?: string`

          The HTML content for the single-sided plastic card. Can specify one of this, `template`, or `pdf`.

        - `pdf?: string | Uploadable`

          A URL pointing to a PDF file for the single-sided plastic card or the PDF file itself.

          - `string`

          - `Uploadable`

        - `template?: string`

          The template ID for the single-sided plastic card.

    - `returnEnvelope?: string`

      The return envelope (ID) sent out with the letter, if any.

    - `template?: string`

      The template ID used for the letter. You can supply _either_ this or `html` but not both.

    - `trackingNumber?: string`

      The tracking number of this order. Populated after an express/certified order has been processed for delivery.

    - `uploadedPDF?: string`

      If a PDF was uploaded for the letter, this will contain the signed link to the uploaded PDF.

    - `url?: string`

      PostGrid renders a PDF preview for all orders. This should be inspected to ensure that the order is correct before it is sent out because it shows what will be printed and mailed to the recipient. Once the PDF preview is generated, this field will be returned by all `GET` endpoints which produce this order.

      This URL is a signed link to the PDF preview. It will expire after a short period of time. If you need to access this URL after it has expired, you can regenerate it by calling the `GET` endpoint again.

  - `Letter`

### Letter Retrieve URL Response

- `LetterRetrieveURLResponse`

  - `id: string`

    A unique ID prefixed with letter_

  - `object: string`

  - `url: string`

    A signed URL linking to the order preview PDF. The link remains valid for 15 minutes from the time of the API call.
