> For the complete documentation index, see [llms.txt](https://docs.sudoplatform.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sudoplatform.com/guides/decentralized-identity/cloud-agent/cloud-agent-admin-api/credentials/anoncreds-credentials/schemas.md).

# Schemas

An Anoncreds schema, represented by `AnoncredsSchema`, defines a set of attributes which form what is essentially a credential template.

Anoncreds schemas are written to the ledger, and therefore cannot be modified or deleted once created. The schema `version` is intended as a mechanism to write an updated version of a schema to the ledger, however this has no effect on versions already written to the ledger, nor on credentials which are already issued using the schema.

## Create an Anoncreds schema

The cloud agent creates a new `AnoncredsSchema` and writes it permanently to the ledger. The `attributeNames` param determines the set of attributes which must appear on credentials issued using this schema.

```graphql
mutation MyMutation {
  createAnoncredsSchema(
    args: {
      name: "MySchema"
      version: "1.0"
      attributeNames: ["Firstname", "Lastname", "DOB"]
    }
  ) {
    id
  }
}
```

## View Anoncreds schemas

View Anoncreds schemas which are created by the cloud agent, with pagination and filtering options. Returns a `nextToken` which can be passed into the same query in order to fetch subsequent pages.

```graphql
query MyQuery {
  anoncredsSchemas(
    page: {
      nextToken: null
    }
    filter: {}
  ) {
    items {
      id
      name
      version
      attributeNames
    }
    nextToken
  }
}
```

Alternatively, view a single Anoncreds schema, referenced by its unique ID.

```graphql
query MyQuery {
  anoncredsSchema(
    schemaId: "Hoh1tsuYFJxqsuJ5vVjxuL:2:MySchema:1.0"
  ) {
    id
    name
    version
    attributeNames
  }
}
```
