# API Access

The colormass API is available at <https://gql.colormass.com/graphql>

## Authentication

In the Headers tab, enter the demo API key to authenticate to the backend:

{% code lineNumbers="true" %}

```json
{
 "X-Api-Key": "0ecff5f6-5b65-42bf-84d1-facf9ed37c7avf"
}
```

{% endcode %}

The following query will return download URLs for thumbnails/tileable images:

{% code lineNumbers="true" %}

```graphql
query GetMaterialDownloadLink($articleId: String!, $organizationId: ID!, $assignmentType: DataObjectAssignmentType!, $resolution: DownloadResolution, $fileType: DownloadFileType) {
  materials(filter: {articleId: {equals: $articleId}, organizationId: {equals: $organizationId}}) {
    dataObjectAssignments(filter: {assignmentType: [$assignmentType]}) {
      dataObject {
        downloadUrl(resolution: $resolution, fileType: $fileType)
        mediaType
      }
    }
  }
}
```

{% endcode %}

For PBR maps, use this query:

{% code lineNumbers="true" %}

```graphql
query GetPbrMaterialDownloadLink($articleId: ID!, $organizationId: String!, $resolution: DownloadResolution, $fileType: DownloadFileType) {
  materials(filter: {articleId: {equals: $articleId}, organizationId: {equals: $organizationId}}) {
    jsonFileAssignments(filter: {jsonFileContent: [{resolution: $resolution, fileType: $fileType, state: "done", default: true}]}) {
      jsonFile {
        outputDataObject {
          downloadUrl
        }
      }
    }
  }
}
```

{% endcode %}

Follow [this link](https://gql.colormass.com/graphql?query=query+GetMaterialDownloadLink%28%24articleId%3A+String%21%2C+%24organizationId%3A+String%21%2C+%24assignmentType%3A+DataObjectAssignmentType%21%2C+%24resolution%3A+DownloadResolution%2C+%24fileType%3A+DownloadFileType%29+%7B%0A++++materials%28filter%3A+%7BarticleId%3A+%7Bequals%3A+%24articleId%7D%2C+organizationId%3A+%7Bequals%3A+%24organizationId%7D%7D%29+%7B%0A++++++++dataObjectAssignments%28filter%3A+%7BassignmentType%3A+%5B%24assignmentType%5D%7D%29+%7B%0A++++++++++++dataObject+%7B%0A++++++++++++++++downloadUrl%28resolution%3A+%24resolution%2C+fileType%3A+%24fileType%29%0A++++++++++++++++mediaType%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%0A%7D%0A%0Aquery+GetPbrMaterialDownloadLink%28%24articleId%3A+String%21%2C+%24organizationId%3A+String%21%2C+%24resolution%3A+DownloadResolution%2C+%24fileType%3A+DownloadFileType%29+%7B%0A++++materials%28filter%3A+%7BarticleId%3A+%7Bequals%3A+%24articleId%7D%2C+organizationId%3A+%7Bequals%3A+%24organizationId%7D%7D%29+%7B%0A++++++++jsonFileAssignments%28filter%3A+%7BjsonFileContent%3A+%5B%7Bresolution%3A+%24resolution%2C+fileType%3A+%24fileType%2C+state%3A+%22done%22%2C+default%3A+true%7D%5D%7D%29+%7B%0A++++++++++++jsonFile+%7B%0A++++++++++++++++outputDataObject+%7B%0A++++++++++++++++++++downloadUrl%0A++++++++++++++++%7D%0A++++++++++++%7D%0A++++++++%7D%0A++++%7D%0A%7D) to try the queries on live data. You will need to provide variables in this format:

{% code lineNumbers="true" %}

```json
{
 "organizationId": "<your organization id>",
 "articleId": "<article id>",
 "resolution": "High",
 "fileType": "exr",
 "assignmentType": "MaterialThumbnail_20x20"
}
```

{% endcode %}

The required link is the `downloadUrl` field of the first `dataObject` of the first `dataObjectAsssignment` returned, unless additional filter criteria apply (for example, you might want to filter by `mediaType` to exclude zip files and only offer download links to images).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.colormass.com/dev/data-exporter/api-access.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
