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.
queryListAlerts($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 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:
queryIntrospectionQuery { __schema { queryType { name } mutationType { name } types {...FullType } directives { name description locations args {...InputValue } } } }fragment FullType on__Type { kind name description fields(includeDeprecated: true) { name description args {...InputValue } type {...TypeRef } isDeprecated deprecationReason } inputFields {...InputValue } interfaces {...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes {...TypeRef } }fragment InputValue on__InputValue { name description type { ...TypeRef } defaultValue }fragment TypeRef on__Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } }
How to use the Panther GraphQL API
Step 1: Identify your Panther GraphQL API URL
To locate your GraphQL API URL:
In the upper-right corner of your Panther Console, click the gear icon, then API Tokens.
At the top of the page, see the API URL.
The GraphQL API URL structure differs depending on your Panther deployment model: