To get all confluence spaces using graphQL

How to get all space using graphQL

You could probably refer to this GraphQL API Find Spaces to find all the spaces available and test it in Graphql sandbox. findSpaces require X-ExperimentalApi: confluence-agg-beta as HTTP header (can add it at the bottom of the sandbox in JSON format) as it is a beta feature.

HTTP Header JSON format:

{"X-ExperimentalApi" : "confluence-agg-beta"}

Sample Queries:

query example_tenant {
  tenantContexts(hostNames:["instance_name.atlassian.net"]) {
    cloudId
  }
}

query example_findAllSpaces {
  confluence {
    findSpaces(cloudId: "cloud-id-from-above-query"){
      edges {
        node {
          id
          name
        }
      }
    }
  }
}

query example_spaces {
  confluence {
    spaces(ids:["space-id-1", "space-id-2"]){
      id
      key
      name
      createdDate
    }
  }
}

What is the url to get cloud id ?

We are trying in postman. What is the URL to get cloud id?

In postman, maybe you could try the following endpoint? Haven’t try it in postman myself before.

  • https://{your-subdomain}.atlassian.net/gateway/api/graphql
  • or https://api.atlassian.com/graphql
1 Like