For the complete documentation index, see llms.txt. This page is also available as Markdown.

GraphQL API

Use the Panther GraphQL API to interact with your Panther entities

Overview

Panther offers a public GraphQL-over-HTTP API, meaning you can write GraphQL queries and invoke the API using a typical HTTP request. For more information on GraphQL, see GraphQL's documentation.

Currently, you can interact with the following entities through the GraphQL API:

Additional operations are available in the REST API.

Understanding a GraphQL query

Click to expand GraphQL query example

The example query below is named ListAlerts. This query will return a list of alerts including every alert's id, title, severity and status based on the time range provided.

  • The input variable of type AlertsInput is used to filter the alerts based on certain conditions, such as createdAtAfter and createdAtBefore. Those conditions will provide a time range for the query.

  • The alerts field returns an object with edges and pageInfo. Each edge has a node field that contains the actual alert data, such as id, title, severity and status.

  • The pageInfo field contains information on pagination, such as hasNextPage and endCursor, which allows the user to loop through all the pages of alerts once hasNextPage becomes false.

query ListAlerts($input: AlertsInput!) {
    alerts(input: $input) {
      edges {
        node {
          id
          title
          severity
          status
        }
      }
      pageInfo {
        hasNextPage
        endCursor
      }
    }
  }

Discover the Panther GraphQL schema

There are three ways to discover the GraphQL schema:

  • Option 1 (quickest): Download the publicly available GraphQL schema file

  • Option 2 (most user-friendly): Use Panther's API Playground

  • Option 3 (best for tools and services): Perform an introspection query against the GraphQL endpoint

Option 1: Download the publicly available GraphQL schema file

You can download the latest version of the GraphQL schema file here.

Option 2: Use the GraphQL Playground

Panther's API Playground is a user-friendly way of browsing and discovering what's supported in our API. Please refer to our API Playground docs for information on how to use this as a discoverability mechanism.

Option 3: Performing an introspection query

An introspection query yields all the GraphQL API's entities in a format that most third-party libraries can parse. This discoverability option is useful if you want to make another library or service aware of the supported operations and types that the Panther API has. These libraries typically issue their own version of an introspection query, so they only need to be pointed to an API URL.

For security purposes, the introspection query is an authorized operation. This means that you'll need to add an X-API-Key header to your HTTP call with the value of an API Token in order for the introspection to work.

The actual shape of the introspection query is customizable. You can ask for a limited set of entities or for all possible information about the schema. For example, a query such as the following would yield every single piece of schema information:

How to use the Panther GraphQL API

Step 1: Identify your Panther GraphQL API URL

To locate your GraphQL API URL:

  • At the bottom of the left-hand navigation bar in your Panther Console, click Settings, then navigate to Developer Tools > API Tokens.

    • At the top of the page, see the API URL.

    • The GraphQL API URL structure differs depending on your Panther deployment model:

      • SaaS deployments: https://api.{YOUR_PANTHER_DOMAIN}.runpanther.net/public/graphql

      • Cloud Connected and self-hosted deployments: https://{YOUR_PANTHER_DOMAIN}/v1/public/graphql

Step 2: Generate an API token

Step 3: Invoke the Panther GraphQL API

In addition to testing with the API Playground, there are two ways to invoke a GraphQL-over-HTTP API:

  • Option 1 (recommended): Install and use a GraphQL Client to abstract the transport-related complexities

  • Option 2: Manually construct an HTTP call

Option 1: Installing and Using GraphQL Clients (Recommended)

While all GraphQL operations are essentially simple HTTP calls, the advantage of using a GraphQL client is that it is more user-friendly.

We recommend using:

Below are some examples of how you would construct a GraphQL query to fetch the first page of alerts in your system:

Option 2: Manually Constructing HTTP Calls

An example request:

The query above returns the first page of all of your Panther alerts. If it's the first time you're using GraphQL, please note the following:

  • There's only one endpoint.

  • The HTTP operation is always a POST.

  • The API operations are defined in POST's body.

  • The body of the POST operation always contains the following keys:

    • query - a GraphQL string defining the GraphQL operation that should be executed

    • variables - an optional set of variables that will be passed along to the query

    • operationName - an optional "nickname" for this operation

  • You must always select a set of fields to return (if the operation returns data.)

Note: The only thing that would change from one GraphQL operation to another is the body of the HTTP POST.

Last updated

Was this helpful?