# Schema Management

Credential schemas define the structure and required fields for credentials, ensuring consistency and interoperability.

**Endpoints**:

* **Create Schema**:

  ```bash
  POST /api/v1/schemas
  x-client-secret: [Client Secret]
  Content-Type: application/json
  ```
* **Get All Schemas**:

  ```bash
  GET /api/v1/schemas
  ```
* **Get Schema by ID**:

  ```bash
  GET /api/v1/schemas/{id}
  ```
* **Delete Schema**:

  ```bash
  DELETE /api/v1/schemas/{id}
  x-client-secret: [Client Secret]
  ```

**Create Schema Example Request**:

```json
{
  "name": "ProofOfPurchase",
  "type": "ProofOfPurchase",
  "credentialSubject": {
    "type": "object",
    "properties": {
      "ticket": {"type": "string", "title": "Ticket"},
      "seat": {"type": "string", "title": "Seat"},
      "description": {"type": "string", "title": "Description"}
    },
    "required": ["ticket", "seat", "description"]
  }
}
```

**Example Response**:

```json
{
  "id": "db5a33ae-2eef-41b4-9c74-2ed16c4bb4f4",
  "name": "ProofOfPurchase",
  "type": "ProofOfPurchase",
  "version": 3,
  "schemaUri": "http://example.com/api/v1/schema/db5a33ae-2eef-41b4-9c74-2ed16c4bb4f4",
  "schemaBody": {}
}
```

**Get All Schemas Example Response**:

```json
[
  {
    "id": "a69ad6ec-8621-472d-90ff-5d15c24d0f2c",
    "name": "ProofOfPurchase",
    "type": "ProofOfPurchase",
    "version": 1,
    "schemaUri": "http://example.com/api/v1/schema/a69ad6ec-8621-472d-90ff-5d15c24d0f2c"
  },
  {
    "id": "7b4ce6ea-2f62-4c54-b15e-6c8b5b1bbbd2",
    "name": "ProofOfPurchase",
    "type": "ProofOfPurchase",
    "version": 2,
    "schemaUri": "http://example.com/api/v1/schema/7b4ce6ea-2f62-4c54-b15e-6c8b5b1bbbd2"
  }
]
```

**Versioning**: If a schema with the same type is created more than once, the version increments automatically, allowing evolution without invalidating previously issued credentials.

**Security**: Only authorized clients (with x-client-secret) can create or delete schemas, ensuring integrity and trustworthiness of credential definitions.
