Gremlin provides a REST API that lets you programmatically perform actions, including running attacks and Scenarios. The easiest way to generate a REST API command is to create and configure an attack using the web app, scrolling to the bottom, and clicking on Gremlin API Examples in the bottom-right corner. The popup window contains everything you need to run your attack using the API.
This generates a curl command that you can enter into a terminal, API tool, CI/CD solution, performance testing suite, or any other application that can make HTTP requests. You can choose which Authorization method to use, including Bearer Tokens or any API keys you’ve created.
For now, copy and paste the contents of the CURL example text box into your terminal. Here’s an example for a CPU attack::
curl -i -X POST 'https://api.gremlin.com/v1/attacks/new?teamId=ed09d800-018a-591a-b591-75cb717a3eb5' -H 'Content-Type: application/json;charset=utf-8' -H 'Authorization: Bearer Yy1kNWJhMWMyNy05OGVlLTU2ZWUtOWUwZS00OTY5NzA1ZGUyOWI6YW5hKzEyQG******************' -d '{"target":{"hosts":{"ids":["ip-10-0-48-196.ec2.internal"]},"type":"Exact"},"command":{"type":"shutdown","commandType":"Shutdown","args":["-d","0"]}}'
After sending the request to the API, we can watch the attack start in the Gremlin web app:
You can learn more about Gremlin’s API via our docs, and you can click through our interactive Swagger documentation to see the full set of capabilities.