Authenticate with the CLI

Before running any request or command in CLI, you need to authenticate yourself. Let's understand how you can do that.




The auth:login command lets you log in to Contentstack and save the session.

Note: If you want to use a specific endpoint, other than NA, refer to the Set Region command.


csdx auth:login


csdx login


  • -u, --username: Email address of your Contentstack account


The auth:logout command lets you log out of Contentstack and clear the session.


csdx auth:logout


csdx logout


f, --force: Exclude confirmation to logout

Add Token

To perform tasks using CLI, you will either need a management token or a delivery token. The auth:tokens:add command lets you add an existing management token or delivery token from your Contentstack account, and save it to the session for further use.

Note: The auth:tokens:add command will by default prompt your to add a management token in the session. If you want to add a delivery token instead, make use of the -d option.


csdx auth:tokens:add


  • -a, --alias=alias : Alias (name) of your token
  • -d, --delivery: Use this flag to save delivery token
  • -m, --management: Use this flag to save management token
  • -e, --environment=environment: Environment name to which the delivery token belongs
  • -f, --force: Exclude confirmation to replace existing alias
  • -k, --api-key=api-key: API key of the stack where the token exists
  • -t, --token=token: Value of the token

Delete Token

The auth:tokens:remove command lets you delete a management/delivery token from the session.

Note: This command will not delete the management/ deliverytoken from the stack.


csdx auth:tokens:remove


-a,--alias=alias: Alias (name) of the token to delete

List All Tokens

The auth:tokens command lists the existing tokens added to the session..


csdx auth:tokens


  • -columns=columns: To display specific columns, separated by comma
  • -filter=filter: To filter the property by partial string matching, ex: name=foo
  • -no-header: To hide table’s header in output
  • -no-truncate: To not truncate output to fit screen
  • -output=csv|json|yaml: To display output in a particular format
  • -sort=sort: To sort the list, prepend '-' to sort in a descending order

Display Username of a Session

The csdx auth:whoami command returns the username (email address) of the user who is currently logged in to the session.


csdx auth:whoami


csdx whoami

Additional Resources: If you want to set and use a particular region, other than North America (NA) region, for managing your content using CLI, refer to the Configuration guide.

Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page