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

POST .../codesec/api/repositories/job/queue

Synchronize repositories from a source integration (for example Azure)—does not start vulnerability scans

POST .../codesec/api/v1/repositories/scan

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

  1. Create or update a Permission Set with rights required for repository scan and CodeSec APIs.

  2. Create a Role bound to that permission set and the correct Application Scope.

  3. 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/tokens

  • CodeSec 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/json

Admin 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:

  1. Optionally call repositories/job/queue with source and integrationId to sync repo list.

  2. List repositories via CodeSec/Code Repository APIs for that integration.

  3. Batch up to 10 repos per POST .../v1/repositories/scan call.

  4. 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

  1. Token creation returns HTTP 200 with a valid bearer secret.

  2. repositories/scan returns HTTP 200 and scan jobs appear in the UI queue.

  3. 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

ANY:* or correct allowed_endpoints; role + API key permissions

405 with PAT

Use scoped bearer token on edge URL

“Queue” API did not scan

Use /v1/repositories/scan in batches of 10

Wrong host

Regional .edge.cloud.aquasec.com


Related Resources