Skip to main content
Version: v12

Retrieve Active Assets

This article provides an example demonstrating how to query for active assets using the BQL API. While this example focuses on a specific set of attributes, you can tailor the query to include the attributes that fit your needs. For more details on the BQL API, see the BQL API documentation.

Start the query

Send a POST request to start the query. This example retrieves active assets with selected fields using projection mode.

curl -X POST 'https://<your-brinqa-instance>/v1/api/bql' \
-H 'Content-Type: application/json' \
-H 'Authorization: ApiKey <your-api-token>' \
-d '{
"query": "FIND Asset WHERE status = \"Active\"",
"returningFields": ["id", "complianceStatus", "displayName", "firstSeen", "lastUpdated", "status"],
"limit": 10
}'
note

Replace <your-brinqa-instance> with the URL of your Brinqa Platform and <your-api-token> with your API token.

The API returns a 202 Accepted response with a Location header:

HTTP/2 202
Location: /v1/api/bql/eyJqb2JI...
Retry-After: 2

Fetch results

Use the Location value from the previous response to poll for results:

curl 'https://<your-brinqa-instance>/v1/api/bql/eyJqb2JI...' \
-H 'Authorization: ApiKey <your-api-token>'

If the query is still processing, the response has status "processing". Poll again after the number of seconds indicated in the Retry-After header. When the query completes, the response contains the matching assets:

{
"status": "completed",
"state": "success",
"message": "Query completed successfully.",
"results": [
{
"id": 1686091182456995840,
"complianceStatus": "Compliant",
"displayName": "prod-web-01.us-east.example.com",
"firstSeen": "2023-07-31T19:31:12.561Z",
"lastUpdated": "2023-08-08T19:07:06.024Z",
"status": "Active"
},
{
"id": 1686091182456995842,
"complianceStatus": "Compliant",
"displayName": "prod-db-02.us-west.example.com",
"firstSeen": "2023-07-31T19:31:13.917Z",
"lastUpdated": "2023-08-08T19:07:06.024Z",
"status": "Active"
}
],
"totalRows": 2,
"pageRows": 2,
"cursor": null
}