Discovery API
List discovery jobs, see which assets each job added and removed, and cancel or retry jobs. Discovery runs are started on a zone (Discovery Zones & Environments API).
List Discovery Jobs
Retrieve a paginated list of discovery jobs across every zone, newest first. environment is the id of the discovery zone the job ran on. Every authenticated user can read jobs; cancel and retry need a manager or admin.
GET /api/v1/discovery/jobs/
# Example: failed jobs of zone 4
curl "https://idp.example.com/api/v1/discovery/jobs/?status=failed&environment=4" \
-H "Authorization: Bearer {access_token}"
# Response (excerpt)
{
"count": 87,
"next": "https://idp.example.com/api/v1/discovery/jobs/?page=2",
"previous": null,
"results": [
{
"id": 254,
"environment": 4,
"environment_name": "Production Kubernetes",
"job_type": "full",
"status": "completed",
"started_at": "2025-06-01T14:00:00Z",
"completed_at": "2025-06-01T14:03:42Z",
"duration_seconds": 222,
"assets_discovered": 48,
"assets_updated": 312,
"assets_removed": 3,
"dependencies_discovered": 187,
"errors_count": 0,
"error_message": "",
"is_scheduled": true,
"relay": null,
"relay_name": null,
"created_at": "2025-06-01T14:00:00Z"
}
]
}Filters & Ordering
Filters are query parameters and can be combined.
- environment: id of the discovery zone
- job_type: full, incremental or targeted
- status: pending, running, completed, partial, failed or cancelled
- is_scheduled: true for jobs started by the scheduler, false for jobs started by a user (or a retry)
- ordering: created_at, started_at or completed_at (prefix - for descending; default -created_at)
Job Statuses
Every discovery job goes through these statuses:
- pending: queued, not yet picked up (relay-managed zones stay pending until the relay claims the job)
- running: a worker or relay is executing the discovery
- completed: the discovery finished and the results were saved
- partial: the discovery finished but some resource types failed or it timed out; assets were saved but none were marked stale
- failed: the discovery hit an unrecoverable error (see error_message)
- cancelled: cancelled by a user before completion
Get Job Detail
Retrieve every field of a job, including environment_type, triggered_by_name, error_details and asset_change_counts ({"added": n, "removed": n}, zero for jobs that predate the list).
GET /api/v1/discovery/jobs/{id}/Assets Added and Removed by a Job
List the assets a job added or removed, paginated and sorted by name. Each row carries the asset name and type recorded at that time, plus the current uid and is_active of the asset. The Job History detail page shows the same lists.
Note: An invalid change value answers 400.
GET /api/v1/discovery/jobs/{id}/asset-changes/?change=added|removed&search=web
# Row
{ "id": 9, "change": "added", "asset": 412, "asset_uid": "azure-vm-abc123", "asset_name": "web-server-01", "asset_type": "vm", "asset_is_active": true }Cancel a Job
Cancel a job in the pending or running state (manager or admin). The Celery task is revoked and the job is marked cancelled with error_message "Cancelled by user". Other statuses answer 400.
Warning: Assets and dependencies saved before the cancellation are kept. Cancelling a job does not roll back partial results.
POST /api/v1/discovery/jobs/{id}/cancel/
# Response
{ "status": "cancelled", "job_id": "254", "message": "Discovery job cancelled successfully" }Retry a Job
Retry a failed, cancelled or partial job (manager or admin). A new job is queued on the same zone with the same full_scan option; the original job stays in the history. Other statuses or an inactive zone answer 400, and a zone that already has a pending or running job answers 409.
POST /api/v1/discovery/jobs/{id}/retry/
# Response (local zone)
{ "status": "queued", "original_job_id": "254", "new_job_id": "255", "task_id": "…" }
# Response (relay-managed zone)
{ "status": "pending_relay", "original_job_id": "254", "new_job_id": "255", "task_id": null, "message": "Discovery queued — the relay will pick it up on next contact." }Job Statistics
Aggregates over the jobs matching the same filters as the list:
Note: recent_stats sums the last 10 completed jobs; by_environment lists at most 10 zones.
GET /api/v1/discovery/jobs/stats/
# Response
{
"total": 1243,
"by_status": [ { "status": "completed", "count": 1185 }, { "status": "failed", "count": 41 } ],
"by_environment": [ { "environment__name": "Production Kubernetes", "count": 310 } ],
"recent_stats": {
"total_assets_discovered": 120,
"total_assets_updated": 2400,
"total_dependencies_discovered": 830
}
}Active Jobs
The pending and running jobs, newest first, without pagination (for quick polling):
Note: For push updates use the discovery_started, discovery_completed and discovery_failed WebSocket events.
GET /api/v1/discovery/jobs/running/