Last updated Dec 13, 2024

Create components using the API

You can create components using the Compass GraphQL API by:

  1. Logging into the GraphQL API explorer
  2. Looking up the unique cloudId for your Atlassian site
  3. Creating the new component using the cloudId

Log in to the GraphQL API explorer

  1. Go to the GraphQL API explorer.
  2. Log in with your Atlassian account if you are prompted to do so.

Look up the unique cloudId for your Atlassian site

  1. In the GraphQL API explorer, enter this code into the query area on the left side:
    1
    2
    query getCloudId($hostName: String!) {
      tenantContexts(hostNames: [$hostName]) {
        cloudId
      }
    }
    
  2. From the bottom left corner of the screen, select Query variables and enter this code, substituting the hostName value with your Atlassian site hostname:
    1
    2
    { "hostName": "your-site-hostname.atlassian.net" }
    
  3. From the top navigation of the GraphQL API explorer, select Execute query
    • The cloudId for your site appears in the results area on the right side.
  4. Copy the value of the cloudId to your clipboard.

Create a new component

Use the createComponent mutation to create the new component.

  1. In the GraphQL API explorer, enter this code into the query area on the left side:
    1
    2
    mutation createComponent($cloudId: ID!, $componentDetails: CreateCompassComponentInput!) {
      compass {
        createComponent(cloudId: $cloudId, input: $componentDetails) {
          success
          componentDetails {
            id
            name
            typeId
          }
        }
      }
    }
    
  2. From the bottom left corner of the screen, select Query variables and enter this code:
    1
    2
    {
      "cloudId": "your-cloudid",
      "componentDetails": {
        "name": "your-component-name",
        "typeId": "your-component-type"
      }
    }
    
  3. Substitute your cloudId and the name of the new component.
  4. Substitute the typeId with your component’s type. The valid values are SERVICE, LIBRARY, APPLICATION, CAPABILITY, CLOUD RESOURCE, DATA PIPELINE, MACHINE LEARNING MODEL, UI ELEMENT, WEBSITE, OTHER.
  5. From the top navigation of the GraphQL API explorer, select Execute query
    • You'll see the id, name and typeId of your newly created component in the results area on the right side.

Components have more attributes other than name and typeId. For a complete list of input parameters to create components using the API, see the createComponent mutation in the Compass GraphQL API reference documentation.

We recommend that you don't exceed 20,000 components in Compass, beyond which you may notice some performance degradation. We are working on scaling the solution to increase the limits over time.

Troubleshooting

If you get an error when attempting to create the component, make sure you’ve provided:

  • the entire cloudId for your Atlassian site and there are no typos
  • values for name and typeId, which are both mandatory
  • a valid option (SERVICE, LIBRARY, APPLICATION, CAPABILITY, CLOUD RESOURCE, DATA PIPELINE, MACHINE LEARNING MODEL, UI ELEMENT, WEBSITE, OTHER) for typeId

Learn more

You can perform numerous other operations using the Compass GraphQL API. To learn more, see the following resources:

Rate this page: