Skip to main content
AhaSend CLI contact commands manage account-global contacts by email address or UUID.
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. Contact tasks need these scopes: Attribute keys must already exist in the dashboard. Creating a contact does not add it to a list; add it with ahasend lists members add. The shell examples need Bash. Commands that take <id-or-email> accept a contact ID or a raw email address. Pass the address exactly as written, including +, and do not percent-encode it.

Create, Read and Update

Save these commands in one Bash script. The script creates two test contacts, and its last step deletes them.
update sends only the flags you give, and needs at least one. --first-name "", --last-name "" and --status-reason "" clear those fields. To remove an attribute, set its value to null in --attributes, such as --attributes '{"old_key":null}'. Status values are enabled, disabled and blocked. To find contacts, filter the list by email, status, subscription or creation time. Times are RFC 3339, such as 2026-01-15T10:30:00Z, or relative, such as 7d for 7 days ago:

Batch Import

Continue the script. contacts batch creates or updates up to 1,000 contacts in one request. Save this as contacts.json:
contacts.json
  • The file is a JSON object whose only field is data. The 1,000 limit counts every item, duplicates included.
  • Items may hold only contact fields, and no field may be null; leave a field out to keep it unchanged. Inside attributes, null removes that attribute.
  • The command prints the result of each item, and exits with code 1 when any item failed.
  • With --idempotency-key, reuse a key only to retry the same file contents.

List a Contact’s Lists

Continue the script:
Each membership shows its list and its status: unconfirmed, confirmed, unsubscribed or complained.

Delete the Test Contacts

Finish the script by deleting the contacts it created.
The script stops at the first command that fails, and then deletes nothing. If it stops early, run these two commands to delete the contacts it made; a contact it did not make fails with a not found error. contacts delete asks for confirmation first; see prompts.
Deleting a contact cannot be undone. It cancels the contact’s active workflows and erases its unsubscribe, list membership, campaign, open and click history. To stop mail and keep the history, run ahasend contacts update <id-or-email> --unsubscribed=true instead.

Command Flags

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

contacts batch

contacts create

Attribute values cannot be null on create.

contacts delete

contacts get

No command-specific flags. See global flags.

contacts list

The list is newest first. --subscribed=false lists unsubscribed contacts.

contacts memberships

contacts update