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

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# Create Schema

> Creates a new schema that defines the structure for attestations

Creates a new schema that defines the structure and validation rules for
attestations. This instruction allows credential authorities to create schemas
that specify what fields an attestation should contain and how they should be
formatted.

## Parameters

| Parameter       | Type                | Description                                                                 |
| --------------- | ------------------- | --------------------------------------------------------------------------- |
| `payer`         | `TransactionSigner` | The account that will pay for the transaction                               |
| `authority`     | `TransactionSigner` | The authority of the credential                                             |
| `credential`    | `Address`           | The credential account this schema will be associated with                  |
| `schema`        | `Address`           | The schema account to create                                                |
| `systemProgram` | `Address`           | The System Program account (defaults to '11111111111111111111111111111111') |
| `name`          | `string`            | The name of the schema                                                      |
| `description`   | `string`            | A detailed description of the schema's purpose                              |
| `layout`        | `Uint8Array`        | The binary layout definition of the schema                                  |
| `fieldNames`    | `string[]`          | The names of fields in the schema                                           |

## Returns

Returns an `Instruction` (`{ accounts, data, programAddress }`). Add it to a
transaction and send it with your client, for example
`client.sendTransaction(instruction)`. There is no `sendAndConfirm()` method.
[Create a Client](/developers/docs/tools/attestations/quickstart/installation#create-a-client) sets up `client`, `payerSigner`, and `authoritySigner`.

## Example

```typescript
import { deriveSchemaPda, getCreateSchemaInstruction } from "sas-lib";

// The schema account is a PDA derived from the credential, name and version
const [schemaPda] = await deriveSchemaPda({
  credential: credentialAddress,
  name: "Identity Verification",
  version: 1
});

const instruction = getCreateSchemaInstruction({
  payer: payerSigner,
  authority: authoritySigner,
  credential: credentialAddress,
  schema: schemaPda,
  name: "Identity Verification",
  description: "Schema for verifying user identity information",
  layout: schemaLayoutBytes,
  fieldNames: ["fullName", "dateOfBirth", "nationality"]
});

// Send the instruction with your Kit client
await client.sendTransaction(instruction);
```

## Important Notes

- The payer must be a signer of the transaction
- The authority must be a signer of the transaction and must be the authority of
  the credential
- The schema account must be writable
- The credential account must be readable
- This operation requires the System Program for rent exemption calculations
- The schema name should be descriptive and unique within the credential
- The description should provide clear information about the schema's purpose
  and usage
- The layout must be a valid binary format that defines the structure of
  attestation data
- The fieldNames array must match the fields defined in the layout
- The schema can be paused later if needed
- The schema can be versioned to support evolution of the data structure
- All attestations created under this schema must conform to its structure
