Skip to main content
AhaSend CLI list commands manage contact lists, the static lists of contacts that campaigns send to, and the members of each list.
These commands need CLI v0.3.0 or later. Check your version with ahasend --version, and upgrade if it is older.

Prerequisites

Authenticate with a full API key. List tasks need these scopes: lists members list --include-contacts also needs contacts:read. The examples also create and delete a test contact, which needs contacts:write and contacts:delete. A contact must exist before you can add it to a list; create contacts with ahasend contacts. The shell examples need Bash and jq. A member is one contact’s membership of one list, with its own subscription status: unconfirmed, confirmed, unsubscribed or complained. A list’s contact count is the number of members a campaign to the list would reach.

Create and Update a Test List

Save these commands in one Bash script. The script creates a test contact and a test list, and later examples on this page use the same contact and list.
--tag can be used more than once and splits on commas, so --tag docs,test gives two tags. On update, --tag replaces all tags, --clear-tags removes every tag, and --description "" clears the description. update sends only the flags you give. lists list --name finds the lists whose name contains the value, in any case.

Add and List Members

Continue the script. members add adds up to 1,000 existing contacts in one request, named with --email, --contact-id, or both. Each flag can be used more than once and splits on commas.
To add contacts from a file instead, save a JSON object whose data array names each contact by email or by ID:
members.json
--file cannot be combined with --email or --contact-id. The command prints the result for each contact: contacts already on the list are skipped, and unknown or invalid ones fail with a reason. It exits with code 1 when any contact failed; skipped contacts are not failures. members list filters by --email and --subscription-status. To see the lists one contact is on, use ahasend contacts memberships.

Unsubscribe or Remove a Member

members set adds one contact to a list or changes its status. Without --subscription-status, a new member is confirmed and an existing member keeps its status.
To stop mail to a contact on a list and keep the record, set the status to unsubscribed. members remove deletes the membership and any unsubscribe it records. A complained membership cannot be changed or removed.

Delete the Test List

Finish the script by deleting the list and the contact it created.
The script stops at the first command that fails, and then deletes nothing. If it stops early, find the test list with ahasend lists list --name docs and delete it with lists delete, then delete the test contact with the contacts delete command above. The API refuses to delete a list while a campaign that still needs it refers to it. lists delete and lists members remove ask for confirmation first; see prompts.

Command Flags

These flags come from the CLI’s --help. All commands also accept the global flags.

lists create

lists delete

lists get

No command-specific flags. See global flags.

lists list

lists members add

lists members list

lists members remove

lists members set

lists update