Skip to Content
GraphQL API

Create Tickets with the Mondoo API

Find a space's ticketing integrations, create a ticket for one or more findings, and list tickets with the Mondoo GraphQL API.

Mondoo creates tickets in the ticketing systems you connect to a space, such as Jira, ServiceNow, or GitHub Issues. In the API, a ticket is a case: Mondoo tracks the findings in the case and creates the matching ticket in your ticketing system. To connect a ticketing system, read Track and Fix Findings.

Each recipe is a complete curl command. To run them, set MONDOO_API_TOKEN and install jq as described in Make your first request. If your organization is in the EU region, replace us.api.mondoo.com with eu.api.mondoo.com.

Find the ticketing integrations in a space

Use this query to get the MRN of the ticketing integration you want to create tickets in.

QUERY='
query TicketingIntegrations($input: TicketingIntegrationsInput!) {
  ticketingIntegrations(input: $input) {
    integrations {
      mrn
      name
      type
    }
  }
}'
VARIABLES='{"input": {"spaceMrn": "//captain.api.mondoo.app/spaces/YOUR_SPACE_ID"}}'

curl -s https://us.api.mondoo.com/query \
  -H "Authorization: Bearer $MONDOO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg query "$QUERY" --argjson variables "$VARIABLES" '{query: $query, variables: $variables}')" | jq
  • Scope: a space MRN.
  • Access: any role that can view the space, such as Viewer.

type tells you which ticketing system each integration connects to, such as TICKET_SYSTEM_JIRA. You need it to fill in ticketConfig in the next recipe.

Create a ticket

Use this mutation to open a ticket for one or more findings, for example every critical vulnerability that a nightly job finds. This example creates a Jira ticket for one CVE across a space. Get the integration MRN from the previous recipe and the finding MRN from the vulnerabilities list.

QUERY='
mutation CreateTicket($input: CreateCaseInput!) {
  createCase(input: $input) {
    mrn
    title
    status
  }
}'
VARIABLES='{
  "input": {
    "title": "Fix CVE-2024-3094 in production",
    "notes": "Upgrade xz-utils on every affected host.",
    "integrationMrn": "YOUR_INTEGRATION_MRN",
    "references": [
      {
        "findingMrn": "//vadvisor.api.mondoo.app/cves/CVE-2024-3094",
        "scopeMrn": "//captain.api.mondoo.app/spaces/YOUR_SPACE_ID"
      }
    ],
    "ticketConfig": {
      "jira": { "projectKey": "SEC", "issueType": "Task" }
    },
    "isV2": true
  }
}'

curl -s https://us.api.mondoo.com/query \
  -H "Authorization: Bearer $MONDOO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg query "$QUERY" --argjson variables "$VARIABLES" '{query: $query, variables: $variables}')" | jq
  • Scope: each reference has its own scopeMrn: a space MRN to cover every affected asset in the space, or an asset MRN to cover one asset.
  • Access: the Editor or Owner role, or another role with the Ticket Creator or Ticket Manager permission. To see every role, read Roles and permissions.

Set these fields in input:

  • references lists the findings the ticket covers. Each findingMrn is the MRN of a CVE, advisory, check, or compliance control.

  • isV2: true lets one ticket cover more than one finding. Without it, a request that references several findings fails. The Mondoo App always sets it.

  • ticketConfig holds the settings for the integration's ticketing system. Set only the key that matches the integration's type:

    Integration typeticketConfig value
    TICKET_SYSTEM_JIRA{"jira": {"projectKey": "KEY", "issueType": "Task"}}
    TICKET_SYSTEM_SERVICE_NOW{"serviceNow": {"impact": 2, "urgency": 2, "priority": 3}}
    TICKET_SYSTEM_GITHUB{"github": {"owner": "OWNER", "repo": "REPO"}}
    TICKET_SYSTEM_GITLAB{"gitlab": {"project": "PROJECT"}}
    TICKET_SYSTEM_AZURE_DEVOPS{"azureDevops": {"projectName": "PROJECT"}}
    TICKET_SYSTEM_ZENDESK{"zendesk": {"priority": "normal", "type": "incident"}}
    TICKET_SYSTEM_EMAIL{"email": {"emailAddress": "security@example.com"}}
    TICKET_SYSTEM_WEBHOOK{}

Mondoo creates the ticket in your ticketing system in the background, so the response doesn't include a ticket link yet. To get it, list the tickets a moment later.

List the tickets in a space

Use this query to read the tickets in a space with their status and the link to each ticket in your ticketing system.

QUERY='
query ListTickets($input: CasesInput!, $after: String) {
  cases(input: $input, first: 50, after: $after) {
    totalCount
    edges {
      node {
        mrn
        title
        status
        createdAt
        assetsCount
        ticketRefs {
          ticketId
          url
        }
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}'
VARIABLES='{
  "input": {
    "scopeMrn": "//captain.api.mondoo.app/spaces/YOUR_SPACE_ID",
    "types": ["TICKET"],
    "statuses": ["OPEN"]
  }
}'

curl -s https://us.api.mondoo.com/query \
  -H "Authorization: Bearer $MONDOO_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "$(jq -n --arg query "$QUERY" --argjson variables "$VARIABLES" '{query: $query, variables: $variables}')" | jq
  • Scope: a space MRN.
  • Access: any role that can view the space, such as Viewer.
  • Pagination: while hasNextPage is true, add "after": "END_CURSOR" to the variables, using the previous page's endCursor.

statuses accepts PENDING, OPEN, CLOSED, and ERROR. Leave it out to list tickets in every status. To manage tickets in the Mondoo App, read Manage tickets.

Next steps

Last updated on

On this page