> 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/create-schemas-with-custom-password.md).

# Create Schemas With Custom Password

Configure a schema so entities can set their own password, using a Student example.

{% stepper %}
{% step %}

### Configure the schema

Via the [Schema API Endpoint](https://rc.sunbird.org/api-reference/registry-apis/schema/create-schema.md):

```json
{
  "$schema": "http://json-schema.org/draft-07/schema",
  "definitions": {
    "Student": {
      "required": ["name", "phoneNumber", "email", "school"],
      "uniqueIndexFields": ["phoneNumber"],
      "properties": {
        "name": { "type": "string" },
        "phoneNumber": { "type": "string" },
        "email": { "type": "string" },
        "school": { "type": "string" },
        "password": { "type": "string", "minLength": 8 }
      }
    }
  },
  "_osConfig": {
    "ownershipAttributes": [
      { "email": "/email", "mobile": "/phoneNumber", "userId": "/phoneNumber", "password": "/password" }
    ],
    "inviteRoles": ["anonymous"]
  }
}
```

{% hint style="warning" %}
If `password` isn't set as an ownership attribute, Sunbird RC falls back to the default password configured in the registry environment. Passwords only apply at creation — they can't be changed via the update-entity API, and if the user account already exists (created by another entity), the password won't be updated.
{% endhint %}
{% endstep %}

{% step %}

### Invite the entity

Via the [Invite Entity API Endpoint](https://rc.sunbird.org/api-reference/registry-apis/registry/invite-an-entity.md):

```bash
curl --location --request POST \
  --header 'content-type: application/json' \
  --data-raw '{ "name": "Pranav Agate", "phoneNumber": "1234567890", "email": "pranav@upps.in", "school": "UP Public School", "password": "pranav@1234" }' \
  'http://localhost:8081/api/v1/Student/invite'
```

This creates the entity and a matching IAM (Keycloak) user with that password.
{% endstep %}

{% step %}

### Get an access token

```bash
curl --location --request POST \
  --header 'content-type: application/x-www-form-urlencoded' \
  --data 'client_id=registry-frontend' --data 'username=1234567890' --data 'password=pranav@1234' --data 'grant_type=password' \
  'http://localhost:8080/auth/realms/sunbird-rc/protocol/openid-connect/token'
```

{% endstep %}

{% step %}

### Retrieve the entity

Via the [Retrieve Entity API Endpoint](https://rc.sunbird.org/api-reference/registry-apis/registry/get-an-entity.md):

```bash
curl --location --request GET \
  --header 'content-type: application/json' \
  --header 'authorization: bearer {access-token}' \
  'http://localhost:8081/api/v1/Student'
```

The password is never returned — it's only used at Keycloak account creation and isn't stored in the entity record.
{% endstep %}
{% endstepper %}


---

# 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/create-schemas-with-custom-password.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.
