Getting started with the Nylas CLI
Quickly install, set up credentials, and begin API requests with the steps in the guide below.
Prerequisites
To start using the Nylas CLI, you'll need the following requirements:
Installing the CLI
Install the Nylas CLI through homebrew or Binary Installation below.
Homebrew installation
Run the command below to install the Nylas CLI using homebrew
.
brew install nylas/nylas-cli/nylas
Also, for upgrading to the most recent version of the Nylas CLI, use the following brew
command.
brew upgrade nylas
Binary installation
For users wanting to install the binary file, the links below contain downloads for each respective operating system. The checksum is available for file verification.
- macOS
- Linux
- Windows
- Checksum verification
At the terminal
After installing the Nylas CLI, begin initializing and authenticating your Dashboard credentials. Once you’ve completed the process, these settings continue to work in the CLI for your application without having to input account information again.
Initializing the CLI
Set up your Nylas CLI with your Nylas application's client ID and secret. Follow the steps from the terminal actions below.
Authenticating your account
With your account’s email address, start the authentication within your terminal. You can choose to authenticate through your browser or through the terminal prompts.
The code below shows the formatting of the command and response when authenticating.
nylas auth [email_address]
INFO Using Nylas's Hosted Authentication, we will obtain a valid access token that can be used to interact with Nylas's public APIs.
INFO For more info, visit: https://developer.nylas.com/docs/v2/developer-guide-v2/authentication/hosted-authentication/
Browser authentication
Input y
to begin authenticating in your browser through Hosted Authentication.
? Open your browser to authenticate your account (Y/n): y
INFO Opening your browser for hosted authentication login...
? Check your browser, or, manually enter your access token:
SUCCESS Verified and saved your access token <ACCESS_TOKEN>.
In the response, the Nylas CLI also verifies your access token in the terminal when authenticating in the browser.
Manual authentication in terminal
Selecting n
requires you to manually authenticate in the terminal with your credentials.
Making your first request
With your account credentials configured, you can begin to make API requests from your terminal.
Get Accounts request
Retrieve your account information with a GET
request in the Nylas CLI.
nylas api accounts get
Get Accounts response
You’ll see similar results to the example below with a successful request.
[
{
"id": "<ACCOUNT_ID>",
"account_id": "<ACCOUNT_ID>",
"billing_state": "paid",
"provider": "eas",
"sync_state": "running",
"trial": false,
"email": "william@example.com"
},
{
"id": "<ACCOUNT_ID>",
"account_id": "<ACCOUNT_ID>",
"billing_state": "paid",
"provider": "gmail",
"sync_state": "running",
"trial": false,
"email": "william@example.com"
}
]
Congratulations!
You’re well on your way to using the Nylas CLI in your workflow! Once you’ve completed the process, these settings continue to work in the CLI for your application without having to input account credentials again.
Video walkthrough
Prefer video? You can watch our LiveStream Coding with Nylas.
What's next?
When you’re ready to build your own application, you can use the credentials from your provider as the <NYLAS_CLIENT_ID>
and <NYLAS_CLIENT_SECRET>
for any requests. For more information, see the Create an application guide.
These links can help you make the most of your Nylas CLI experience:
- Nylas CLI API Requests.
- Using Webhooks.
- API References.
- Read the blog post Working with the Nylas CLI.
- Read the blog post Super Power the Nylas CLI With Fig.
- Read the blog post Fig Workflows and the Nylas CLI.