Skip to main content

Discovery Jobs API

Discovery jobs are how Infracast populates and updates your infrastructure graph. A discovery job runs one or more plugins against your cloud accounts, Kubernetes clusters, or on-premises systems, collecting resource data and building the node/edge graph. After discovery completes, the audit engine automatically re-evaluates all compliance rules.


Endpoints

MethodPathDescriptionPermission
GET/api/v1/tenants/{tenantID}/jobsList discovery jobsjobs:read
POST/api/v1/tenants/{tenantID}/jobsCreate and start a jobjobs:create
GET/api/v1/tenants/{tenantID}/jobs/{jobID}Get job status/detailsjobs:read
DELETE/api/v1/tenants/{tenantID}/jobs/{jobID}Cancel a running jobjobs:cancel
GET/api/v1/tenants/{tenantID}/jobs/{jobID}/streamStream job logsjobs:read

Create a Discovery Job

POST /api/v1/tenants/{tenantID}/jobs

Creates and immediately starts a discovery job.

Request Body

{
"name": "AWS Full Discovery — us-east-1",
"plugins": ["aws"],
"credential_id": "cred-aws-prod-abc123",
"config": {
"regions": ["us-east-1", "us-west-2"],
"services": ["ec2", "s3", "iam", "rds", "lambda", "eks"],
"account_id": "123456789012"
}
}

Request Fields

FieldTypeRequiredDescription
namestringHuman-readable job name
pluginsarrayPlugin IDs to run (see Plugin List)
credential_idstringCredential to use for discovery
configobjectPlugin-specific configuration
config.regionsarrayAWS regions to scan (default: all)
config.servicesarrayAWS services to scan (default: all)

Example Request

curl -X POST https://api.infracast.io/api/v1/tenants/acme-corp/jobs \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Full AWS Discovery",
"plugins": ["aws"],
"credential_id": "cred-aws-prod-abc123",
"config": {
"regions": ["us-east-1", "us-east-2"],
"services": ["ec2", "s3", "iam", "rds", "eks", "cloudtrail"]
}
}'

Response

{
"id": "job-abc123def456",
"tenant_id": "acme-corp",
"name": "Full AWS Discovery",
"status": "running",
"plugins": ["aws"],
"credential_id": "cred-aws-prod-abc123",
"config": {
"regions": ["us-east-1", "us-east-2"],
"services": ["ec2", "s3", "iam", "rds", "eks", "cloudtrail"]
},
"started_at": "2024-03-16T10:00:00Z",
"created_at": "2024-03-16T10:00:00Z"
}

Get Job Status

GET /api/v1/tenants/{tenantID}/jobs/{jobID}
curl -H "Authorization: Bearer $TOKEN" \
"https://api.infracast.io/api/v1/tenants/acme-corp/jobs/job-abc123def456"

Response

{
"id": "job-abc123def456",
"tenant_id": "acme-corp",
"name": "Full AWS Discovery",
"status": "completed",
"plugins": ["aws"],
"stats": {
"nodes_discovered": 1247,
"nodes_updated": 312,
"nodes_removed": 8,
"edges_created": 4820,
"findings_created": 34,
"findings_resolved": 12,
"duration_seconds": 187
},
"started_at": "2024-03-16T10:00:00Z",
"completed_at": "2024-03-16T10:03:07Z",
"created_at": "2024-03-16T10:00:00Z"
}

Job Status Values

StatusDescription
pendingJob created, not yet started
runningDiscovery in progress
completedDiscovery completed successfully
failedDiscovery failed (see error field)
cancelledJob was cancelled before completion

List Discovery Jobs

GET /api/v1/tenants/{tenantID}/jobs
# List recent jobs
curl -H "Authorization: Bearer $TOKEN" \
"https://api.infracast.io/api/v1/tenants/acme-corp/jobs?per_page=10&sort=-created_at"
{
"items": [
{
"id": "job-abc123def456",
"name": "Full AWS Discovery",
"status": "completed",
"plugins": ["aws"],
"stats": { "nodes_discovered": 1247, "duration_seconds": 187 },
"started_at": "2024-03-16T10:00:00Z",
"completed_at": "2024-03-16T10:03:07Z"
},
{
"id": "job-xyz789uvw012",
"name": "Kubernetes Scan — prod-cluster",
"status": "failed",
"plugins": ["kubernetes"],
"error": "Connection refused: kubeconfig context 'prod-cluster' unreachable",
"started_at": "2024-03-15T09:00:00Z",
"completed_at": "2024-03-15T09:00:15Z"
}
],
"total": 47,
"page": 1,
"per_page": 10
}

Stream Job Logs

Get real-time log output from a running discovery job (Server-Sent Events):

curl -H "Authorization: Bearer $TOKEN" \
"https://api.infracast.io/api/v1/tenants/acme-corp/jobs/job-abc123def456/stream"

# Output:
data: {"ts":"2024-03-16T10:00:01Z","level":"info","msg":"Starting AWS plugin for account 123456789012"}
data: {"ts":"2024-03-16T10:00:05Z","level":"info","msg":"Discovered 342 EC2 instances in us-east-1"}
data: {"ts":"2024-03-16T10:00:12Z","level":"info","msg":"Discovered 67 S3 buckets"}
data: {"ts":"2024-03-16T10:00:45Z","level":"info","msg":"Discovered 234 IAM users, 512 IAM roles"}
data: {"ts":"2024-03-16T10:01:20Z","level":"warn","msg":"Skipping service 'glacier': insufficient permissions"}
data: {"ts":"2024-03-16T10:03:07Z","level":"info","msg":"Discovery complete: 1247 nodes, 4820 edges"}

Available Plugins

List all available discovery plugins:

GET /api/v1/plugins
Plugin IDNameDiscovers
awsAmazon Web ServicesEC2, S3, IAM, RDS, Lambda, EKS, CloudTrail, VPC, KMS, and 40+ more
azureMicrosoft AzureVMs, Storage, SQL, Networking, Entra ID, Key Vault
gcpGoogle Cloud PlatformCompute, GCS, Cloud SQL, IAM, GKE, Networking
kubernetesKubernetesPods, Services, Deployments, RBAC, Namespaces
m365Microsoft 365Users, Groups, Applications, Exchange, SharePoint
githubGitHubRepositories, Actions, Org members
agentOn-Premises AgentLocal systems via installed agent

Plugin Configuration Examples

AWS Discovery

{
"plugins": ["aws"],
"config": {
"regions": ["us-east-1", "us-west-2", "eu-west-1"],
"services": ["ec2", "s3", "iam", "rds", "lambda", "eks", "cloudtrail", "kms", "shield", "config"],
"role_arn": "arn:aws:iam::123456789012:role/InfracastReadOnly",
"external_id": "infracast-external-id-abc123"
}
}

Kubernetes Discovery

{
"plugins": ["kubernetes"],
"config": {
"cluster_name": "prod-eks-cluster",
"kubeconfig": "base64-encoded-kubeconfig",
"namespaces": ["default", "production", "monitoring"],
"include_rbac": true
}
}

Multi-Plugin Job

{
"name": "Full Environment Discovery",
"plugins": ["aws", "kubernetes"],
"credential_id": "cred-aws-prod",
"config": {
"aws": {
"regions": ["us-east-1"],
"services": ["ec2", "eks", "iam"]
},
"kubernetes": {
"cluster_name": "prod-eks",
"include_rbac": true
}
}
}

Cancel a Job

DELETE /api/v1/tenants/{tenantID}/jobs/{jobID}

Cancels a running job. Any data already discovered is preserved.


Scheduling Discovery

Discovery jobs can be scheduled to run automatically:

POST /api/v1/tenants/{tenantID}/reports/schedule
{
"type": "discovery",
"job_template": {
"name": "Daily AWS Scan",
"plugins": ["aws"],
"credential_id": "cred-aws-prod-abc123"
},
"frequency": "daily",
"time": "02:00",
"timezone": "UTC"
}
Best Practice

Schedule discovery at least daily (nightly recommended) to keep your compliance posture current. For regulated environments (FedRAMP, DoD), run discovery before generating monthly ConMon deliverables.


Error Handling

Common job failure reasons:

ErrorCauseFix
insufficient_permissionsIAM role missing required read permissionsAttach ReadOnlyAccess or scoped read policy
invalid_credentialCredentials expired or revokedUpdate credential in Settings → Credentials
rate_limitedAWS API rate limit hitReduce discovery scope or schedule during off-peak
connection_refusedKubernetes API unreachableVerify kubeconfig and network connectivity
node_limit_exceededLicense node limit reachedUpgrade plan or reduce discovery scope

Next Steps