Often developers and IT organizations have routine tasks that can be encapsulated into a tool. There are likely many SendGrid customers who have written scripts to manage these kinds of tasks.
For example, I was recently developing some internal tools, and making contributions during Hacktoberfest. I found myself repeatedly enabling and disabling webhooks for inbound parse, creating API keys, and uploading contacts. As a developer, context switching to make these changes in the UI slowed me down.
Then, a few weeks ago, I overheard a customer request to retrieve teammates who are admins for subuser accounts. This is possible through our API, of course. But, not everyone wants to (or can) write code to solve a niche use case with the SendGrid platform.
Having come from a varied background, including IT and operations, I thought this seems like a common situation for a command line tool. So, we built one and today we’re announcing a new open source project: sendgrid-cli.
The SendGrid CLI (Command Line Interface) tool allows you to interact with SendGrid services from the command line.
The SendGrid CLI removes the need to write code to perform common management activities on the SendGrid platform like uploading a CSV file and enabling or disabling webhooks.
What can you do with the CLI?
At release, we have the following capabilities:
- Uploading a CSV file of contacts
- Listing API Keys
- Listing teammates within each subuser account
- Managing webhooks
You may wonder, what about sending email?! We’re taking an opinionated approach, and kept sending email out of this project. At the outset, including email in the project could dilute the main types of activities we want this tool to expedite, and why we focused on use cases like enabling and disabling webhooks, uploading contacts, and retrieving subusers and teammates.
Keeping the tool focused on scenarios related to administration and management of the customer’s use of SendGrid’s platform. Of course, we’re open to your suggestions as well, so feel free to open an issue or PR.
Some technical points
If you’re curious about the technical underpinnings of sendgrid-cli:
- Since sendgrid-cli is a NodeJS project, we used the yargs library for creating the core command line utility features. Yargs made it easy and maintainable to create a subcommand structure in the project.
- The main API calls are made via the @sendgrid/client library, and live in the lib/sgclient.js file.
- The output for any of the commands sends to stdout in JSON format, and so can be saved to a file for further processing.
The project is released under an MIT license. You can find it in the SendGrid GitHub Organization at https://github.com/sendgrid/sendgrid-cli. We welcome your contributions and suggestions, so feel free to open an issue or PR!
We hope you find this tool useful, look forward to contributions, and would love to know how you’re using it!