Skip to main content

GraphQL API

Call the Vulnara GraphQL API with a bearer token and the X-Tenant header, page and filter lists, handle errors, and subscribe to live events.

Everything the Vulnara web app does goes through one GraphQL API. You can call it yourself to automate scans, pull findings into other tools, or build your own reports. The CLI, the GitHub Action and the MCP server all use the same API.

What it is for

  • Integrating Vulnara with your own tooling, dashboards and pipelines.
  • Doing in bulk what the web app does one item at a time.
  • Receiving scan progress, notifications and changes to your team's records live over a WebSocket.

How it works

There is one endpoint, https://vulnara-gw.rso.dev/graphql. It takes queries and mutations as JSON over HTTP POST, and subscriptions over a WebSocket on the same path. Introspection is on, so any GraphQL client or IDE can load the schema.

Every request carries two headers:

  • Authorization: Bearer <access token>.
  • X-Tenant: the id of the team the request is about.

Vulnara checks your role in that team before it runs each field.

What you can set

On every list query, the list argument takes the same fields:

  • limit: how many items to return. The default is 10, the maximum is 500.
  • skip: how many items to skip, for paging. The default is 0.
  • filters: a list of { field, ... } filters. Use stringEquals or idEquals for an exact match, categoryEquals with a ScanCategory (SAST, SCA, SECRETS or PII on repository findings, and DAST on web application findings) for a category, and min or max for a range. Several categoryEquals filters on the same field match a finding in any of those categories.
  • sort: the field to sort by. The default is createdAt.
  • order: ASC or DESC. The default is DESC.
  • search: free text to search for.

A list returns total, the number of items that match the filters, and items, the current page.

graphql
query Findings($scanResultId: ID!) {
  scanFindings(
    list: {
      limit: 50
      skip: 0
      filters: [{ field: "scanResultId", idEquals: $scanResultId }]
      sort: "severity"
      order: DESC
    }
  ) {
    total
    items { id severity file line }
  }
}

Sorting findings by severity ranks them Critical, High, Medium, Low, not alphabetically.

Do it

  1. Get an access token

    Use one of these:

    • A service account, for scripts and CI. Create one (see Service accounts), then exchange its name and token for an access token at the OAuth token endpoint, with the client_credentials grant, client_id set to hl04e6MSMRY60LdpGh5rdMRQjkPxvldAYoqXdzo4, username set to the service account name, password set to its token, and scope=profile. The endpoint is the token-url default on the GitHub Action reference. The response carries access_token and expires_in.
    • Your own sign-in, for trying things out. Run vulnara login with the CLI. It stores your access token in ~/.config/vulnara/jwt/access_token.
  2. Find your team id

    Query myUser. Its tenants field lists the teams you belong to, with their ids.

    graphql
    query { myUser { tenants { id } } }
  3. Send a request

    sh
    curl https://vulnara-gw.rso.dev/graphql \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer $VULNARA_TOKEN" \
      -H "X-Tenant: my-team" \
      -d '{"query":"{ repositories(list: { limit: 5 }) { total items { id repositoryName } } }"}'

Every query, mutation and type, with examples, is on the GraphQL reference.

The X-Tenant header

X-Tenant must name a team you belong to. If it names one you do not belong to, the request is refused. If you leave it out, Vulnara uses the first team you are a member of, so always send it when you belong to more than one.

Roles guard every field

Each team member holds a role: VIEWER, EDITOR or ADMIN. A higher role includes the lower ones.

  • VIEWER reads: repositories, scans, findings, the dashboard and statistics.
  • EDITOR also changes things: adds and deletes repositories, networks, web applications and workspaces, starts and cancels scans, manages schedules, alert rules and triage decisions.
  • ADMIN also manages credentials, people and money: git tokens, service accounts, members, invitations, roles, transfers between teams, connector agents for networks, self-managed GitLab and GitHub Enterprise Server instances, your team's own GitHub Apps, the audit log, plans and payment methods.

A field your role does not allow returns an AUTHORIZATION_ERROR and does nothing. Service accounts hold the VIEWER role. See Teams and roles.

Errors

Errors come back in the standard GraphQL errors array. Each carries a stable code in extensions.code:

  • AUTHENTICATION_ERROR: no token, an invalid or expired token, or an X-Tenant you do not belong to.
  • AUTHORIZATION_ERROR: your role does not allow this field.
  • NOT_FOUND: the id does not exist in this team.
  • VALIDATION_ERROR: the input broke a rule. extensions.fields lists each field and why, for example TOO_SHORT, INVALID_PATTERN or DUPLICATE_ENTRY.
  • LIMIT_EXCEEDED: you hit a rate limit.
  • NEW_TENANT_INVALID: a transfer named the team the resource is already in.
  • CONSENT_ACTOR_UNKNOWN: the ownership statement for a new network, workspace or web application was sent with a token that does not identify a person. Nothing is created.
  • INTERNAL_ERROR: something failed on Vulnara's side.
  • DATABASE_UNAVAILABLE, DATABASE_BUSY, DATABASE_SCHEMA_PENDING, CACHE_UNAVAILABLE, MESSAGE_BROKER_UNAVAILABLE and UPSTREAM_UNREACHABLE: Vulnara was briefly unable to answer, for example during an update. Nothing was changed. Wait a few seconds and send the request again.

Some errors carry a more specific code, such as REPOSITORY_LIMIT_EXCEEDED when your plan's repository cap stops you, GIT_TOKEN_NOT_VALID, or, for a web scan, NO_SCANNER_FOR_CATEGORY (web application scanning is not enabled for the team), WEB_TARGET_ADDRESS_REFUSED (the address is not publicly reachable) and DAST_SCAN_MINUTES_LIMIT_EXCEEDED, or WEB_TARGET_CREDENTIALS_CONFLICT when a web application's sign-in methods cannot be combined. That one also carries extensions.reason: BASIC_AND_BEARER, AUTHORIZATION_HEADER_TAKEN or TOO_MANY. Handle unknown codes as generic failures. Build on the code, not on the message: messages can be generic and may change.

A query that selects a field the schema does not have fails validation before anything runs. Findings and scans are described by category: use a finding's category, and toolCount for how many scanners agreed. See Scan categories.

Rate limits

Some fields are limited per user. Each limit is a number of calls a minute with a burst you can spend at once, and a call over it returns LIMIT_EXCEEDED and does nothing:

The limits are sized so that working in the web app never reaches them. A script that does should wait and retry.

Subscriptions

Open a WebSocket to wss://vulnara-gw.rso.dev/graphql using the graphql-ws protocol. Pass the same two values as connection parameters: Authorization with your bearer token, and X-Tenant.

  • taskEvents: live progress of scans and imports in the team. Each event has a type (STATE_UPDATED or TASK_CANCELLED), a taskId and the task's current state.
  • notifications: new in-app notifications for the team as they are created. See Notifications.
  • resourceChanges: which of the team's records were just created, updated or deleted, by anyone. Each change has a type (the kind of record, such as Network or Repository), an id and an action (created, updated or deleted). An id of null means several records of that type changed at once. Changes never carry the record's contents: read the record again with the usual query, so your role applies as always. This is how the web app keeps its screens current.
graphql
subscription { taskEvents { type taskId } }
graphql
subscription { resourceChanges { type id action } }

You only receive events for the team you connected with. To follow another team, open another connection.

REST routes

A few things are plain HTTP routes on the same host rather than GraphQL fields, such as browser sign-in and sign-out, PDF reports and the chat. They take the same bearer token. Reports are limited to 20 a minute, and a request over a limit gets HTTP 429. See the REST reference.

Good to know

  • Send JSON: POST requests need Content-Type: application/json. Requests that look like a plain browser form are refused.
  • Batching works: you can send several operations as a JSON array in one request.
  • Git providers: wherever a field takes a gitType, use github, gitlab, bitbucket, azure_devops or forgejo. gitEntityProviders tells you on which of them a name exists, and checkGitToken checks a token against any of them.
  • Ownership statement: createGitEntity, createNetwork and createWebTarget require ownershipConsent: true, your statement that the team owns the target or is authorised to scan it. Without it the call is refused with VALIDATION_ERROR and nothing is created.
  • Secrets are write-only: git token values and webhook header values are never returned after you set them.
  • Some reads are role-dependent: member email addresses are hidden from viewers, except their own.
  • Plan limits apply: creating repositories or networks, enabling repositories and starting scans can be refused when your plan's limit is reached. See Plans, usage and billing.
  • Token lifetime: service account tokens expire. Read expires_in and exchange again before it runs out.