Main entry point for the Checkmarx On-Premise REST API client.

const cxClient = new CheckmarxClient({
apiUrl: 'https://checkmarx.example.com',
apiPath: 'api',
token: 'my-bearer-token',
});

const projects = await cxClient.projects({ limit: 50 });
const project = await cxClient.project('project-id');
const branches = await cxClient.project('project-id').branches();
const scans = await cxClient.scans({ 'project-id': 'project-id' });
const summary = await cxClient.scanSummary({ 'scan-ids': 'scan-id' });
const report = await cxClient.createReport({ fileFormat: 'PDF', data: { scanId: 'scan-id' } });
const file = await cxClient.downloadReport('report-id');
const overview = await cxClient.projectsOverview();

Constructors

Methods

  • Authenticates against the Checkmarx identity endpoint using the refresh token provided at construction time, and updates the client's Authorization header with the returned access token for all subsequent requests.

    POST <authApiPath>

    Parameters

    • authApiPath: string

      Path to the auth endpoint, relative to apiUrl. Overrides the default apiPath since the auth endpoint lives outside the main API path. Example: 'auth/realms/CxOne/protocol/openid-connect/token'

    Returns Promise<CheckmarxAuthResponse>

    The auth response containing token_type and access_token

    await cxClient.authenticate('auth/realms/CxOne/protocol/openid-connect/token');
    // All subsequent calls now use the new access token automatically
    const projects = await cxClient.projects();
  • Downloads a generated report as a binary ArrayBuffer.

    GET /api/reports/{reportId}

    Parameters

    • reportId: string

      The report ID to download

    Returns Promise<ArrayBuffer>

    The report content as an ArrayBuffer

  • Subscribes to a client event.

    Type Parameters

    • K extends "request"

    Parameters

    Returns this

    cxClient.on('request', (event) => {
    console.log(`${event.method} ${event.url}${event.durationMs}ms`);
    if (event.error) console.error('Request failed:', event.error);
    });
  • Returns a ProjectResource for a given project ID, providing access to project-level data and sub-resources.

    The returned resource can be awaited directly to fetch project info, or chained to access nested resources.

    Parameters

    • projectId: string

      The project ID

    Returns ProjectResource

    A chainable project resource

    const project  = await cxClient.project('project-id');
    const branches = await cxClient.project('project-id').branches({ branchName: 'main' });
  • Fetches all projects accessible to the authenticated user.

    GET /api/projects

    Parameters

    • Optionalparams: ProjectsParams

      Optional filters: limit, offset, name, ids, tags

    Returns Promise<
        {
            filteredTotalCount: number;
            projects: CheckmarxProject[];
            totalCount: number;
        },
    >

    An object containing projects and pagination counts

  • Fetches all scans accessible to the authenticated user.

    GET /api/scans

    Parameters

    • Optionalparams: ScansParams

      Optional filters: project-id, project-name, branch, status, tags, limit, offset, from-date, to-date

    Returns Promise<
        {
            filteredTotalCount: number;
            scans: CheckmarxScan[];
            totalCount: number;
        },
    >

    An object containing scans and pagination counts