auth commands log you in and manage your saved profiles; this page lists their arguments, flags and output. For the complete workflow, use the authentication guide.
Overview
auth loginchecks the API key against the account and saves it as a profile. Profiles says which name the profile gets and when it becomes the default.auth statusshows whether the API accepts a profile’s key for its account. It reads the configuration file and never changes it.auth switchmakes a profile the default. It checks the profile’s key first, and warns on stderr but switches anyway when the check fails.auth logoutremoves the default profile, the profile you name as the argument or with--profile, or every profile with--all. Only--allasks for confirmation; one profile is removed at once.
auth commands do not take the global --api-key and --account-id flags; see Global Flags. auth switch takes the profile as its argument only; --profile fails with exit code 4.
Examples
Command Flags
These flags come from the CLI’s--help. All commands also accept the global flags.
auth login
--account-id must be a UUID. Give --api-key and --account-id together or not at all; one alone fails with exit code 4. Logging in to a profile that exists replaces its credentials without asking.
Without --api-key and --account-id, the command reads the API key and then the account ID. On a terminal, it asks for them and hides the key as you type it. Otherwise it reads them as two lines of stdin, so a script can pipe them in:
operation cancelled and exit code 4. The command has no --non-interactive.
auth logout
--all asks for confirmation; answer y or yes. --force without --all fails with exit code 4, and so do --all with a profile and two different profiles.
auth status
auth switch
This command has no command-specific flags.
Output
Noauth command prints the API key, in any format.
auth login, auth switch and auth logout
Table and plain output print one line that says what the command did, such as Switched to profile 'production'. With --output json, the command prints the profile it acted on and that line:
profile is empty for auth logout --all, and for auth logout when there are no profiles. CSV output has the columns profile,success,message and one row.
auth status
With --output json, auth status prints an object with these keys:
Table and plain output start with an
Authentication Status section that shows Profile, Account ID, Valid (Yes or No; when the check could not tell, the value is empty in table output and the line is left out of plain output) and, when set, Note. Why a check failed is not a row: it is the error line on stderr. When the account could be read, Account Details, Email Settings and Data Retention sections follow. CSV output has one row, with the columns profile, account_id, valid, error and note, then a column for each account field.
With --all, --output json prints the profile names:
No authentication profiles found, then a line that says to run ahasend auth login. CSV output prints nothing, and --output json prints:
--all and no profiles, table and plain output print No authentication profiles found, --output json prints an empty profiles array, and CSV output prints the profile header row alone.
Exit Codes
Theauth commands use the CLI’s exit codes. In particular:
- 2: The API rejected the key, or the key belongs to another account.
- 3: The profile does not exist, there is no default profile, or the configuration file cannot be read or written.
- 4: A flag or argument is missing or not valid, or a prompt was declined or got no answer.
- 6: The API refuses the key from this IP address.
- 7: The API cannot be reached.
auth status prints the status even when the check fails, and then exits with the code of that failure.

