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

# POST /api/issuer/:did/schemas

> Create a credential schema for an issuer

```http theme={null}
POST /api/issuer/did:alyra:issuer.../schemas HTTP/1.1
Authorization: Bearer <jwt>
Content-Type: application/json

{
  "name": "National ID",
  "description": "Government-issued identity credential",
  "version": "1.0",
  "attributes": [
    {
      "name": "full_name",
      "data_type": "string",
      "description": "Full legal name",
      "required": true
    },
    {
      "name": "date_of_birth",
      "data_type": "date",
      "description": "Date of birth",
      "required": true
    }
  ],
  "extensions_allowed": false,
  "allowed_extensions": [],
  "evidence_allowed": true,
  "allowed_evidence": ["photo_id"]
}
```

## Body

| Field                | Type      | Required | Description                                       |
| -------------------- | --------- | -------- | ------------------------------------------------- |
| `name`               | string    | Yes      | Schema name.                                      |
| `description`        | string    | No       | Human-readable description.                       |
| `version`            | string    | Yes      | Schema version.                                   |
| `attributes`         | array     | Yes      | List of schema attributes.                        |
| `extensions_allowed` | boolean   | No       | Allows extension fields when issuing credentials. |
| `allowed_extensions` | string\[] | No       | Accepted extension names.                         |
| `evidence_allowed`   | boolean   | No       | Allows evidence attachments.                      |
| `allowed_evidence`   | string\[] | No       | Accepted evidence labels.                         |

## Schema Attribute

| Field         | Type    | Required | Description                                                                          |
| ------------- | ------- | -------- | ------------------------------------------------------------------------------------ |
| `name`        | string  | Yes      | Attribute key.                                                                       |
| `data_type`   | enum    | Yes      | `string`, `number`, `boolean`, `date`, `email`, `url`, `file`, `object`, or `array`. |
| `description` | string  | Yes      | Attribute description.                                                               |
| `required`    | boolean | Yes      | Whether the holder must provide this value.                                          |

## Response

`201 Created`

```json theme={null}
{
  "success": true,
  "message": "Schema created successfully",
  "schema": {
    "id": "schema-uuid",
    "issuer_did": "did:alyra:issuer...",
    "name": "National ID",
    "version": "1.0",
    "attributes": [],
    "ipfs_hash": "Qm...",
    "on_chain": true,
    "blockchain_tx": "0x...",
    "created_at": "2026-06-27T00:00:00Z"
  }
}
```
