Gateway overview

Gateway provides a single and stable API integration point for various Tanium solutions. It is designed for Tanium partners and customers interested in building integrated solutions with the Tanium Core Platform.

Note: To view examples of filtering syntax, see Reference: Filter syntax. To view examples of available functions, see Reference: Gateway examples. To download a file containing examples, see Reference: Integration with Insomnia API Client.

Gateway topology

The Gateway service runs in your Tanium™ Cloud instance. The Gateway service passes user requests to Tanium™ Data Service (TDS) or the Tanium Core Platform; the Tanium Core Platform collects data from Tanium™ Clients or updates data based on the request, and returns the results to the Gateway service. The Gateway service passes the results to the user that submitted the request.

Figure 1. Gateway topology
Gateway topology diagram, with information flow from user sending a request to and receiving a request from Tanium

With Gateway, information passes between users and the Tanium Core Platform through the following workflow (matching the numbers in Gateway topology):

  1. Users send requests to the Gateway to be performed on endpoints, such as action deployment and queries for question results.

  2. By default, the Gateway relays user queries to TDS, which continuously collects results for all registered sensors through the Tanium Core Platform. Continuous collection from endpoints ensures that results are available in the TDS cache for both online and offline endpoints.

  3. Users can optionally specify queries that go directly from the Gateway to the Tanium Core Platform for collecting live results from endpoints that are currently online.

  4. Users can specify requests that go from the Gateway to Tanium solutions to be performed on endpoints. For example, a user might request Tanium™ Direct Connect to establish a direct connection to a specific endpoint.

  5. The Tanium Core Platform issues questions and deploys actions (and associated content such as packages) to Tanium™ Clients.

  6. Tanium Clients return the question results or action statuses to the Tanium Core Platform. The server responds to the request with the results and statuses. If the user sent the request through the Gateway query explorer, the results pane displays the response.

Query explorer

Gateway includes an interactive query explorer that you can use to write and run queries and mutations in Tanium™ Console. Use the query explorer to try new queries and discover what data is available.

You can find the query explorer on the Gateway Overview page:

Figure 2. Query explorer
Query explorer
Tip: If the query explorer does not appear on the Gateway Overview page, click Customize Page and make sure the Query Explorer option is selected.

Query variables

If a query or mutation uses variables, expand the Variables pane and include the variables in the pane that expands.

Figure 3. Variables pane
Variables pane

For the best results, use query variables when passing arguments, such as when you use pagination or filtering in your request. For more information, see Pagination and Filters.

Schema reference

Gateway contains a schema reference that documents all queries, mutations, and objects that are available in Gateway. The schema reference is generated directly from the schema; refer to the schema reference in Gateway for the most up-to-date documentation. The schema reference does not include fields and types that depend on a Tanium solution that is not installed. For example, the compliance field of the endpoints query does not appear unless Tanium Comply is installed. The schema reference updates automatically when you install or uninstall a solution. After you uninstall a solution, the dependent fields and types are removed within one minute.

To view the schema reference in the query explorer, click Docs to expand the Documentation Explorer pane of the query explorer.

Figure 4. Documentation Explorer pane
Documentation Explorer pane
Note: The query explorer uses the GraphiQL interactive browser to send GraphQL queries and mutations to Tanium™ Cloud. For more information about the options that are available in GraphiQL, see https://graphql.org/learn/.

Authentication

Requests that are sent from the query explorer in Tanium Console are authenticated and authorized with the session ID of the user who is signed in. Tanium Cloud uses the role-based access control (RBAC) permissions of the user account to determine which content you can query and mutate.

Requests that are sent from outside Tanium Console are authenticated and authorized with API tokens. You must include an API token in the authorization header of all requests that are sent to Gateway. Gateway uses the RBAC permissions of the requesting user to determine content access for all queries and mutations. To view an example cURL query that shows the authorization header, see Example cURL syntax.

Important:

Use API tokens to send requests through Gateway. You can create API tokens in Tanium Console, through the Tanium Core Platform REST API, or through Gateway.

To view best practices regarding API tokens, see Enabling long-lived Tanium sessions through API tokens. For more information about how to create tokens through Gateway, see API token examples.

Important: When requests are sent outside Tanium Console, make sure to use the correct URL to send requests. To view examples, see Root endpoint and Example cURL syntax.

If your environment uses multiple customer organizations, requests can be scoped to a specific organization with the Tanium-Organization-Id header. For details on how Gateway uses this header, see Multi-tenant organizations.

Rate limits

Gateway has no specific rate limits.

Root endpoint

To send queries and mutations outside Tanium Console, use the following address:

https://<customerName>-api.cloud.tanium.com/plugin/products/gateway/graphql

Example cURL syntax

JSON
curl --request POST \
   --url https://acme-api.cloud.tanium.com/plugin/products/gateway/graphql \
   --header 'Content-Type: application/json' \
   --header 'session: token-356d5f5bbb3671f28e24f65be3bdd54d9d81001ca823efaabc5fbff251' \
   --data '{"query":"{\n  now\n}\n"}'

Pagination

Queries that return many results are paginated to reduce resource utilization. Gateway uses the standard Relay GraphQL pagination specification to provide users the option to explicitly control pagination.

Paginated queries return a connection type that is prefixed with the name of the data type, such as EndpointConnection. Queries accept standard arguments to control the pagination. For more information about pagination syntax, see Reference: Paginated query syntax.

Example of a paginated query:

CODE
query paginationExample {
  endpoints {
    edges {
      node {
        id
        serialNumber
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

Cursors

Use cursors to control relay pagination. Cursors are opaque strings that point to records within queried collections, and can be used to request the records after the cursor. All collections support forward traversal, and some also support backward traversal.

Cursors are valid only for the query for which they were returned. Cursors are generally valid for five minutes after their most recent use. Any queries that deviate from this policy are documented in the query field. It is a best practice to use query variables with cursors to quickly update the pagination in your request.

Connection results are stable and consistent when traversed with cursors unless documented in the query field.

Example of an endpoint query with cursors:

JSON
query useCursorsForEndpoints ($cursor: Cursor, $results: Int) {
  endpoints(after: $cursor, first: $results) {
    edges {
      node {
        name
        ipAddress
      }
    }
    pageInfo {
      startCursor
      endCursor
      hasPreviousPage
      hasNextPage
    }
  }
}

Include the pagination cursor and results variables in the Variables panel:

JSON
{
  "cursor": "NTc2NTM4MDow",
  "results": 5
}

Connection and edges

The connection includes an edge field that returns a list of typed edges, such as EndpointEdge. Each edge contains at least two fields:

  • A node field with the actual data type, such as Endpoint

  • A cursor field with a cursor for the record

The connection type also includes a pageInfo field that contains at least two fields:

  • hasNextPage indicates if there are more records

  • endCursor is the cursor of the last record in the returned page, if any

Some connection types feature other metadata, such as totalRecords.

Arguments

Paginated queries support at least two arguments: first indicates the number of records to return, and after is the value of the record cursor that precedes the records in the requested page. When fully paginated, this value is the same as the endCursor value from the previous page. Both arguments have sensible defaults.

Paginated queries that support backward traversal allow two corresponding arguments: last and before. You must pass both arguments together to traverse backwards in a query.

Note: A single query supports either forward or backward traversal, but not both. Tanium Cloud returns an error response for queries with arguments for both forward and backward traversals.

When a paginated request extends beyond the collection, the query returns only the available results.

For the best results, use query variables with the pagination arguments to quickly update the response results.

Example of a request for a page of data within a collection:

JSON
query getTenEndpointsAfterCursor ($cursor: Cursor, $results: Int) {
  endpoints(after: $cursor, first: $results) {
    edges {
      node {
        id
        serialNumber
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}

Include the pagination cursor and results variables in the Variables panel:

JSON
{
  "cursor": "NTc2NTM4MDow",
  "results": 10
}

Refreshing collections

The records returned and paginated over in a query are intended to be stable, ensuring callers are able to traverse the entire collection without gaps or duplicates. With certain collections, particularly the results of querying endpoints with the Tanium Server data source, new records might become available after the first stable paginated collection has been returned by Gateway. There are two primary scenarios for needing these late-arriving data:

  • When fetching live data for a specific endpoint or small set of endpoints

  • When fetching live data about as many endpoints as practical

When you want to obtain the latest data available for a paginated query, you can request a repopulation of the collection with the refresh argument, which takes a cursor as its value. If the gateway can obtain potentially new data for the collection, it obtains the data and returns a new pagination starting at the beginning of the collection. The old cursor values are no longer valid.

Since a common scenario for this capability is when no records were initially available, queries that support the refresh argument provide a collectionInfo field on their connection type. This field includes a startCursor field, which is always defined as pointing to the beginning of the entire collection. The collectionInfo might include other fields which help the user decide if they would like to refresh the cursor or read the results.

You can always perform a new query with no cursor instead of using the refresh argument, but this does not take advantage of the ongoing effort to collect records from the previous query. Using the refresh argument is the most efficient and effective way to obtain as complete a collection as possible or required.

Example of an endpoint query against an endpoint that is slow to respond, with collectionInfo.startCursor included in the response:

JSON
query getSlowEndpoint($first: Int, $path: String, $value: String, $expectedCount: Int) {
  endpoints(
    first: $first
    filter: {path: $path, value: $value}
    source: {ts: {expectedCount: $expectedCount}}
  ) {
    edges {
      node {
        id
      }
    }
    collectionInfo {
      startCursor
      success
      active
    }
  }
}

Add the pagination and filter variables in the Variables panel:

JSON
{
  "first": 1,
  "path": "name",
  "value": "slow-endpoint",
  "expectedCount": 1
}

Example response for an ongoing collection with a startCursor value:

JSON
{
  "data": {
    "endpoints": {
      "edges": [],
      "collectionInfo": {
        "startCursor": "4t2cB0ZGNPqy4J4P7O7opwz/24/5zgPi6OinDAA=:0",
        "success": false,
        "active": true
      }
    }
  }
}

Example request refreshing the collection using the returned startCursor value:

JSON
query getEndpointRefresh($refresh: Cursor, $first: Int, $path: String, $value: String, $expectedCount: Int) {
  endpoints(
    refresh: $refresh
    first: $first
    filter: {path: $path, value: $value}
    source: {ts: {expectedCount: $expectedCount}}
  ) {
    edges {
      node {
        id
      }
    }
    collectionInfo {
      startCursor
      success
      active
    }
  }
}

Add the pagination and filter variables in the Variables panel:

JSON
{
  "refresh": "4t2cB0ZGNPqy4J4P7O7opwz/24/5zgPi6OinDAA=:0",
  "first": 1,
  "path": "name",
  "value": "slow-endpoint",
  "expectedCount": 1
}

Example response with a completed collection:

JSON
{
  "data": {
    "endpoints": {
      "edges": [
        {
          "node": {
            "id": 1
          }     
      ],
      "collectionInfo": {
        "startCursor": "4t2cB0ZGNPqy4J4P7O7opwz/24/5zgPi6OinDAA=:0",
        "success": true,
        "active": true
      }
    }
  }
}

Filters

Most queries that return multiple results provide support to filter the results. Such queries provide a filter argument.

It is a best practice to use query variables with filter arguments to quickly update the filter.

For more information about specific filter syntax, see Reference: Filter syntax.

Simple filters

Simple filters are single filters that constrain the values of fields that participate in the query. You can specify simple filters in the path property with a period to separate levels in the graph starting at the record type. For example:

JSON
query getEndpointsByEmail ($path:String, $value:String){
  endpoints(filter: {path: $path, value: $value}) {
    edges {
      node {
        id
        primaryUser {
          email
        }
      }
    }
  }
}

Include the path and value variables in the Variables panel:

JSON
{
  "path": "primaryUser.email",
  "value": "user@example.com"
}

The query does not need to return the filtered path. Not all field paths are filterable. Refer to the schema to see which paths cannot be filtered.

Simple filters must also contain a string value property.

You can specify an operator in the op property, which is an enumerated type and defaults to the equality operator. For example:

JSON
query getGTE4ProcessorEndpoints($path: String, $value: String, $fieldfilterop: FieldFilterOp!) {
  endpoints(filter: {path: $path, value: $value, op: $fieldfilterop}) {
    edges {
      node {
        id
      }
    }
  }
}

Include the path, value, and operator variables in the Variables panel:

JSON
{
  "path": "processor.logicalProcessors",
  "value": "4",
  "fieldfilterop": "GTE"
}
Note: Not all operators are valid for all fields.

Compound filters

Compound filters contain multiple simple or compound filters that appear in the filters property. By default, all child filters must pass for a record to be included. If the or argument is given with a true value, then a record is included if any child filter matches.

Example of a simple compound filter:

JSON
query getEndpointsTwoFilters($path1: String, $path2: String, $value1: String, $value2: String) {
  endpoints(
    filter: {filters: [{path: $path1, value: $value1}, {path: $path2, value: $value2}]}
  ) {
    edges {
      node {
        id
      }
    }
  }
}

Include the path and value variables in the Variables panel:

JSON
{
  "path1": "serialNumber",
  "value1": "x",
  "path2": "name",
  "value2": "y"
}

Negated filters

You can negate both simple and compound filters with a negated property of true. For example, the following query returns endpoints whose serial number does not contain the letter x:

JSON
query getEndpointsNegate($path: String, $value: String, $negated: Boolean!) {
  endpoints(
    filter: {filters: {path: $path, value: $value, negated: $negated}}
  ) {
    edges {
      node {
        id
      }
    }
  }
}

Include the path, value, and negated variables in the Variables panel:

JSON
{
  "path": "serialNumber",
  "value": "x",
  "negated" : true
}

Field filters

Filters apply to the entire record. Some records contain fields that are collections; you can also filter these fields. When you filter a field, the filter applies to both the child collection and to the records. For example, if you search for endpoints with an installed application named Tanium Client with a filter on the field, Gateway returns only those endpoints with such an application, as well as only the matching application:

JSON
query getEndpointsWithTC ($path: String, $value: String){
  endpoints {
    edges {
      node {
        installedApplications(filter: {path: $path, value: $value}) {
          name
          version
        }
      }
    }
  }
}

Include the path, value, and negated variables in the Variables panel:

JSON
{
  "path": "name",
  "value": "Tanium Client"
}

Field filters can be simple or compound. Compound filters are limited to one level of children that must use the equality operator, and require all child filters. For example:

JSON
query getEndpointsMultipleFilters ($path1: String, $value1: String, $path2: String, $value2: String){
  endpoints {
    edges {
      node {
        installedApplications(
          filter: {
            filters: [
              {path: $path1, value: $value1},
              {path: $path2, value: $value2}
            ]
          }
        ) {
          name
          version
        }
      }
    }
  }
}

Include the path and value variables in the Variables panel:

JSON
{
  "path1": "name",
  "value1": "Tanium Client",
  "path2": "version",
  "value2": "7.5.0.0"
}

Multi-tenant organizations

If your environment uses multiple customer organizations, Gateway can surface and filter by the organization that owns each endpoint.

Gateway supports Tanium deployments that use multiple customer organizations, in multi-tenant or managed service provider (MSP) deployments. An MSP operator can attribute endpoint data to the customer organization that owns the endpoint, discover which organizations they are authorized to query, and target specific organizations when they create platform content.

Endpoint rows returned by the endpoints query carry their owning customer organization in the organization field, so a query that spans multiple organizations can tell which organization each row belongs to without a separate lookup. You can also filter endpoints to a subset of organizations by filtering on organization.id. For an example, see Get endpoints with their owning organization.

To discover which customer organizations you are authorized to query, use the taniumPlatformOrganizations query. A session scoped to the Global organization can see every organization. A session scoped to a single organization sees only that organization. The id values this query returns are the same values the endpoints query accepts when filtering on organization.id. For an example, see List the organizations you are authorized to query.

To act on behalf of a specific organization when sending a request from outside Tanium Console, set the Tanium-Organization-Id header on the request. For the general header contract, see Specify an organization in API requests.

When you send the Tanium-Organization-Id header on a mutation that creates platform content, such as an action, a saved action, or a question, Gateway creates that content in the named organization. If you omit the header, Gateway creates the content in the organization for your session. A session in the Global organization can target any organization. A session scoped to a single organization can target only that same organization.

The Tanium-Organization-Id header also scopes the endpoints query when you use the ts (live) data source, because that source issues a question and the header determines which endpoints receive the question. The header has no effect on the tds data source. This source reads stored results instead of issuing a new question, so a Global session querying through tds remains unscoped regardless of the header. To narrow tds results by organization, filter on organization.id instead.

If a create mutation references another platform object, such as a package or a computer group, owned by an organization other than the one in which you are creating content, the request is refused. The error reads the same as a reference to an object that does not exist, so that the existence of objects in other organizations is not disclosed.

For user fields such as username and displayName, a session in the Global organization can see the values for every user. A session scoped to a single organization can see the values for users in the Global organization, users in that organization, and the user who sent the request. For any other user, these fields return null. The response is the same as for a user that does not exist.

Interoperability with other Tanium products

Gateway works with the following solutions:

  • Tanium Core Platform

    • Actions

    • Action groups

    • Computer groups

    • Tanium Data Service (TDS)

    • Tanium Direct Connect

    • Packages

    • Tanium™ Reporting

  • Tanium™ Asset

  • Tanium™ Automate

  • Tanium™ Blob Service

  • Tanium™ Comply

  • Tanium™ Connect

  • Tanium™ Deploy

  • Tanium™ Discover

  • Tanium™ Email

  • Tanium™ Impact

  • Tanium™ Integrity Monitor

  • Tanium™ Patch

  • Tanium™ Performance

  • Tanium™ Provision

  • Tanium™ Reveal

  • Tanium™ Benchmark

  • Tanium™ Threat Response