ListContactsCommand

Lists the contacts present in a specific contact list.

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { SESv2Client, ListContactsCommand } from "@aws-sdk/client-sesv2"; // ES Modules import
// const { SESv2Client, ListContactsCommand } = require("@aws-sdk/client-sesv2"); // CommonJS import
const client = new SESv2Client(config);
const input = { // ListContactsRequest
  ContactListName: "STRING_VALUE", // required
  Filter: { // ListContactsFilter
    FilteredStatus: "OPT_IN" || "OPT_OUT",
    TopicFilter: { // TopicFilter
      TopicName: "STRING_VALUE",
      UseDefaultIfPreferenceUnavailable: true || false,
    },
  },
  PageSize: Number("int"),
  NextToken: "STRING_VALUE",
};
const command = new ListContactsCommand(input);
const response = await client.send(command);
// { // ListContactsResponse
//   Contacts: [ // ListOfContacts
//     { // Contact
//       EmailAddress: "STRING_VALUE",
//       TopicPreferences: [ // TopicPreferenceList
//         { // TopicPreference
//           TopicName: "STRING_VALUE", // required
//           SubscriptionStatus: "OPT_IN" || "OPT_OUT", // required
//         },
//       ],
//       TopicDefaultPreferences: [
//         {
//           TopicName: "STRING_VALUE", // required
//           SubscriptionStatus: "OPT_IN" || "OPT_OUT", // required
//         },
//       ],
//       UnsubscribeAll: true || false,
//       LastUpdatedTimestamp: new Date("TIMESTAMP"),
//     },
//   ],
//   NextToken: "STRING_VALUE",
// };

ListContactsCommand Input

See ListContactsCommandInput for more details

Parameter
Type
Description
ContactListName
Required
string | undefined

The name of the contact list.

Filter
ListContactsFilter | undefined

A filter that can be applied to a list of contacts.

NextToken
string | undefined

A string token indicating that there might be additional contacts available to be listed. Use the token provided in the Response to use in the subsequent call to ListContacts with the same parameters to retrieve the next page of contacts.

PageSize
number | undefined

The number of contacts that may be returned at once, which is dependent on if there are more or less contacts than the value of the PageSize. Use this parameter to paginate results. If additional contacts exist beyond the specified limit, the NextToken element is sent in the response. Use the NextToken value in subsequent requests to retrieve additional contacts.

ListContactsCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
Contacts
Contact[] | undefined

The contacts present in a specific contact list.

NextToken
string | undefined

A string token indicating that there might be additional contacts available to be listed. Copy this token to a subsequent call to ListContacts with the same parameters to retrieve the next page of contacts.

Throws

Name
Fault
Details
BadRequestException
client

The input you provided is invalid.

NotFoundException
client

The resource you attempted to access doesn't exist.

TooManyRequestsException
client

Too many requests have been made to the operation.

SESv2ServiceException
Base exception class for all service exceptions from SESv2 service.