> For the complete documentation index, see [llms.txt](https://rc.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rc.sunbird.org/use/developer-guide/schema-setup/creating-your-own-schemas.md).

# Creating Your Own Schemas

An entity is defined by its schema.

{% code title="student.json" %}

```json
{
  "$schema": "http://json-schema.org/draft-07/schema",
  "type": "object",
  "definitions": {
    "Student": {
      "$id": "#/properties/Student",
      "type": "object",
      "uniqueIndexFields": ["phoneNumber"],
      "properties": {
        "name": { "type": "string" },
        "phoneNumber": { "type": "string" },
        "email": { "type": "string" },
        "school": { "type": "string" },
        "passwordToken": { "type": "string" }
      },
      "required": ["name", "phoneNumber", "email", "school"]
    }
  },
  "properties": { "Student": { "$ref": "#/definitions/Student" } },
  "_osConfig": {
    "privateFields": ["$.phoneNumber"],
    "internalFields": ["$.school"],
    "systemFields": ["osCreatedAt", "osUpdatedAt", "osCreatedBy", "osUpdatedBy"],
    "roles": ["admin"],
    "inviteRoles": ["admin"],
    "ownershipAttributes": [
      { "email": "/email", "mobile": "/phoneNumber", "userId": "/phoneNumber", "password": "/passwordToken" }
    ],
    "attestationPolicies": [
      {
        "name": "studentInstituteAttest",
        "additionalInput": { "enrollmentNumber": { "type": "string" } },
        "attestationProperties": { "name": "$.name", "educationDetails": "$.school" },
        "type": "MANUAL",
        "attestorPlugin": "did:internal:ClaimPluginActor?entity=Teacher",
        "conditions": "(ATTESTOR#$.school#.contains(REQUESTER#$.school#))"
      }
    ],
    "credentialTemplate": "",
    "certificateTemplates": {
      "svg": "https://raw.githubusercontent.com/dileepbapat/ref-sunbirdrc-certificate/main/schemas/templates/TrainingCertificate.svg"
    }
  }
}
```

{% endcode %}

{% hint style="info" %}
The example above is annotated for clarity in prose — schema files themselves cannot contain comments.
{% endhint %}

## Adding a new entity

Place the schema JSON in the schemas folder:

| Setup               | Schema folder                                                |
| ------------------- | ------------------------------------------------------------ |
| Registry CLI        | `config/schemas`                                             |
| Running from source | `java/registry/src/main/resources/public/_schemas`           |
| Docker Compose      | Wherever your `docker-compose.yaml` mounts the schema volume |

Then restart:

{% tabs %}
{% tab title="Docker Compose" %}

```bash
$ docker compose up --force-recreate -d
```

{% endtab %}

{% tab title="Registry CLI" %}

```bash
$ registry restart
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
`--force-recreate` is only needed after a config/schema change; for a plain process restart, `docker compose restart` or `registry restart --soft` is enough. After restarting manually, wait \~40 seconds and check status with `docker compose ps` / `registry status`.
{% endhint %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://rc.sunbird.org/use/developer-guide/schema-setup/creating-your-own-schemas.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
