> ## Documentation Index
> Fetch the complete documentation index at: https://docs.occtoo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get started with the GraphQL API

> Get a token, list your sources, read source entries, and create a managed tag list.

This page walks you through two queries and one mutation. You need an [Application](https://docs.occtoo.com/concepts/applications.md) with the scopes used below.

## Get a token

Request an [Application access token](https://docs.occtoo.com/api-reference/authentication/application-token.md) with your tenant ID as the audience. For the examples on this page, ask for `read:sources` and `write:cards`.

## Send a request

Send every query and mutation as a `POST` to `https://api.occtoo.com/graphql` with a JSON body. Put the GraphQL document in `query` and any variables in `variables`.

```bash theme={null}
curl https://api.occtoo.com/graphql \
  --header 'Authorization: Bearer <access-token>' \
  --header 'Content-Type: application/json' \
  --data '{"query":"{ dataSources(first: 5) { totalCount nodes { id name } } }"}'
```

You can also paste the documents below into Nitro at [https://api.occtoo.com/graphql](https://api.occtoo.com/graphql).

## List your sources

`dataSources` lists the sources of your tenant, archived ones included. This query keeps only live sources that hold data entries:

```graphql theme={null}
query LiveSources {
  dataSources(
    first: 10
    where: { deletedAt: { eq: null }, type: { eq: GENERIC } }
    order: [{ name: ASC }]
  ) {
    totalCount
    nodes {
      id
      name
      status
      entriesCount
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

```json theme={null}
{
  "data": {
    "dataSources": {
      "totalCount": 1,
      "nodes": [
        {
          "id": "RGF0YVNvdXJjZTpwcm9kdWN0cw==",
          "name": "Products",
          "status": "ACTIVE",
          "entriesCount": 1250
        }
      ],
      "pageInfo": { "hasNextPage": false, "endCursor": "MA==" }
    }
  }
}
```

The `id` is a global id. See [Ids](https://docs.occtoo.com/api-reference/graphql/conventions.md#ids) for how it relates to the raw source id `products`.

## Read source entries

`sourceEntries` reads the entries of one source, with typed property values. It takes the raw source id. This query finds entries whose `brand` is `Acme`, most recently updated first:

```graphql theme={null}
query AcmeProducts($sourceId: String!) {
  sourceEntries(
    sourceId: $sourceId
    first: 20
    where: { text: { property: "brand", eq: "Acme" } }
    sort: [{ property: "@updatedAt", direction: DESC }]
  ) {
    nodes {
      entryId
      updatedAt
      properties(ids: ["name", "brand"]) {
        id
        value {
          ... on TextValue { text }
        }
      }
    }
    pageInfo {
      hasNextPage
      endCursor
    }
  }
}
```

```json theme={null}
{ "sourceId": "products" }
```

`value` is a union. Its member type follows the property's data type, such as `TextValue`, `IntegerValue`, `DecimalValue`, `BooleanValue`, `TimestampValue`, `ListValue`, `LocalizedTextValue` or `LocalizedListValue`. Select a fragment for each type you expect.

## Create a managed tag list

Mutations take one `input` argument and return a payload. The payload holds the result and an `errors` list for expected failures.

```graphql theme={null}
mutation CreateColors {
  createManagedTagsList(input: { displayName: "Colors", type: LOCALIZED_TEXT }) {
    managedTagsList {
      id
      displayName
      type
    }
    errors {
      ... on GraphQlError {
        code
        message
        details { key value }
      }
    }
  }
}
```

If the name is already in use, `managedTagsList` is `null` and `errors` explains why. Always select `errors` in mutations. See [Errors](https://docs.occtoo.com/api-reference/graphql/conventions.md#errors).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.