Start asynchronous report download

Starts a background task that generates the requested report. The response includes a uuid for the download job.

Use the UUID to poll GET /v1/downloads/status/{uuid}. While the report is being generated, the status response contains status: "downloading". When status is "completed", download the generated file from csv_file.link or json_file.link in that status response.

The download links are signed, temporary URLs. Request a new status response if a link has expired.

API_HOST="https://api.securitytrails.com"     # the API host
KEY="API_KEY"
PROJECT_ID="PROJECT_ID"

# 1. Enqueue — returns 202 + uuid (does NOT return the report)
uuid=$(curl -fsS -H "apikey: $KEY" \
"$API_HOST/v2/action_center/reports_async/$PROJECT_ID/exposures-issue" \
  | jq -r .uuid)
echo "queued: $uuid"

# 2. Poll status until completed (every 5s); grab the S3 link when done
# curl -X GET "https://api.securitytrails.com/v2/action_center/reports_async/$PROJECT_ID/exposures-issue" -H "apikey: $API_KEY"

while :; do
  resp=$(curl -fSv -H "apikey: $KEY" "$API_HOST/v1/downloads/status/$uuid")
  status=$(jq -r '.status // "unknown"' <<<"$resp")
  echo "status=$status progress=$(jq -r '.completed_percent // "n/a"' <<<"$resp")"
  case "$status" in
    completed) link=$(jq -r '.csv_file.link' <<<"$resp"); echo "$link\n"; break ;;
    failed|error|deleted) echo "ended: $status"; exit 1 ;;
  esac
  sleep 5
done

# 3. Download the finished CSV (link is a presigned S3 URL; no apikey needed)
curl -fsS -o exposures-by-issue.csv "$link"
echo "saved exposures-by-issue.csv"

Path Params
string
required

The unique identifier of the project.

string
enum
required

The type of report to generate, such as exposures-host.

Allowed:
Response

Language
Credentials
Header
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json