# 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.


---

# Agent Instructions: 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.empe.io/develop/issuer/schema-management.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.
