Supply Chain API – Authenticating and Queueing Azure Repository Scans
Overview
Integrators often confuse two CodeSec repository endpoints: one synchronizes integrated repositories; another starts scans. Authentication failures (HTTP 401 or 405) usually trace to token scope, permission sets, or calling the wrong regional edge hostname. This article documents the correct bearer-token setup and the scan API to use for batch repository scanning.
Endpoint Purposes
Endpoint | Purpose |
|---|---|
| Synchronize repositories from a source integration (for example Azure)—does not start vulnerability scans |
| Queue scans for code repositories (up to 10 repositories per request) |
A successful job/queue response returns a job identifier (for example ["315886"]) reflecting sync work, not scan completion.
Authentication Setup (Bearer Token)
1. Create token with broad CodeSec scope
When requesting a token from the regional token API, include allowed endpoints that cover CodeSec edge calls:
POST_BODY='{"validity":240,"allowed_endpoints":["ANY:*"]}'Post to your regional token endpoint, for example:
https://<region>.api.cloudsploit.com/v2/tokens
2. Assign permissions
Create or update a Permission Set with rights required for repository scan and CodeSec APIs.
Create a Role bound to that permission set and the correct Application Scope.
Create or update an API Key assigned to that role.
3. Call regional edge URLs
Use the edge hostname for your region, not only the generic codesec.aquasec.com landing host. Example pair:
Token:
https://eu-1.api.cloudsploit.com/v2/tokensCodeSec API:
https://eu-central-1.edge.cloud.aquasec.com/codesec/api/...
Match region to your tenant (EU vs US examples differ).
4. Use bearer token on API requests
POST https://<region>.edge.cloud.aquasec.com/codesec/api/v1/repositories/scan
Authorization: Bearer <token>
Content-Type: application/jsonAdmin PAT alone may return 405 Not Allowed on endpoints expecting scoped bearer tokens.
Scanning All Repositories in an Azure Integration
There is no single API call to scan every repository in an integration in one request. Typical automation:
Optionally call
repositories/job/queuewithsourceandintegrationIdto sync repo list.List repositories via CodeSec/Code Repository APIs for that integration.
Batch up to 10 repos per
POST .../v1/repositories/scancall.Pace batches (for example 2 seconds between requests is generally acceptable from an API rate-limit perspective).
Monitor progress in the Aqua Supply Chain / Code Repositories UI for your tenant, not the bare codesec host status page.
Verification
Token creation returns HTTP 200 with a valid bearer secret.
repositories/scanreturns HTTP 200 and scan jobs appear in the UI queue.Distinguish sync job IDs from active scan jobs in the repository scan history.
Platform Coverage
Component: Supply Chain Security, CodeSec API
Integrations: Azure DevOps, GitHub, GitLab (pattern applies; paths unchanged per source)
Summary
Issue | Fix |
|---|---|
401 Unauthorized |
|
405 with PAT | Use scoped bearer token on edge URL |
“Queue” API did not scan | Use |
Wrong host | Regional |
Related Resources
Did you find it helpful? Yes No
Send feedback