Making API requests with the Nylas CLI
With the Nylas CLI, you can make API requests directly from the terminal. Follow the Calendar endpoint examples to view the requests and responses through the CLI.
nylas api [command] [flags]
CLI Available Commands
Each API command matches Nylas API endpoints. View the available commands in the CLI below or in your terminal with the help
flag. View the Nylas CLI Commands for all available actions.
accounts
: Gets a list of authenticated accounts.applications
: Gets your application info.calendars
: Calendars API commands.contacts
: Contacts API commands.delta
: Delta API commands.drafts
: Drafts API commands.events
: Events API commands.files
: Files API commands.folders
: Folders API commands.ip-addresses
: Gets a list of Nylas IP addresses (paid customers only).job-statuses
: Job-Statuses API commands.labels
: Labels API commands.messages
: Messages API commands.neural
: Neural API commands.resources
: Resources API commands.send
: Send API commands.threads
: Threads API commands.webhooks
: Gets a list of webhooks.
Using a File Reference
Add a JSON
file to use as a reference for any available commands. The <
character directs the command to a filename in the current directory.
nylas api [commands] < [sample.json]
File Reference Example
The POST
API request for the Calendar endpoint uses the calendar_test.json
file for query parameters.
nylas api calendars post < calendar_test.json
JSON File Contents
{
"name": "My New Calendar",
"description": "Description of my new calendar",
"location": "Location description",
"timezone": "America/Los_Angeles"
}
POST Calendars Response
{
"account_id": "<ACCOUNT_ID>",
"description": "Description of my new calendar",
"id": "<CALENDAR_ID>",
"is_primary": false,
"job_status_id": "db83las7n4ekrdgzaqnbd8plc",
"location": "Location description",
"name": "My New Calendar",
"object": "calendar",
"read_only": false,
"timezone": "America/Los_Angeles"
}
CLI API Requests
The request and response examples below go through each of the methods for the Nylas Calendars endpoint.
The responses below use the default JSON
output format. For information about the table
formatting, see the table section guide.
GET Calendars Example
For the complete reference, see the GET /calendars API documentation.
GET Calendars Request
The GET
request example for the /calendars
endpoint has the --limit
flag added.
nylas api calendars get --limit=2
GET Calendars Response
[
{
"account_id": "<ACCOUNT_ID>",
"description": "Emailed events",
"id": "<CALENDAR_ID>",
"is_primary": null,
"location": null,
"name": "Emailed events",
"object": "calendar",
"read_only": true,
"timezone": null
},
{
"account_id": "<ACCOUNT_ID>",
"description": null,
"id": "<CALENDAR_ID>",
"is_primary": true,
"location": null,
"name": "hello@example.com",
"object": "calendar",
"read_only": false,
"timezone": "America/Vancouver"
}
]
POST Calendars Example
For the complete reference, see the POST /calendars API documentation.
POST Calendars Request
The POST
request example for the /calendars
endpoint has the --body
flag added with additional query parameters. To add these parameters as a JSON
file, view the guide on Using a File Reference.
nylas api calendars post --body='{
"name": "My New Calendar",
"description": "Description of my new calendar",
"location": "Location description",
"timezone": "America/Los_Angeles"
}'
POST Calendars Response
{
"account_id": "<ACCOUNT_ID>",
"description": "Description of my new calendar",
"id": "<CALENDAR_ID>",
"is_primary": false,
"job_status_id": "3lsrtnwabxta2v171uht241x9",
"location": "Location description",
"name": "My New Calendar",
"object": "calendar",
"read_only": false,
"timezone": "America/Los_Angeles"
}
POST Calendars Terminal Example
The video below shows how the POST /calendars
request works in the CLI.
PUT Calendars Example
For the complete reference, see the PUT /calendars API documentation.
PUT Calendars Request
The PUT
request example for the /calendars
endpoint includes the <CALENDAR_ID>
value and has the --body
flag added.
nylas api calendars put <CALENDAR_ID> --body='{"description": "Better description of the calendar."}'
PUT Calendars Response
{
"account_id": "<ACCOUNT_ID>",
"description": "Better description of the calendar.",
"id": "<CALENDAR_ID>",
"is_primary": false,
"job_status_id": "3wb767lba3adaxalnkw4sqhg8",
"location": "Location description",
"name": "My New Calendar",
"object": "calendar",
"read_only": false,
"timezone": "America/Los_Angeles"
}
DELETE Calendars Example
For the complete reference, see the DELETE /calendars API documentation.
DELETE Calendars Request
The DELETE
request example for the /calendars
endpoint includes the <CALENDAR_ID>
value.
nylas api calendars delete <CALENDAR_ID>
DELETE Calendars Response
{
"job_status_id": "14fbiqtmnersloa2o6tdqd25b"
}