Developer
News and Updates
Get Support
Sign in
Get Support
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
Sign in
DOCUMENTATION
Cloud
Data Center
Resources
Sign in
UI Kit components
Jira UI Kit components
UI Kit hooks
Forge bridge APIs
Jira bridge APIs
Confluence bridge APIs
Dashboard bridge APIs
Upgrade UI Kit versions
Last updated Nov 10, 2026

requestTeamworkGraph

This section describes a Forge preview feature. Preview features are deemed stable; however, they remain under active development and may be subject to shorter deprecation windows. Preview features are suitable for early adopters in production environments.

We release preview features so partners and developers can study, test, and integrate them prior to General Availability (GA). For more information, see Forge release phases: EAP, Preview, and GA.

You can query the Teamwork Graph API directly from UI Kit and Custom UI frontends using @forge/bridge, without routing requests through a Forge backend function.

The requestTeamworkGraph bridge method enables Forge app frontends to call the Teamwork Graph GraphQL API on behalf of the user who is currently interacting with the app in the browser. Calls always run as the current user; Forge apps can't call the Teamwork Graph API as the app.

Your app must declare the scopes required by the objects queried in its manifest. The current user must also have the Teamwork Graph permissions required by the GraphQL operation being called.

To use the latest bridge API, update @forge/bridge in your app's frontend directory:

1
2
npm install @forge/bridge@latest

If you need to call the Teamwork Graph API from a backend function, use the requestTeamworkGraph() method from the @forge/api package with api.asUser().

Function signature

1
2
3
4
5
6
7
8
9
10
type TeamworkGraphResult = {
  data?: Record<string, unknown> | null;
  errors?: Array<Record<string, unknown>>;
};

const requestTeamworkGraph = (
  query: string,
  variables?: Record<string, unknown>,
): Promise<TeamworkGraphResult>

Arguments

Unlike other Atlassian app APIs, the Teamwork Graph API is a GraphQL API. If you're not familiar with GraphQL, we recommend following the Teamwork Graph API tutorial and using the GraphQL explorer at https://<your-site>.atlassian.net/gateway/api/graphql/twg to learn how to form queries.

  • query: The GraphQL query. See the Teamwork Graph API reference for more information.
  • variables (optional): The GraphQL variables to provide to the query.

Returns

  • TeamworkGraphResult: An object containing the response data from the GraphQL query.
    • data: the GraphQL response payload. The shape of this object mirrors the TWG query; each key corresponds to a queried field, with nested structure reflecting the Cypher-backed graph traversal. May be null if a top-level error prevented execution, or partially populated alongside errors in the case of field-level failures.
    • errors: The errors array returned from the API response.

Example

The following example shows a Jira global page app that retrieves all Confluence pages and Jira work items created by the currently logged-in user.

Manifest example

The following manifest declares the granular scopes required to query the current user, Confluence pages, and Jira work items:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# manifest.yml
modules:
  jira:globalPage:
    - key: jira-global-page
      resource: custom-ui-resource
      title: "My Teamwork Graph App"
resources:
  - key: custom-ui-resource
    path: static/hello-world/build
permissions:
  scopes:
    - 'read:graph:user:atlassian'
    - 'read:graph:page:confluence'
    - 'read:graph:issue:jira'

Frontend example

The following component calls requestTeamworkGraph with the user's account ID to fetch graph data, and render the result:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// src/frontend/index.jsx
import React, { useEffect, useState } from 'react';
import { requestTeamworkGraph, view } from '@forge/bridge';
import { GQL_QUERY, QUERY_KEY } from './getConfluencePagesAndJiraIssues';

function App() {
  const [teamworkGraphData, setTeamworkGraphData] = useState(null);
  const [isTeamworkGraphLoading, setIsTeamworkGraphLoading] = useState(true);
  const [isTeamworkGraphError, setIsTeamworkGraphError] = useState(false);
  const [accountId, setAccountId] = useState(null);

  useEffect(() => {
    view.getContext().then((context) => setAccountId(context.accountId));
  }, []);

  useEffect(() => {
    if (!accountId) return;

    requestTeamworkGraph(GQL_QUERY, {
      queryKey: QUERY_KEY,
      queryParams: { userId: `ari:cloud:identity::user/${accountId}` },
    })
      .then(({ data, errors }) => {
        if (errors?.length > 0) {
          setIsTeamworkGraphError(true);
          for (const error of errors) {
            console.error('Error requesting teamwork graph:', error.message);
          }
        } else {
          setIsTeamworkGraphError(false);
          setTeamworkGraphData(data);
        }
      })
      .catch((error) => {
        setIsTeamworkGraphError(true);
        console.error('Error requesting teamwork graph:', error);
      })
      .finally(() => setIsTeamworkGraphLoading(false));
  }, [accountId]);

  return (
    <div>
      {isTeamworkGraphLoading && (
        <p>Loading Teamwork Graph data...</p>
      )}
      {isTeamworkGraphError && (
        <p>Error requesting Teamwork Graph data. Check the console for details.</p>
      )}
      {teamworkGraphData && !isTeamworkGraphError && (
        <>
          <p>Teamwork Graph data loaded successfully</p>
          <p>{JSON.stringify(teamworkGraphData, null, 2)}</p>
        </>
      )}
    </div>
  );
}

Query example

The following example uses a persisted Cypher query to retrieve Confluence pages and Jira work items created by a user. Register the Cypher query once for your app using the Teamwork Graph query builder or the query registration endpoint, then store the returned query key in your app configuration. Allow the query to propagate before calling it. The raw Cypher text is used only during registration; do not send it from your frontend at runtime.

Cypher query to register

1
2
3
4
MATCH (user:AtlassianUser {ari: $userId})-[:atlassian_user_created_confluence_page|atlassian_user_created_jira_work_item]->(target)
RETURN user, target
LIMIT 25

Declare the userId parameter as a required ARI in the registration request. The following GraphQL query uses the registered query key and passes the user ARI as a runtime parameter:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export const QUERY_KEY = 'YOUR_REGISTERED_QUERY_KEY';

export const GQL_QUERY = `
query Atlassian_GetAllPagesAndIssues($queryKey: String!, $queryParams: CypherRequestParams) {
  customQuery(queryKey: $queryKey, queryParams: $queryParams, first: 25) {
    edges {
      node {
        columns {
          key
          value {
            __typename
            ... on CypherQueryResultNode {
              id
              data {
                __typename
                ... on ConfluencePage {
                  title
                  webUrl
                }
                ... on JiraWorkItem {
                  summary
                }
              }
            }
          }
        }
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
`;

Rate this page: