> 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
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.sudoplatform.com/guides/decentralized-identity/cloud-agent/cloud-agent-admin-api/credentials/anoncreds-credentials/schemas.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.
