[API] [CURL] get agent in Data Collection Management

Hi Community,

Everyday, I’m doing an agents export from Rapid7 - Login*******/agent-management
I’ll looking to script/shedule it using API, CURL and Powershell.
I’m using US1 cloud tenant and have already generated a user API.
Next step on which I’m stuck : Build the CURL query to get all my agents.
I’v no idea how to…api host to use…fully newbies…
Any hint from scripting gurus ?


Hi Thiery,

you cannot schedule a CSV export via agent management, we do however have a Graphql Preview API, which is the API used to load the agent mangement page which we can provide access to


1 Like

@david_smith I 'd love be able to reach this Graphql and have corresponding docs
Could you ?

@david_smith Hi David, Looking for acess to the Graphql Preview API. Thanks.

Sent your way!

1 Like

@david_smith : first query try

C:\Windows\System32\curl.exe https://us.api.insight.rapid7.com/graphql -v -X POST -H “Accept-Version: kratos” -H “Content-Type: application/json” -H “X-Api-Key: SecretKey” --data “{organizations(first: 1){edges{node{idname}}”

{"errors":[{"message":"Request query is not valid","extensions":{"statusCode":403},"errorType":"ValidationError","path":null}]}

Query grab from doc
Any hint about what I did wrong ?

FYI : found something working : ie :

C:\Windows\System32\curl.exe -g -X POST -H “Content-Type: application/json” -H “Accept-Version: kratos” -H “X-Api-Key: ****************” -d ‘{“query” : “query($orgId: String!) {organization(id: $orgId) {assets(first: 10000) {edges {node {host {hostNames{name }}}}}}}”,“variables”:{“orgId”:"********************"}}’ https://us.api.insight.rapid7.com/graphql/

It’s very cases sensitive … and tricky in Windows cmd ^^

1 Like

Glad you got it working @thierry_bon!

1 Like