# Mailing List Imports

## Create Mailing List Import

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

Create a new mailing list import.

Initiates the import process for a contact list file. The import enters the
`validating` status while contacts are processed and verified.

### Header Parameters

- `"idempotency-key": optional string`

### Body Parameters

- `file: string`

  The CSV file for this import.

- `fileType: FileType`

  Type of file supported for mailing list imports.

  - `"csv"`

- `receiverAddressMapping: map[string]`

  Mapping of columns for receiver addresses.

- `description: optional string`

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

- `metadata: optional map[unknown]`

  See the section on Metadata.

- `receiverMergeVariableMapping: optional map[string]`

  Optional mapping of columns for receiver merge variables.

- `senderAddressMapping: optional map[string]`

  Optional mapping of columns for sender addresses.
  If this is present, then all receivers should have a corresponding sender.

- `senderMergeVariableMapping: optional map[string]`

  Optional mapping of columns for sender merge variables.

### Returns

- `MailingListImportResponse object { id, createdAt, errors, 13 more }`

  Read-only view of a MailingListImport

  - `id: string`

    A unique ID prefixed with mailing_list_import_

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `errors: array of object { message, type }`

    A list of processing errors encountered, if any. Present when status is 'changes_required'.

    - `message: string`

      A human-readable message describing the error.

    - `type: "no_valid_contacts_error" or "multiple_countries_error" or "invalid_contact_count_error" or "internal_service_error"`

      Type of error encountered during import processing.

      - `"no_valid_contacts_error"`

      - `"multiple_countries_error"`

      - `"invalid_contact_count_error"`

      - `"internal_service_error"`

  - `file: object { fileType, receiverAddressMapping, url, 3 more }`

    The file object your controller returns: all the mappings plus a signed URL.

    - `fileType: FileType`

      Type of file supported for mailing list imports.

      - `"csv"`

    - `receiverAddressMapping: map[string]`

      Mapping of columns for receiver addresses.
      Contact fields to file columns.
      Possible Contact fields:

      - description
      - firstName
      - lastName
      - email
      - phoneNumber
      - companyName
      - addressLine1
      - addressLine2
      - jobTitle
      - city
      - postalOrZip
      - provinceOrState
      - countryCode

    - `url: string`

      The signed URL your controller generates.

    - `receiverMergeVariableMapping: optional map[string]`

      Optional mapping of columns for receiver merge variables.

    - `senderAddressMapping: optional map[string]`

      Optional mapping of columns for sender addresses.

    - `senderMergeVariableMapping: optional map[string]`

      Optional mapping of columns for sender merge variables.

  - `invalidRowCount: number`

    Number of invalid rows found in the file.

  - `live: boolean`

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

  - `notes: array of object { message, type }`

    Additional notes about the import process.

    - `message: string`

      A human-readable message describing the note.

    - `type: "truncated_test_file" or "skipped_invalid_contacts"`

      Type of note attached to the import process.

      - `"truncated_test_file"`

      - `"skipped_invalid_contacts"`

  - `organization: string`

    The organization that owns this import.

  - `receiverStatusCount: VerificationStatusCount`

    Count of contact verification statuses.

    - `correctedCount: number`

      Number of contacts that were corrected during verification.

    - `failedCount: number`

      Number of contacts that failed verification.

    - `verifiedCount: number`

      Number of contacts that were verified without changes.

  - `status: "validating" or "completed" or "changes_required"`

    Status of the mailing list import process.

    - `"validating"`

    - `"completed"`

    - `"changes_required"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `validRowCount: number`

    Number of valid rows processed from the file.

  - `description: optional string`

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

  - `metadata: optional map[unknown]`

    See the section on Metadata.

  - `reportURL: optional string`

    A temporary URL to download the processing report, available once the import is completed.

  - `senderStatusCount: optional VerificationStatusCount`

    Count of contact verification statuses.

### Example

```http
curl https://api.postgrid.com/print-mail/v1/mailing_list_imports \
    -H 'Content-Type: application/json' \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY" \
    -d '{
          "file": "https://signed-upload-url.csv",
          "fileType": "csv",
          "receiverAddressMapping": {
            "description": "Description",
            "firstName": "First Name",
            "lastName": "Last Name",
            "email": "Email",
            "addressLine1": "Address",
            "city": "City",
            "postalOrZip": "Postal Code",
            "provinceOrState": "State",
            "countryCode": "Country"
          }
        }'
```

#### Response

```json
{
  "id": "mailing_list_import_123",
  "live": false,
  "createdAt": "2023-10-27T10:00:00Z",
  "updatedAt": "2023-10-27T10:05:00Z",
  "status": "completed",
  "reportURL": "https://signed-report-url.csv",
  "errors": [],
  "notes": [],
  "validRowCount": 100,
  "invalidRowCount": 0,
  "receiverStatusCount": {
    "verifiedCount": 100,
    "correctedCount": 0,
    "failedCount": 0
  },
  "senderStatusCount": {
    "verifiedCount": 100,
    "correctedCount": 0,
    "failedCount": 0
  },
  "organization": "org_123",
  "file": {
    "fileType": "csv",
    "receiverAddressMapping": {
      "description": "Description",
      "firstName": "First Name",
      "lastName": "Last Name",
      "email": "Email",
      "addressLine1": "Address",
      "addressLine2": "Address Line 2",
      "city": "City",
      "postalOrZip": "Postal Code",
      "provinceOrState": "Province",
      "countryCode": "Country"
    },
    "url": "https://signed.url/import_123.csv"
  }
}
```

## List Mailing List Imports

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

Retrieve a list of mailing list imports.

Returns a paginated list of imports associated with the authenticated organization,
filterable by various parameters.

### Query Parameters

- `limit: optional number`

- `search: optional 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: optional number`

### Returns

- `data: array of MailingListImportResponse`

  - `id: string`

    A unique ID prefixed with mailing_list_import_

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `errors: array of object { message, type }`

    A list of processing errors encountered, if any. Present when status is 'changes_required'.

    - `message: string`

      A human-readable message describing the error.

    - `type: "no_valid_contacts_error" or "multiple_countries_error" or "invalid_contact_count_error" or "internal_service_error"`

      Type of error encountered during import processing.

      - `"no_valid_contacts_error"`

      - `"multiple_countries_error"`

      - `"invalid_contact_count_error"`

      - `"internal_service_error"`

  - `file: object { fileType, receiverAddressMapping, url, 3 more }`

    The file object your controller returns: all the mappings plus a signed URL.

    - `fileType: FileType`

      Type of file supported for mailing list imports.

      - `"csv"`

    - `receiverAddressMapping: map[string]`

      Mapping of columns for receiver addresses.
      Contact fields to file columns.
      Possible Contact fields:

      - description
      - firstName
      - lastName
      - email
      - phoneNumber
      - companyName
      - addressLine1
      - addressLine2
      - jobTitle
      - city
      - postalOrZip
      - provinceOrState
      - countryCode

    - `url: string`

      The signed URL your controller generates.

    - `receiverMergeVariableMapping: optional map[string]`

      Optional mapping of columns for receiver merge variables.

    - `senderAddressMapping: optional map[string]`

      Optional mapping of columns for sender addresses.

    - `senderMergeVariableMapping: optional map[string]`

      Optional mapping of columns for sender merge variables.

  - `invalidRowCount: number`

    Number of invalid rows found in the file.

  - `live: boolean`

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

  - `notes: array of object { message, type }`

    Additional notes about the import process.

    - `message: string`

      A human-readable message describing the note.

    - `type: "truncated_test_file" or "skipped_invalid_contacts"`

      Type of note attached to the import process.

      - `"truncated_test_file"`

      - `"skipped_invalid_contacts"`

  - `organization: string`

    The organization that owns this import.

  - `receiverStatusCount: VerificationStatusCount`

    Count of contact verification statuses.

    - `correctedCount: number`

      Number of contacts that were corrected during verification.

    - `failedCount: number`

      Number of contacts that failed verification.

    - `verifiedCount: number`

      Number of contacts that were verified without changes.

  - `status: "validating" or "completed" or "changes_required"`

    Status of the mailing list import process.

    - `"validating"`

    - `"completed"`

    - `"changes_required"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `validRowCount: number`

    Number of valid rows processed from the file.

  - `description: optional string`

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

  - `metadata: optional map[unknown]`

    See the section on Metadata.

  - `reportURL: optional string`

    A temporary URL to download the processing report, available once the import is completed.

  - `senderStatusCount: optional VerificationStatusCount`

    Count of contact verification statuses.

- `limit: number`

- `object: "list"`

  - `"list"`

- `skip: number`

- `totalCount: number`

### Example

```http
curl https://api.postgrid.com/print-mail/v1/mailing_list_imports \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY"
```

#### Response

```json
{
  "object": "list",
  "totalCount": 1,
  "skip": 0,
  "limit": 10,
  "data": [
    {
      "id": "mailing_list_import_123",
      "live": false,
      "createdAt": "2023-10-27T10:00:00Z",
      "updatedAt": "2023-10-27T10:05:00Z",
      "status": "completed",
      "reportURL": "https://signed-report-url.csv",
      "errors": [],
      "notes": [],
      "validRowCount": 100,
      "invalidRowCount": 0,
      "receiverStatusCount": {
        "verifiedCount": 100,
        "correctedCount": 0,
        "failedCount": 0
      },
      "senderStatusCount": {
        "verifiedCount": 100,
        "correctedCount": 0,
        "failedCount": 0
      },
      "organization": "org_123",
      "file": {
        "fileType": "csv",
        "receiverAddressMapping": {
          "description": "Description",
          "firstName": "First Name",
          "lastName": "Last Name",
          "email": "Email",
          "addressLine1": "Address",
          "addressLine2": "Address Line 2",
          "city": "City",
          "postalOrZip": "Postal Code",
          "provinceOrState": "Province",
          "countryCode": "Country"
        },
        "url": "https://signed.url/import_123.csv"
      }
    }
  ]
}
```

## Update Mailing List Import

**post** `/print-mail/v1/mailing_list_imports/{id}`

Update an existing mailing list import.

### Path Parameters

- `id: string`

### Body Parameters

- `description: optional string`

  An optional description for the import. Set to `null` to remove the existing description.

- `metadata: optional map[string]`

  Optional key-value data associated with the import. Set to `null` to remove existing metadata.

### Returns

- `MailingListImportResponse object { id, createdAt, errors, 13 more }`

  Read-only view of a MailingListImport

  - `id: string`

    A unique ID prefixed with mailing_list_import_

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `errors: array of object { message, type }`

    A list of processing errors encountered, if any. Present when status is 'changes_required'.

    - `message: string`

      A human-readable message describing the error.

    - `type: "no_valid_contacts_error" or "multiple_countries_error" or "invalid_contact_count_error" or "internal_service_error"`

      Type of error encountered during import processing.

      - `"no_valid_contacts_error"`

      - `"multiple_countries_error"`

      - `"invalid_contact_count_error"`

      - `"internal_service_error"`

  - `file: object { fileType, receiverAddressMapping, url, 3 more }`

    The file object your controller returns: all the mappings plus a signed URL.

    - `fileType: FileType`

      Type of file supported for mailing list imports.

      - `"csv"`

    - `receiverAddressMapping: map[string]`

      Mapping of columns for receiver addresses.
      Contact fields to file columns.
      Possible Contact fields:

      - description
      - firstName
      - lastName
      - email
      - phoneNumber
      - companyName
      - addressLine1
      - addressLine2
      - jobTitle
      - city
      - postalOrZip
      - provinceOrState
      - countryCode

    - `url: string`

      The signed URL your controller generates.

    - `receiverMergeVariableMapping: optional map[string]`

      Optional mapping of columns for receiver merge variables.

    - `senderAddressMapping: optional map[string]`

      Optional mapping of columns for sender addresses.

    - `senderMergeVariableMapping: optional map[string]`

      Optional mapping of columns for sender merge variables.

  - `invalidRowCount: number`

    Number of invalid rows found in the file.

  - `live: boolean`

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

  - `notes: array of object { message, type }`

    Additional notes about the import process.

    - `message: string`

      A human-readable message describing the note.

    - `type: "truncated_test_file" or "skipped_invalid_contacts"`

      Type of note attached to the import process.

      - `"truncated_test_file"`

      - `"skipped_invalid_contacts"`

  - `organization: string`

    The organization that owns this import.

  - `receiverStatusCount: VerificationStatusCount`

    Count of contact verification statuses.

    - `correctedCount: number`

      Number of contacts that were corrected during verification.

    - `failedCount: number`

      Number of contacts that failed verification.

    - `verifiedCount: number`

      Number of contacts that were verified without changes.

  - `status: "validating" or "completed" or "changes_required"`

    Status of the mailing list import process.

    - `"validating"`

    - `"completed"`

    - `"changes_required"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `validRowCount: number`

    Number of valid rows processed from the file.

  - `description: optional string`

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

  - `metadata: optional map[unknown]`

    See the section on Metadata.

  - `reportURL: optional string`

    A temporary URL to download the processing report, available once the import is completed.

  - `senderStatusCount: optional VerificationStatusCount`

    Count of contact verification statuses.

### Example

```http
curl https://api.postgrid.com/print-mail/v1/mailing_list_imports/$ID \
    -H 'Content-Type: application/json' \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY" \
    -d '{}'
```

#### Response

```json
{
  "id": "mailing_list_import_123",
  "live": false,
  "createdAt": "2023-10-27T10:00:00Z",
  "updatedAt": "2023-10-27T10:05:00Z",
  "status": "completed",
  "reportURL": "https://signed-report-url.csv",
  "errors": [],
  "notes": [],
  "validRowCount": 100,
  "invalidRowCount": 0,
  "receiverStatusCount": {
    "verifiedCount": 100,
    "correctedCount": 0,
    "failedCount": 0
  },
  "senderStatusCount": {
    "verifiedCount": 100,
    "correctedCount": 0,
    "failedCount": 0
  },
  "organization": "org_123",
  "file": {
    "fileType": "csv",
    "receiverAddressMapping": {
      "description": "Description",
      "firstName": "First Name",
      "lastName": "Last Name",
      "email": "Email",
      "addressLine1": "Address",
      "addressLine2": "Address Line 2",
      "city": "City",
      "postalOrZip": "Postal Code",
      "provinceOrState": "Province",
      "countryCode": "Country"
    },
    "url": "https://signed.url/import_123.csv"
  }
}
```

## Get Mailing List Import

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

Retrieve a specific mailing list import by its ID.

### Path Parameters

- `id: string`

### Returns

- `MailingListImportResponse object { id, createdAt, errors, 13 more }`

  Read-only view of a MailingListImport

  - `id: string`

    A unique ID prefixed with mailing_list_import_

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `errors: array of object { message, type }`

    A list of processing errors encountered, if any. Present when status is 'changes_required'.

    - `message: string`

      A human-readable message describing the error.

    - `type: "no_valid_contacts_error" or "multiple_countries_error" or "invalid_contact_count_error" or "internal_service_error"`

      Type of error encountered during import processing.

      - `"no_valid_contacts_error"`

      - `"multiple_countries_error"`

      - `"invalid_contact_count_error"`

      - `"internal_service_error"`

  - `file: object { fileType, receiverAddressMapping, url, 3 more }`

    The file object your controller returns: all the mappings plus a signed URL.

    - `fileType: FileType`

      Type of file supported for mailing list imports.

      - `"csv"`

    - `receiverAddressMapping: map[string]`

      Mapping of columns for receiver addresses.
      Contact fields to file columns.
      Possible Contact fields:

      - description
      - firstName
      - lastName
      - email
      - phoneNumber
      - companyName
      - addressLine1
      - addressLine2
      - jobTitle
      - city
      - postalOrZip
      - provinceOrState
      - countryCode

    - `url: string`

      The signed URL your controller generates.

    - `receiverMergeVariableMapping: optional map[string]`

      Optional mapping of columns for receiver merge variables.

    - `senderAddressMapping: optional map[string]`

      Optional mapping of columns for sender addresses.

    - `senderMergeVariableMapping: optional map[string]`

      Optional mapping of columns for sender merge variables.

  - `invalidRowCount: number`

    Number of invalid rows found in the file.

  - `live: boolean`

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

  - `notes: array of object { message, type }`

    Additional notes about the import process.

    - `message: string`

      A human-readable message describing the note.

    - `type: "truncated_test_file" or "skipped_invalid_contacts"`

      Type of note attached to the import process.

      - `"truncated_test_file"`

      - `"skipped_invalid_contacts"`

  - `organization: string`

    The organization that owns this import.

  - `receiverStatusCount: VerificationStatusCount`

    Count of contact verification statuses.

    - `correctedCount: number`

      Number of contacts that were corrected during verification.

    - `failedCount: number`

      Number of contacts that failed verification.

    - `verifiedCount: number`

      Number of contacts that were verified without changes.

  - `status: "validating" or "completed" or "changes_required"`

    Status of the mailing list import process.

    - `"validating"`

    - `"completed"`

    - `"changes_required"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `validRowCount: number`

    Number of valid rows processed from the file.

  - `description: optional string`

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

  - `metadata: optional map[unknown]`

    See the section on Metadata.

  - `reportURL: optional string`

    A temporary URL to download the processing report, available once the import is completed.

  - `senderStatusCount: optional VerificationStatusCount`

    Count of contact verification statuses.

### Example

```http
curl https://api.postgrid.com/print-mail/v1/mailing_list_imports/$ID \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY"
```

#### Response

```json
{
  "id": "mailing_list_import_123",
  "live": false,
  "createdAt": "2023-10-27T10:00:00Z",
  "updatedAt": "2023-10-27T10:05:00Z",
  "status": "completed",
  "reportURL": "https://signed-report-url.csv",
  "errors": [],
  "notes": [],
  "validRowCount": 100,
  "invalidRowCount": 0,
  "receiverStatusCount": {
    "verifiedCount": 100,
    "correctedCount": 0,
    "failedCount": 0
  },
  "senderStatusCount": {
    "verifiedCount": 100,
    "correctedCount": 0,
    "failedCount": 0
  },
  "organization": "org_123",
  "file": {
    "fileType": "csv",
    "receiverAddressMapping": {
      "description": "Description",
      "firstName": "First Name",
      "lastName": "Last Name",
      "email": "Email",
      "addressLine1": "Address",
      "addressLine2": "Address Line 2",
      "city": "City",
      "postalOrZip": "Postal Code",
      "provinceOrState": "Province",
      "countryCode": "Country"
    },
    "url": "https://signed.url/import_123.csv"
  }
}
```

## Delete Mailing List Import

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

Delete a mailing list import.

This permanently deletes the import and its associated resources.
This operation cannot be undone.

### Path Parameters

- `id: string`

### Returns

- `id: string`

  A unique ID prefixed with mailing_list_import_

- `deleted: true`

  - `true`

### Example

```http
curl https://api.postgrid.com/print-mail/v1/mailing_list_imports/$ID \
    -X DELETE \
    -H "X-API-Key: $POSTGRID_PRINT_MAIL_API_KEY"
```

#### Response

```json
{
  "id": "mailing_list_import_123",
  "deleted": true
}
```

## Domain Types

### File Type

- `FileType = "csv"`

  Type of file supported for mailing list imports.

  - `"csv"`

### Mailing List Import Response

- `MailingListImportResponse object { id, createdAt, errors, 13 more }`

  Read-only view of a MailingListImport

  - `id: string`

    A unique ID prefixed with mailing_list_import_

  - `createdAt: string`

    The UTC time at which this resource was created.

  - `errors: array of object { message, type }`

    A list of processing errors encountered, if any. Present when status is 'changes_required'.

    - `message: string`

      A human-readable message describing the error.

    - `type: "no_valid_contacts_error" or "multiple_countries_error" or "invalid_contact_count_error" or "internal_service_error"`

      Type of error encountered during import processing.

      - `"no_valid_contacts_error"`

      - `"multiple_countries_error"`

      - `"invalid_contact_count_error"`

      - `"internal_service_error"`

  - `file: object { fileType, receiverAddressMapping, url, 3 more }`

    The file object your controller returns: all the mappings plus a signed URL.

    - `fileType: FileType`

      Type of file supported for mailing list imports.

      - `"csv"`

    - `receiverAddressMapping: map[string]`

      Mapping of columns for receiver addresses.
      Contact fields to file columns.
      Possible Contact fields:

      - description
      - firstName
      - lastName
      - email
      - phoneNumber
      - companyName
      - addressLine1
      - addressLine2
      - jobTitle
      - city
      - postalOrZip
      - provinceOrState
      - countryCode

    - `url: string`

      The signed URL your controller generates.

    - `receiverMergeVariableMapping: optional map[string]`

      Optional mapping of columns for receiver merge variables.

    - `senderAddressMapping: optional map[string]`

      Optional mapping of columns for sender addresses.

    - `senderMergeVariableMapping: optional map[string]`

      Optional mapping of columns for sender merge variables.

  - `invalidRowCount: number`

    Number of invalid rows found in the file.

  - `live: boolean`

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

  - `notes: array of object { message, type }`

    Additional notes about the import process.

    - `message: string`

      A human-readable message describing the note.

    - `type: "truncated_test_file" or "skipped_invalid_contacts"`

      Type of note attached to the import process.

      - `"truncated_test_file"`

      - `"skipped_invalid_contacts"`

  - `organization: string`

    The organization that owns this import.

  - `receiverStatusCount: VerificationStatusCount`

    Count of contact verification statuses.

    - `correctedCount: number`

      Number of contacts that were corrected during verification.

    - `failedCount: number`

      Number of contacts that failed verification.

    - `verifiedCount: number`

      Number of contacts that were verified without changes.

  - `status: "validating" or "completed" or "changes_required"`

    Status of the mailing list import process.

    - `"validating"`

    - `"completed"`

    - `"changes_required"`

  - `updatedAt: string`

    The UTC time at which this resource was last updated.

  - `validRowCount: number`

    Number of valid rows processed from the file.

  - `description: optional string`

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

  - `metadata: optional map[unknown]`

    See the section on Metadata.

  - `reportURL: optional string`

    A temporary URL to download the processing report, available once the import is completed.

  - `senderStatusCount: optional VerificationStatusCount`

    Count of contact verification statuses.

### Verification Status Count

- `VerificationStatusCount object { correctedCount, failedCount, verifiedCount }`

  Count of contact verification statuses.

  - `correctedCount: number`

    Number of contacts that were corrected during verification.

  - `failedCount: number`

    Number of contacts that failed verification.

  - `verifiedCount: number`

    Number of contacts that were verified without changes.

### Mailing List Import Delete Response

- `MailingListImportDeleteResponse object { id, deleted }`

  - `id: string`

    A unique ID prefixed with mailing_list_import_

  - `deleted: true`

    - `true`
