> This is part 1 of 2 of the full documentation (pages 1–100 of 132).
> The content is paginated: fetch every part to see all of it.
> Next part: https://rc.sunbird.org/llms-full.txt/1
> Page index: https://rc.sunbird.org/llms.txt

# 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
This site has an agentic ask interface you may use to query the documentation dynamically 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/index.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.

---

# Welcome Aboard!

Sunbird RC is a best-in-class open-source framework for building electronic registries and issuing verifiable credentials. It enables governments and organisations to build trusted registries of people, institutions and assets, from teachers and health workers to schools, and keep that data accurate, verified and ready to use. Sunbird RC is part of Sunbird, a Digital Public Good, and gives every adopter a proven foundation for digital trust, so no one has to build it from scratch.

{% hint style="info" %}
Subscribe to the Sunbird Newsletter for the latest updates <a href="https://zcmp.in/9UG8" class="button primary small" data-icon="envelope">Subscribe to the newsletter</a>
{% endhint %}

<p align="center"><strong>Credentials:</strong> v2.1.0 · <strong>Registry:</strong> v2.0.3 · <strong>Last updated:</strong> October 2026</p>

<p align="center"><a href="https://rc.sunbird.org/use/getting-started" class="button primary" data-icon="sparkle">Get started</a><a href="https://github.com/Sunbird-RC/sunbird-rc-core" class="button secondary" data-icon="github">View on Github</a> <a href="https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release" class="button primary" data-icon="rocket">Latest release</a></p>

<table data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Secure by Design</strong></td><td>Every credential is cryptographically signed, sensitive data is encrypted, and keys are managed in Vault.</td></tr><tr><td><strong>Designed to Scale</strong></td><td>Independent microservices on Kubernetes can be scaled horizontally as a registry grows.</td></tr><tr><td><strong>Resilient Under Load</strong></td><td>Entity creation can be processed asynchronously through Kafka to absorb spikes in demand.</td></tr><tr><td><strong>Open by Default</strong></td><td>Built on W3C Verifiable Credentials and DIDs, with no vendor lock-in, so credentials can be verified anywhere.</td></tr><tr><td><strong>Registries Without Code</strong></td><td>Define a schema, and Sunbird RC automatically generates the APIs, attestation workflows and credentials.</td></tr><tr><td><strong>Instant Verification</strong></td><td>Anyone can verify a credential in seconds by scanning a QR code, even offline.</td></tr></tbody></table>


# Overview

Build live, reusable and trustworthy registries and verifiable credentials — with configuration, not code.

Every digital platform runs on **master data** — structured, validated records about people, entities and things. Increasingly, this data lives in electronic registries with open APIs, so other systems can use attested, authenticated data instead of relying on paper-based checks. That lowers the cost of trust, especially when claims about people and entities need to be verified.

## The challenge

As registries scale, most of them run into the same three problems:

<table data-view="cards"><thead><tr><th></th><th></th><th data-type="image"></th></tr></thead><tbody><tr><td><strong>Live</strong></td><td>Data goes stale fast. Contact details, credentials and records change constantly, and re-collecting them is slow and expensive.</td><td></td></tr><tr><td><strong>Reusable</strong></td><td>Data trapped in one system can't be reused by another, so every department repeats the same collection and maintenance work.</td><td></td></tr><tr><td><strong>Trustworthy</strong></td><td>Data without a digital signature or attestation can't be trusted elsewhere. A CSV exported from a portal offers no guarantee it's authentic or unedited.</td><td></td></tr></tbody></table>

What's needed is an interoperable, unified registry infrastructure that makes registries live, reusable and trustworthy at once — a single source of truth that other systems can rely on without re-verifying it.

## What is Sunbird RC?

**Sunbird RC (Registry and Credentials)** is a low-code, open-source package for building electronic registries and issuing verifiable credentials. It has two components, which can be used on their own or together:

* **Registry** — builds an authoritative source of record for people, entities and things.
* **Credentials** — issues, manages and revokes W3C verifiable credentials from a trusted data source.

Instead of writing custom code, you describe your registry and credentials through configuration. Sunbird RC then generates the APIs, attestation and consent flows, and credential issuance and verification needed around them.

{% hint style="success" %}
**Open source and free to use.** Sunbird RC is [MIT-licensed](https://opensource.org/license/MIT) and listed as a global Digital Public Good in the [Digital Public Goods Alliance (DPGA) registry](https://digitalpublicgoods.net/registry/). It is the core engine behind DIVOC (vaccination and health credentialing). See [Adopters](https://rc.sunbird.org/learn/adopters) for other implementations and their status.
{% endhint %}

## A registry is an authoritative source, not just a database

A Sunbird RC registry is more than a store with CRUD and search APIs. It is the place other systems go to for the **authoritative version** of a record:

* **Owned by an authority.** The body responsible for the data — a ministry, a council, an institution — defines the schema and the rules for who can create, change and see each record.
* **Attested.** Claims can be checked by attesters before they are accepted, through configurable single- or multi-level attestation workflows.
* **Signed.** Records can be digitally signed, so anyone relying on them can confirm where they came from and that they haven't been altered.
* **Access-controlled.** Field-level privacy and consent decide who can see what.
* **Reused, not re-collected.** Other systems read from the registry through its APIs instead of collecting and maintaining their own copies.

The APIs are how systems use the registry; the trust in the data is what makes it authoritative. For more on the difference, see [Registry vs Database](https://rc.sunbird.org/help/comprehensive-overview-electronic-registries-and-verifiable-credentials/electronic-registries/registry-vs-database).

## From data source to verifier

A verifiable credential carries trusted data from where it is held to wherever it needs to be checked:

1. **Data source** — the authoritative record. This can be a Sunbird RC Registry, or any existing system of record you already run.
2. **Credential** — the Credentials component issues and signs a verifiable credential from that record.
3. **Holder** — the person or organisation the credential is about keeps it in a wallet or other digital storage they control.
4. **Verifier** — an employer, agency or service checks the credential's signature and status, without calling the issuer.

Because the Credentials component does not depend on where the data lives, you can issue credentials from an existing database or registry without moving it into Sunbird RC. If you also use the Registry component, the two connect directly. See [Workflows](https://rc.sunbird.org/learn/readme/workflows) for each step in detail.

## Watch: What is Sunbird RC?

Hear Dr Pramod Varma, CTO of EkStep Foundation, explain the thinking behind Sunbird RC.

{% embed url="<https://www.youtube.com/watch?feature=youtu.be&v=HsQK5uSUnDk>" %}
What is Sunbird RC? by Dr Pramod Varma
{% endembed %}

## What Sunbird RC provides

<table data-search="false"><thead><tr><th width="220">Feature</th><th>What it does</th></tr></thead><tbody><tr><td><strong>Master data store</strong></td><td>Model entities with flexible schemas (JSON/JSON-LD); attach validation, lifecycle and relationship rules</td></tr><tr><td><strong>Data operations</strong></td><td>Secure, API-driven CRUD; open APIs for publishing, access, and key-value or attribute search</td></tr><tr><td><strong>Data protection</strong></td><td>Encryption, masking, pluggable custom encryption services, audit trails and logging</td></tr><tr><td><strong>Single source of truth</strong></td><td>Digital signatures for trust and non-repudiation across every registry record</td></tr><tr><td><strong>Your choice of database</strong></td><td>Out-of-the-box adapters for multiple databases, including Postgres and graph DBs like Neo4j</td></tr><tr><td><strong>Modular and configurable</strong></td><td>Tailor the platform to your needs; supports multiple languages and multi-cloud deployment</td></tr><tr><td><strong>Observability</strong></td><td>Telemetry and analytics for monitoring system health, with audit logs to catch issues early</td></tr></tbody></table>

## Explore further

* [Why do we need Sunbird RC?](https://rc.sunbird.org/learn/readme/why-do-we-need-sunbird-rc)
* [Core Capabilities](https://rc.sunbird.org/learn/readme/core-capabilities)
* [Workflows](https://rc.sunbird.org/learn/readme/workflows)
* [What Sunbird RC is and what it's not](https://rc.sunbird.org/learn/readme/what-sunbird-rc-is-and-what-its-not)
* [Possibilities](https://rc.sunbird.org/learn/readme/possibilities)


# Why do we need Sunbird RC?

Stand up trusted registries and verifiable credentials quickly — for any domain.

{% embed url="<https://www.youtube.com/watch?v=zWDyQWuB_lw>" %}

Sunbird RC lets you quickly build registries of individuals, objects and entities for a wide variety of domains.

{% hint style="info" %}
Sunbird RC is one open-source package with two components, **Registry** and **Credentials**. You can use either one on its own, or both together. Each component has its own release line and version number.
{% endhint %}

## Build registries through configuration

Adopters build core electronic registries using configurable schemas and workflows. Sunbird RC then automatically creates all the APIs, workflows and a default user experience needed by key registry stakeholders.

## Issue credentials people can carry and verify

Sunbird RC provides microservices to issue portable, standard schema-based credentials that are compliant with the [W3C Verifiable Credentials](https://www.w3.org/TR/vc-data-model/) data model, with built-in attestation and verification flows. Credentials can be issued from a Sunbird RC Registry or from any existing system of record. These credentials:

* can be printed with QR codes
* can be translated into many languages
* can be verified by anyone, using the issuer's public key

Along the way, Sunbird RC handles enrolment, authentication, data ownership, search, issuance and management of verifiable credentials, claim attestation between users and attesters, and sharing of credentials with user consent.

## Built to scale and integrate

<table data-search="false"><thead><tr><th width="200">Quality</th><th>What it means</th></tr></thead><tbody><tr><td><strong>Scalable</strong></td><td>Built from independently deployable microservices that can be scaled horizontally as volumes grow.</td></tr><tr><td><strong>Always up to date</strong></td><td>Supports both synchronous and asynchronous updates, so data stays current.</td></tr><tr><td><strong>Interoperable</strong></td><td>Built on open standards and protocols, so it integrates with other systems and applications without reinventing the wheel.</td></tr></tbody></table>

{% hint style="info" %}
**In short:** Sunbird RC gives organizations a secure, scalable way to manage and verify digital identities and credentials — making access and permissions easier to manage, and giving individuals greater control over their own data.
{% endhint %}


# What Sunbird RC is and what it's not?

Where Sunbird RC fits — and what you'll still need to build or bring yourself.

Sunbird RC is a set of open-source building blocks for registries and verifiable credentials. This page draws the line clearly, so adopters know what they're getting and what they still need to build or bring themselves.

{% hint style="info" %}
Sunbird RC is one open-source package with two components, **Registry** and **Credentials**. You can use either one on its own, or both together. Each component has its own release line and version number.
{% endhint %}

## What Sunbird RC is

One open-source package with two components. You can use either one on its own, or both together. Each is made up of independently deployable microservices:

* **Registry** — a configurable, low-code registry: Registry (core), Claims / Attestation, Notification, Metrics, Encryption and ID Gen.
* **Credentials** — a W3C-compliant credentialing service: Identity, Credential Schema, Credential Issuance and OID4VC.

When both are used together, Registry's signing and DID features (Signature V2) are provided by the Credentials services.

For the full picture, see [Sunbird RC Overview](https://rc.sunbird.org/learn/readme), Why do we need Sunbird RC? and Core Capabilities.

{% hint style="success" %}
**Works with any compliant wallet.** Through the OID4VC microservice, Sunbird RC now speaks OpenID4VCI (issuance) and OpenID4VP (presentation), so any compliant wallet — not just a Sunbird-built one — can fetch, hold and present credentials issued by the platform.
{% endhint %}

## What Sunbird RC is not

<table data-search="false"><thead><tr><th width="220">Sunbird RC is not…</th><th>What that means for you</th></tr></thead><tbody><tr><td><strong>A wallet app</strong></td><td>Sunbird RC does not ship a holder-facing wallet with its own credential storage or UI — earlier wallet and verifier-app prototypes were removed from the codebase in favor of standards compliance. Citizens use any OpenID4VCI/VP-compliant wallet of their choice.</td></tr><tr><td><strong>An identity provider</strong></td><td>Authentication and authorization run through Keycloak by default, but Sunbird RC can sit behind any OpenID Connect-compliant IDP and OAuth2 resource server — it doesn't replace one.</td></tr><tr><td><strong>A consent management platform</strong></td><td>By design, the consent decision and disclosure happen inside the holder's own wallet — the verifier states what it needs via DCQL, and the wallet decides what to share. This keeps consent under the holder's control rather than logged on a central server.</td></tr><tr><td><strong>A blockchain or DID network</strong></td><td>DIDs are generated and resolved as part of identity management, but Sunbird RC doesn't operate a distributed ledger or implement DIDComm — it's a centrally operated registry with DID-compliant, web-resolvable identifiers.</td></tr><tr><td><strong>A turnkey vertical solution</strong></td><td>There's no built-in student registry, national ID system or health registry out of the box — every deployment defines its own schemas, workflows and attestation policy to fit its use case.</td></tr></tbody></table>


# Core Capabilities

What Sunbird RC can do out of the box — with Registry and Credentials, used on their own or together.

<figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FUzl140s7LPuogyuVWGf7%2Fcore.png?alt=media&#x26;token=860736a3-c1ee-4b73-802d-5ba30c0481cf" alt=""><figcaption></figcaption></figure>

Sunbird RC is one open-source package with two components, **Registry** and **Credentials**. You can use either one on its own, or both together. This page lists what each component can do and the status of each capability.

## Capability matrix

Status labels follow the [Roadmap](https://rc.sunbird.org/help/roadmap): **Released**, **Experimental**, **In Development** and **Roadmap**.

| Component              | Capability                                                                                            | Status            |
| ---------------------- | ----------------------------------------------------------------------------------------------------- | ----------------- |
| Registry               | Schema definition, with field types and field-level privacy                                           | Released          |
| Registry               | Entity creation: bulk onboarding via CSV, self-registration, links to external systems                | Released          |
| Registry               | Ownership, login and authorization                                                                    | Released          |
| Registry               | Discovery with public, private and consent-based visibility                                           | Released          |
| Registry               | Attestation and claim workflows                                                                       | Released          |
| Registry               | Consent: grant, revoke and audit access                                                               | Released          |
| Registry               | Basic analytics                                                                                       | Released          |
| Credentials            | W3C-compliant credential issuance, update and revocation                                              | Released          |
| Credentials            | Credential formats: `ldp_vc`, `jwt_vc_json`, `vc+sd-jwt`, `mso_mdoc`                                  | Released          |
| Credentials            | Wallet issuance via OpenID4VCI 1.0 (draft-13 compatible)                                              | Released (opt-in) |
| Credentials            | Wallet presentation via OpenID4VP 1.0 (draft-23)                                                      | Released (opt-in) |
| Registry + Credentials | [Authority Service](#authority-service): multi-tenant access control, configuration and record review | In Development    |

## Registry

A governing body or authority can build a registry that acts as a **single source of truth**.

1. **Define schema as per policy**
   * **Fields and field types:** Create new fields in the registry to store specific types of information, and specify the type of data each field accepts. For example, a student registry might define fields for student name, father's name, mother's name, school name and age — with the age field accepting only numbers.
   * **Field-level privacy:** Set different levels of privacy for different fields based on how sensitive their data is. For example, in a patient registry, fields containing health information can be restricted to authorized healthcare professionals, while less sensitive fields such as demographics are available to a wider range of users.
   * **Consent framework** at schema level
2. **Create entities**
   * Bulk invite or onboard users via CSV
   * Link to external systems
   * Let users self-register
   * Decide, at field level, who can view the content
3. **Define ownership**
   * Define which entities can log in and how authorization is handled
4. **Discovery**
   * Control the visibility of discovery attributes through access control mechanisms such as consent-based sharing. Users can mark each discovery attribute as **public** (visible to all users), **private** (visible only to the user) or **consent-based** (visible to selected users or groups based on their consent).
5. **Attestation and claim workflows**
   * Tenants (users) can define an add-on workflow, customizing its steps to suit their needs, and configure whether claims are approved automatically or manually.
   * Attestation can run on an internal system like Sunbird RC, or on an external system the tenant connects to.
   * Claims can go through multi-level attestation — reviewed by multiple parties or levels of approval.
   * Define validity
6. **Consent**
   * **Grant or revoke consent:** Receive consent requests and grant or revoke access.
   * Consent auditing
7. **Analytics**
   * Basic analytics for registries

## Credentials

1. **Issuance services**
   * W3C compliant
   * Create and issue verifiable credentials
   * Update and revoke credentials
   * Unique ID generation
2. **Verification**
   * Anyone can verify a credential's signature and status.
   * Holders share credentials with a verifier by consent, from their own wallet.
3. **Digital wallet interoperability (opt-in)**
   * Credentials implements OpenID4VCI and OpenID4VP through the OID4VC service, so citizens can use **any compliant wallet** — Sunbird-built or third-party — to hold and present their credentials. The OID4VC service is optional and is enabled separately.

{% tabs %}
{% tab title="Fetch and store credentials" %}

* **Issuance via OpenID4VCI 1.0** (draft-13 compatible): the issuer publishes a credential offer, the wallet resolves it, exchanges a pre-authorized code for a token, then proves key possession (nonce + PoP) to fetch the credential.
* Supports deferred issuance and issuance notifications.
* **Formats:** `ldp_vc`, `jwt_vc_json`, `vc+sd-jwt`, `mso_mdoc`
* Standard `.well-known` discovery endpoints — no custom wallet integration needed.
  {% endtab %}

{% tab title="Share with consent" %}

* **Presentation via OpenID4VP 1.0** (draft-23): the verifier describes the claims it needs via DCQL, and the wallet fetches the request object and returns a `vp_token`.
* **Consent is enforced at the wallet** — the holder decides what to disclose against the query; there is no blanket handover.
* The verifier polls the presentation status to confirm what was shared.
  {% endtab %}
  {% endtabs %}

## Using Registry and Credentials together

When both components are deployed, a registry can issue verifiable credentials from its own records. Registry's signing and DID features (Signature V2) are provided by the Credentials services, and the registry can also hand credentials to wallets through the OID4VC service.

## In development

### Authority Service

{% hint style="warning" %}
**In Development.** The Authority Service is not part of any Sunbird RC release yet. Its design, APIs and behaviour may change. Don't use it in production.
{% endhint %}

**What it is.** The Authority Service is a small, reusable, **domain-neutral** administrative layer that sits in front of Sunbird RC. It provides multi-tenant access control, configuration, and a lightweight record-review workflow for any registry entity — without encoding business logic specific to a particular sector (agriculture, education, etc.).

**Why it exists.** Sunbird RC already supports per-record ownership, login, field-level privacy, consent and attestation workflows. What it doesn't provide is **multi-tenancy**: a way for each organisation's administrators able to manage only their own registries and records. The Authority Service adds that layer, so multiple organisations can share one instance safely, with a basic review step before a record is treated as trustworthy.

**Core model.**

```
Authority → Registry → Credential Profile → Credential
```

Definitions of each level, and how they map to existing Sunbird RC concepts such as registry schemas and credential schemas, will be added here.

**Where it fits.** The Authority Service sits in front of Sunbird RC and works across both components. Whether it is optional, and how it is used alongside direct calls to the Registry and Credentials APIs, is being confirmed.

**Status and scope.** Not included in any release. The target release and first-release scope are being confirmed — see the [Roadmap](https://rc.sunbird.org/help/roadmap). Follow progress on [GitHub Discussions](https://github.com/orgs/Sunbird-RC/discussions).

## Core Registry Verbs

<figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FKPB7ZDEuNKvvfmhnEGGb%2Fimage.png?alt=media&#x26;token=4f7e3485-112e-44fa-b6e2-b7c8e5e3a6b5" alt=""><figcaption></figcaption></figure>


# Workflows

How users, issuers, holders and verifiers move through Sunbird RC — from onboarding to verification.

<figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FS1MvdIcHZgmRx1CeOtOK%2Fworkflow.png?alt=media&#x26;token=eef8d060-f91f-4262-8bc1-6987b798f5ed" alt=""><figcaption></figcaption></figure>

The full flow runs from a trusted record to a verified credential. Each step is handled by one of Sunbird RC's two components:

| Step                        | Component                                                            |
| --------------------------- | -------------------------------------------------------------------- |
| Registration and onboarding | Registry                                                             |
| Credential issuance         | Credentials                                                          |
| Credential storage          | Holder's wallet (not part of Sunbird RC)                             |
| Credential verification     | Verifier, using Credentials APIs or any standards-compliant verifier |

You can start at either component. If you use the Registry, records flow from it into issuance. If you only use Credentials, issuance starts from your existing system of record instead.

{% stepper %}
{% step %}

### User registration and onboarding (Registry)

Users can join a registry in three ways:

* Self-registration
* Registration via invitation
* Integration with existing registries
  {% endstep %}

{% step %}

### Verifiable credential issuance (Credentials)

The issuer creates the credential from a trusted record — a Sunbird RC Registry entry or a record from another system — and digitally signs it using a cryptographic key that only the issuer can use (as JSON-LD, JWT, SD-JWT or mdoc, depending on the configured credential format).

The signature is generated with the issuer's private key and attached to the credential, so verifiers can confirm the credential hasn't been altered since it was issued. The public key associated with the issuer's private key can also be included in the credential, letting verifiers check the signature.
{% endstep %}

{% step %}

### Verifiable credential storage (Holder)

Once issued, the credential is stored in an eLocker, digital wallet or other digital storage controlled by the credential holder. The wallet gives the holder a secure, convenient way to manage and share their credentials with others.
{% endstep %}

{% step %}

### Verifiable credential verification (Verifier)

When the holder presents a credential to an accepting party or verifier — such as a potential employer — the verifier checks its authenticity using cryptographic techniques. Verifying the issuer's digital signature confirms that the credential hasn't been tampered with since it was issued, and checking its status confirms it hasn't been revoked.
{% endstep %}
{% endstepper %}

## Wallet-based flows

The Credentials component also supports standards-based flows that work with **any compliant wallet**, not just a Sunbird-built one. These are provided by the optional OID4VC service.

{% tabs %}
{% tab title="Issuance (OpenID4VCI)" %}
The issuer publishes a credential offer; the wallet resolves it, exchanges a pre-authorized code for an access token, and fetches the signed credential directly into wallet storage — a standardized, wallet-interoperable alternative to manual download.
{% endtab %}

{% tab title="Verification (OpenID4VP)" %}
The verifier describes the claims it needs using DCQL; the wallet returns a signed presentation containing only those claims, which the verifier checks against the issuer's public key.
{% endtab %}
{% endtabs %}


# Possibilities

Ideas for what you can build with Sunbird RC across education, healthcare, government and employment.

<figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FQV2byNZwuzyUGV9Cqini%2Fpossibilities.png?alt=media&amp;token=6d0e240c-77d1-4911-a33c-87a65fd7b252" alt=""><figcaption></figcaption></figure>

Sunbird Registry and Credentials provides a secure, scalable way to manage digital identities and credentials. Here are some of the areas where it can be used:

{% tabs %}
{% tab title="🎓 Education" %}
Manage educational credentials such as degrees, certificates and diplomas.

* Institutions can securely issue and verify digital credentials.
* Students get a secure, portable way to share their achievements.
  {% endtab %}

{% tab title="🏥 Healthcare" %}
Manage healthcare credentials such as medical licenses, certifications and training records.

* Providers can ensure their staff are qualified and competent.
* Patients can verify the credentials of their healthcare providers.
  {% endtab %}

{% tab title="🏛️ Government" %}
Manage citizen identities and credentials such as driver's licenses, passports and voter registration.

* Improves the efficiency and accuracy of government services.
* Enhances the security and privacy of citizen data.
  {% endtab %}

{% tab title="💼 Employment" %}
Manage employment credentials such as job certifications, training records and performance reviews.

* Employers can ensure their staff are qualified and competent.
* Employees can securely share their credentials with potential employers.
  {% endtab %}
  {% endtabs %}


# Adopters

Implementations built on Sunbird RC, and the status of each.

Sunbird RC is used in the following implementations.

{% hint style="info" %}
**How to read this page.** Each implementation is marked as **Production** (in live use), **Pilot** (live with a limited group), **PoC** (proof of concept), **Reference** (a sample or reference application) or **Historical** (no longer active). Entries marked — are being confirmed. Figures such as user or record counts are as reported by the adopter.
{% endhint %}

<table data-search="false"><thead><tr><th width="126"></th><th></th><th width="130">Status</th></tr></thead><tbody><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/IdZC1cFuN7C5PuiBn5UG/image%20(25).png" alt="" data-size="original"></td><td><p><strong>COVID Vaccination Credentials</strong></p><p>Sunbird RC is the core engine within <a href="https://divoc.dev/">DIVOC</a>, a DPG for vaccination and health credentialing. DIVOC uses Sunbird RC to generate vaccination certificates, available electronically and as printable copies. Governments including India, Sri Lanka and the Philippines have implemented DIVOC for their digital vaccination programmes.</p></td><td>Production</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/IdZC1cFuN7C5PuiBn5UG/image%20(25).png" alt="" data-size="original"></td><td><strong>COVID Test Certificates</strong></td><td>—</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/t15XZtYPzWEarV473J97/image%20(27).png" alt="" data-size="original"></td><td><p><strong>DIKSHA</strong></p><p><a href="https://diksha.gov.in/">DIKSHA</a> (Digital Infrastructure for Knowledge Sharing) is India's national school education platform. Student, teacher and school registries are core building blocks of the platform, and these registries can be built with Sunbird RC.</p></td><td>—</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/vsFJmxiNPHXvE8WgCQgk/image%20(28).png" alt="" data-size="original"></td><td><p><strong>iGOT Karmayogi</strong></p><p>An online platform for the capacity building of civil service officials. iGOT uses Sunbird RC to issue and verify digital certificates as proof of training, for a reported 2 crore officials.</p></td><td>Production</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Upskilling platform</strong></p><p>A multinational corporation built an upskilling platform on Sunbird RC, focused on vocational and soft-skill development. It issues verifiable credentials and certificates to learners, with a reported 500,000+ learners and 10,000+ courses.</p></td><td>Production</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Organ Pledge Registry</strong></p><p>A government health agency created a registry of individuals who have pledged to donate organs. It verifies the people pledging, and generates verifiable digital pledge certificates from registration data, including multilingual certificates.</p></td><td>Production</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Unified Learners Passport (ULP)</strong></p><p>A single digital credential source for learners across levels. ULP lets learners aggregate their educational achievements, skills and experiences, and share them as verifiable credentials with opportunity providers.</p></td><td>Pilot</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>eLocker</strong></p><p>A proof of concept for a digital wallet that lets users manage digital documents, including government-issued IDs and academic certificates.</p></td><td>PoC</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Event participation credentials</strong></p><p>Organisations use Sunbird RC to issue proof-of-achievement credentials to participants in events they host.</p></td><td>Production</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Vehicle Registry</strong></p><p>A proof of concept that adds verifiable credentials to number plates and registration cards, to support authentication and accountability in vehicle management.</p></td><td>PoC</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Credential management platform</strong></p><p>An adopter used Sunbird RC to build a configurable platform for registering, verifying and issuing verifiable credentials.</p></td><td>—</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Volunteer and needs registries</strong></p><p>Another Sunbird building block uses Sunbird RC as a component for its registries of volunteers, agencies, needs and need types.</p></td><td>—</td></tr><tr><td><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/o0HRVOsyXbM74quASmIz/image%20(2)%20(1).png" alt="" data-size="original"></td><td><p><strong>Farmer Registry</strong></p><p>A government agency is building a platform on Sunbird RC to issue verifiable credentials to farmers. Each farmer will receive a unique farmer ID and a verifiable credential, with the registry linked to their farmland plot records.</p></td><td>—</td></tr><tr><td><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FfQ3gFiK9Psnp9KyZaGRV%2Fimages.png?alt=media&#x26;token=671cb003-f090-4433-945b-24f55e744851" alt=""></td><td><p><strong>NSDC</strong></p><p>NSDC runs its national skilling ecosystem on the Sunbird RC "Skill and Work Credentials" architecture. It keeps a registry of candidates and their training and employment records, and issues verifiable credentials at enrolment, course completion and employment verification. The registry holds a reported 200 million entries.</p></td><td>Production</td></tr></tbody></table>


# Getting started

Sunbird RC is one open-source package with two components, **Registry** and **Credentials**. You can use either one on its own, or both together. Pick the path that matches what you need.

## New to Sunbird RC? Choose your path

| Path                       | Choose this if you want to…                                                                        |
| -------------------------- | -------------------------------------------------------------------------------------------------- |
| **Registry only**          | Build an authoritative registry of people, entities or things, with APIs, attestation and consent. |
| **Credentials only**       | Issue and verify W3C verifiable credentials from data you already hold in another system.          |
| **Registry + Credentials** | Build a registry and issue verifiable credentials from its records.                                |

Before you start, install the [Pre-requisites](https://rc.sunbird.org/use/getting-started/developer-setup) for your path.

{% tabs %}
{% tab title="Registry only" %}
**Quick start**

* [Docker Compose Setup](https://rc.sunbird.org/use/getting-started/installation/docker-compose-setup) — the default settings leave credential signing off, so the Registry runs on its own.
* Or the [Registry CLI](https://rc.sunbird.org/use/getting-started/installation/registry-cli) for a guided local setup.

**Next steps**

* [Creating Your Own Schemas](https://rc.sunbird.org/use/developer-guide/schema-setup/creating-your-own-schemas)
* [Registry API reference](https://rc.sunbird.org/registry/api-reference/registry/using-the-apis)
* [Core Capabilities](https://rc.sunbird.org/learn/readme/core-capabilities)
  {% endtab %}

{% tab title="Credentials only" %}
**Quick start**

* [Credentialling Services setup](https://rc.sunbird.org/use/getting-started/installation/credentialling-services-setup-dev-docker-helm) — use the **Docker Compose** tab.

**Next steps**

* [Credentials API reference](https://rc.sunbird.org/credentials/api-reference/credential-issuance-apis)
* [Wallet Integration](https://rc.sunbird.org/use/integrations/wallet-integration) — optional, to issue to and verify from any compliant wallet
  {% endtab %}

{% tab title="Registry + Credentials" %}
**Quick start**

1. Follow [Docker Compose Setup](https://rc.sunbird.org/use/getting-started/installation/docker-compose-setup).
2. From the `sunbird-rc-core` folder, run `bash enable-v2.sh`. This brings up Vault, identity, credential-schema, credentials and claim-ms, and restarts the Registry with signing, DIDs and claims turned on.

**Next steps**

* [Signature V1 or V2](https://rc.sunbird.org/use/developer-guide/working-with-source-code#signature-v1-or-v2) — how the Registry signs credentials
* [Wallet Integration](https://rc.sunbird.org/use/integrations/wallet-integration) — optional
  {% endtab %}
  {% endtabs %}

## Going to production

For a Kubernetes deployment, see [Helm Setup](https://rc.sunbird.org/use/getting-started/installation/helm-setup) and the **Helm** tab of [Credentialling Services setup](https://rc.sunbird.org/use/getting-started/installation/credentialling-services-setup-dev-docker-helm).

{% hint style="warning" %}
The production deployment guides are being reviewed for v2.1.0. Check with the community on [GitHub Discussions](https://github.com/orgs/Sunbird-RC/discussions) before deploying to production.
{% endhint %}

## Already running Sunbird RC?

See [For existing adopters](https://rc.sunbird.org/use/getting-started/for-existing-adopters) for what's new, what changed, compatibility and upgrade steps.

## In this section

* [Pre-requisites](https://rc.sunbird.org/use/getting-started/developer-setup)
* [Installation](https://rc.sunbird.org/use/getting-started/installation)
* [For existing adopters](https://rc.sunbird.org/use/getting-started/for-existing-adopters)


# Pre-requisites

Install these before starting. What you need depends on the [path you choose](https://rc.sunbird.org/use/getting-started). Each section has a command to confirm the install worked.

| Tool              | Version    | Needed for                                                    | Check with               |
| ----------------- | ---------- | ------------------------------------------------------------- | ------------------------ |
| Terminal emulator | —          | All paths                                                     | `echo Hi`                |
| Git               | any recent | All paths                                                     | `git --version`          |
| Docker            | any recent | All paths                                                     | `docker -v`              |
| Docker Compose    | 2.x        | All paths                                                     | `docker compose version` |
| Java              | 11         | Building the Registry from source                             | `java -version`          |
| NodeJS            | 20.x       | Registry CLI, or running the Credentials services from source | `node -v`                |

{% hint style="info" %}
If you only run Sunbird RC with Docker Compose or Helm, you don't need Java or NodeJS.
{% endhint %}

## Terminal emulator

Linux and macOS have a terminal installed already. For Windows, it's recommended you use `git-bash`, which you can install from [here](https://gitforwindows.org/).

Type `echo Hi` in the terminal once it's installed. If installed correctly, you should see `Hi` appear when you hit enter.

## Git

Installation instructions for Git can be found [here](https://git-scm.com/downloads).

```bash
$ git --version
```

## Docker

Installation instructions for Docker can be found [here](https://docs.docker.com/get-docker/).

```bash
$ docker -v
```

## Docker Compose

Docker Compose v2 ships with current versions of Docker. Installation instructions can be found [here](https://docs.docker.com/compose/install/).

```bash
$ docker compose version
```

{% hint style="info" %}
Some pages in these docs use the older `docker-compose` command. With Compose v2, use `docker compose` instead.
{% endhint %}

## Java

Only needed to build the Registry from source. Installation instructions for Java 11 can be found [here](https://adoptium.net/).

```bash
$ java -version
```

## NodeJS

Only needed for the Registry CLI, or to run the Credentials services from source. Installation instructions for NodeJS can be found [here](https://nodejs.org/).

```bash
$ node -v
```


# Installation

Choose a **quick start** to try Sunbird RC on your machine, or a **production** path to deploy on Kubernetes. Not sure which component you need? See [Getting started](https://rc.sunbird.org/use/getting-started).

## Quick start

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Registry CLI</strong></td><td>Registry · Guided local setup, no YAML to edit.</td><td><a href="https://rc.sunbird.org/use/getting-started/installation/registry-cli">Registry CLI</a></td></tr><tr><td><strong>Docker Compose setup</strong></td><td>Registry, or Registry + Credentials · Full control over services and environment.</td><td><a href="https://rc.sunbird.org/use/getting-started/installation/docker-compose-setup">Docker Compose Setup</a></td></tr><tr><td><strong>Credentialling Services</strong></td><td>Credentials · Identity, Credential Schema and Credentials, with the optional OID4VC service. Development, Docker and Helm variants.</td><td><a href="https://rc.sunbird.org/use/getting-started/installation/credentialling-services-setup-dev-docker-helm">Credentialling Services setup (Dev / Docker / Helm)</a></td></tr></tbody></table>

## Production

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Helm setup</strong></td><td>Registry · Deployment on Kubernetes, from the <code>devops</code> repo.</td><td><a href="https://rc.sunbird.org/use/getting-started/installation/helm-setup">Helm Setup</a></td></tr><tr><td><strong>Credentialling Services — Helm</strong></td><td>Credentials · See the Helm tab of the Credentialling Services setup.</td><td><a href="https://rc.sunbird.org/use/getting-started/installation/credentialling-services-setup-dev-docker-helm">Credentialling Services setup (Dev / Docker / Helm)</a></td></tr></tbody></table>

{% hint style="warning" %}
The production deployment guides are being reviewed for v2.1.0. Check with the community on [GitHub Discussions](https://github.com/orgs/Sunbird-RC/discussions) before deploying to production.
{% endhint %}


# Registry CLI

{% hint style="info" %}
**System requirements**: 4 cores · 8 GB RAM · 100 GB disk minimum.
{% endhint %}

This guide assumes some familiarity with basic Linux commands. Don't copy-paste the `$` signs — they indicate that what follows is a terminal command.

{% stepper %}
{% step %}

### Install the Registry CLI

```bash
$ npm install --global @sunbird-rc/registry-cli
```

If you hit a permission-denied error, prefix the command with `sudo`:

```bash
$ sudo npm install --global @sunbird-rc/registry-cli
```

Check the install:

```bash
$ registry help
```

{% endstep %}

{% step %}

### Set up a registry instance

Run the following in a directory where you wish to set up the registry (`~/Registries/example/` in this example):

```bash
$ mkdir -p ~/Registries/example
$ cd ~/Registries/example
$ registry init
```

This presents a set of questions to configure the registry — registry version, auxiliary services (toggle with SPACE BAR), and the QR code type to generate on certificates when signing is enabled. You can accept the defaults for a first run.
{% endstep %}

{% step %}

### Check the registry status

```bash
$ registry status
```

Confirm every service shows as running. If a service shows `exited`, restart just that service:

```bash
$ docker-compose restart <service-name>
```

To force-recreate the registry service after a config or schema change:

```bash
$ SCHEMA_DIR=config/schemas docker-compose up -d --force-recreate --no-deps registry
```

{% endstep %}

{% step %}

### Stop the registry

```bash
$ registry down
```

{% endstep %}
{% endstepper %}


# Docker Compose Setup

{% hint style="info" %}
**System requirements**: 4 cores · 8 GB RAM · 100 GB disk minimum — same as the Registry CLI path.
{% endhint %}

{% stepper %}
{% step %}

### Get the compose file and environment template

Download the latest [docker-compose.yml](https://github.com/Sunbird-RC/sunbird-rc-core/blob/main/docker-compose.yml) and modify values as needed. Then download or create a `.env` file from the [`.env.example`](https://github.com/Sunbird-RC/sunbird-rc-core/blob/main/.env.example) template.
{% endstep %}

{% step %}

### Set the required environment variables

| ENV               | Value     | Description                                                                                     |
| ----------------- | --------- | ----------------------------------------------------------------------------------------------- |
| `RELEASE_VERSION` | `v2.1.0`  | Use the latest [release](https://github.com/Sunbird-RC/sunbird-rc-core/releases) of Sunbird RC. |
| `SCHEMA_DIR`      | `schemas` | Relative path to the directory where schemas are created.                                       |
| {% endstep %}     |           |                                                                                                 |

{% step %}

### Add schemas and imports

Create the schema files in the `schemas` directory. Then create an `imports` directory and download the Keycloak realm file and the sample signing key file into it.

{% hint style="warning" %}
The sample signing keys are for local use only — replace them before going to production.
{% endhint %}
{% endstep %}

{% step %}

### Set up Keycloak

```bash
docker-compose up -d db
docker-compose up -d keycloak
```

Open the Keycloak admin console at `http://localhost:8080/auth/`, go to **Clients** → `admin-api` → **Credentials** → **Regenerate Secret**, copy the value, and set `KEYCLOAK_SECRET` in `.env` with it.
{% endstep %}

{% step %}

### Start everything and verify

```bash
docker-compose up -d
docker-compose ps
```

The registry swagger JSON is then available at `http://localhost:8081/api/docs/swagger.json`.
{% endstep %}
{% endstepper %}


# Helm Setup

{% hint style="warning" %}
**Helm charts don't live in `sunbird-rc-core` anymore.** They live in the separate [`Sunbird-RC/devops`](https://github.com/Sunbird-RC/devops) repo, under `deploy-as-code/helm/v1`. This is the single most common trip-up when following this page — an older doc revision pointed at `sunbird-rc-core/infra/...`, which no longer exists.
{% endhint %}

**Prerequisites**: Kubernetes cluster (min. 3 nodes), Helm, kubectl, [ingress-nginx](https://kubernetes.github.io/ingress-nginx/deploy/), a Postgres DB (for both Keycloak and the registry), and optionally ElasticSearch, Kafka, Redis, Minio. See the [High-Level Architecture](https://rc.sunbird.org/registry) page for what each optional service is for.

{% stepper %}
{% step %}

### Clone the repo and pre-check the cluster

```bash
git clone https://github.com/Sunbird-RC/devops.git
cd devops/deploy-as-code/helm/v1
```

```bash
kubectl cluster-info
kubectl get nodes
kubectl get ns
helm version
```

Create a namespace:

```bash
kubectl create ns demo-registry
```

{% endstep %}

{% step %}

### Create secrets

Base64-encode all passwords/secrets and set them in `values.yaml`:

| Secret                           | Required | Purpose                                                     |
| -------------------------------- | -------- | ----------------------------------------------------------- |
| `DB_PASSWORD`                    | Yes      | Postgres database password                                  |
| `KEYCLOAK_ADMIN_PASSWORD`        | Yes      | Keycloak admin console password                             |
| `KEYCLOAK_DEFAULT_USER_PASSWORD` | Yes      | Default password for new users created by the registry      |
| `MINIO_SECRET_KEY`               | No       | Minio secret key                                            |
| `ELASTIC_SEARCH_PASSWORD`        | No       | ElasticSearch connection password                           |
| `KEYCLOAK_ADMIN_CLIENT_SECRET`   | No       | Client secret of the Keycloak admin client for the registry |
| {% endstep %}                    |          |                                                             |

{% step %}
{% hint style="info" %}
The passwords listed in the `values.yaml` should be updated.
{% endhint %}
{% endstep %}

{% step %}

### Configure values, schemas and signing keys

Modify the configuration values — database address, ElasticSearch address, etc. — in `values.yaml`.

Place schema files at [`devops/deploy-as-code/helm/v1/helm_charts/charts/registry/schemas`](https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/helm/v1/helm_charts/charts/registry/schemas).

Configure signing keys (a sample key ships by default — replace it before going live):

* Public + private signing keys: [`.../certificate-signer/keys`](https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/helm/v1/helm_charts/charts/certificate-signer/keys)
* Public key only (for verifiers): [`.../public-key-service/keys`](https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/helm/v1/helm_charts/charts/public-key-service/keys)
  {% endstep %}

{% step %}

### Deploy

```bash
helm upgrade --install --namespace=demo-registry demo-registry helm_charts --create-namespace
kubectl get pods -n demo-registry
```

{% endstep %}

{% step %}

### Import the Keycloak realm and set the secret

Via the admin console (`<host>/auth/`): Master → Add realm → import `imports/realm-export.json`.

Then Clients → `admin-api` → Credentials → Regenerate Secret → copy it, base64-encode it, and set `KEYCLOAK_ADMIN_CLIENT_SECRET` via `kubectl edit secret rc-secret -n demo-registry`. Then:

```bash
kubectl rollout restart deploy/demo-registry -n demo-registry
kubectl get pods -n demo-registry
```

{% endstep %}

{% step %}

### Check the registry APIs

Open `<host>/registry/api/docs/swagger.json` in a browser.
{% endstep %}
{% endstepper %}


# Credentialling Services setup (Dev / Docker / Helm)

The same three-way split as the Registry: run locally for development, bring it up with Docker Compose, or deploy to Kubernetes with Helm.

{% tabs %}
{% tab title="Development" %}

* Node.js version: `v20.11.0`
* Runs identity-service, credential-schema, and credentials-service locally. Vault is required — see Working with the Vault.
* Environment variables: check the [docker-compose.yml](https://github.com/Sunbird-RC/sunbird-rc-core/blob/main/docker-compose.yml) for the values credentialling services expect (e.g. `DATABASE_URL=postgres://postgres:postgres@db:5432/registry`).
* Per service: `cd` into the service directory, `yarn install`, then `yarn start`.

**Dependency chain**

```mermaid
flowchart LR
    Vault --> Identity[Identity Service]
    DB[(Database)] --> Identity
    DB --> Schema[Credential Schema Service]
    Identity --> Schema
    DB --> Creds[Credentials Service]
    Identity --> Creds
    Schema --> Creds
```

{% endtab %}

{% tab title="Docker Compose" %}

* System requirements: 4 Cores / 8 GB RAM / 100 GB disk (same as Registry).
* Download the [credentialling docker-compose.yml](https://github.com/Sunbird-RC/devops/blob/main/deploy-as-code/docker/v2/credentialling/docker-compose.yml) from the `devops` repo.
* Create a `.env` from the example file provided alongside it.

```bash
docker-compose up -d
docker-compose ps
```

Swagger: `<base-url>/docs`
{% endtab %}

{% tab title="Helm" %}
{% hint style="warning" %}
Same trip-up as the Registry Helm page: this deploys from `Sunbird-RC/devops`, not a `deployment` repo, and the credentialling charts live specifically at `deploy-as-code/helm/v2/credentialling`.
{% endhint %}

System requirements and prerequisites are the same as the Registry Helm setup, plus the [High-Level Architecture](https://rc.sunbird.org/learn/technical-overview/registry/high-level-architecture) page is worth a read first.

{% stepper %}
{% step %}

#### Clone the repo

```bash
git clone https://github.com/Sunbird-RC/devops.git
cd devops/deploy-as-code/helm/v2/credentialling
```

Pre-check and namespace creation: same commands as the Registry Helm flow.
{% endstep %}

{% step %}

#### Deploy Vault

Credentialling Services use HashiCorp Vault as the keystore. Follow [HashiCorp's Kubernetes Raft deployment guide](https://developer.hashicorp.com/vault/tutorials/kubernetes/kubernetes-raft-deployment-guide) in the same namespace you created above, then:

1. **Initialize** (first time only): `vault operator init` — save the unseal keys and root token securely. Base64-encode the root token as `VAULT_SECRET_TOKEN` in `values.yaml`.
2. **Unseal**: `vault operator unseal`, repeated with enough distinct unseal keys to reach the threshold (typically 3).
3. **Log in**: `vault login <root_token>`.
4. **Enable a KV engine**: `vault secrets enable -path=kv kv-v2` — whatever path you choose here must match `root_path: http://vault:8200/v1/kv` in `values.yaml`.
   {% endstep %}

{% step %}

#### Create secrets and deploy

In `values.yaml`, base64-encoded:

* `VAULT_SECRET_TOKEN` — the initial root token *(mandatory)*
* `DB_URL` — e.g. `postgres://{{username}}:{{password}}@localhost:5432/{{database_name:sunbirdrc}}` *(mandatory)*

```bash
helm upgrade --install --namespace=demo-registry demo-registry helm_charts --create-namespace
kubectl get pods -n demo-registry
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

## Service configuration

Environment variables passed to each credentialling service.

{% tabs %}
{% tab title="Identity Service" %}

| Env var            | Description                                                                       |
| ------------------ | --------------------------------------------------------------------------------- |
| `DATABASE_URL`     | `postgres://<username>:<password>@<db_url>:<db_port>/<db_name>`                   |
| `VAULT_ADDR`       | Address for the HashiCorp Vault, e.g. `http://<vault_address>:8200/v1`            |
| `VAULT_TOKEN`      | Vault API token                                                                   |
| `VAULT_ROOT_PATH`  | Vault root path for the key-value store, e.g. `http://<vault_address>:8200/v1/kv` |
| `VAULT_TIMEOUT`    | API timeout for Vault in ms (e.g. `5000`)                                         |
| `VAULT_PROXY`      | `false`                                                                           |
| `JWKS_URI`         | JWKS URI of the OAuth2 resource server for handling Bearer tokens                 |
| `ENABLE_AUTH`      | Enable/disable authentication (e.g. `false`)                                      |
| `WEB_DID_BASE_URL` | Base URL to generate a web-based DID                                              |

Supported signature suites: `Ed25519Signature2020`, `Ed25519Signature2018`, `RSASignature2018`.
{% endtab %}

{% tab title="Credential Schema Service" %}

| Env var             | Description                                                     |
| ------------------- | --------------------------------------------------------------- |
| `DATABASE_URL`      | `postgres://<username>:<password>@<db_url>:<db_port>/<db_name>` |
| (identity endpoint) | `http://identity-service:3332`                                  |
| `JWKS_URI`          | JWKS URI of the OAuth2 resource server                          |
| `ENABLE_AUTH`       | Enable/disable authentication                                   |
| {% endtab %}        |                                                                 |

{% tab title="Credential Issuance Service" %}

| Env var                       | Description                                                                                |
| ----------------------------- | ------------------------------------------------------------------------------------------ |
| `DATABASE_URL`                | `postgres://<username>:<password>@<db_url>:<db_port>/<db_name>`                            |
| `CREDENTIAL_SERVICE_BASE_URL` | Base URL for the credential service, used to set the verify URL in the QR code             |
| `JWKS_URI`                    | JWKS URI of the OAuth2 resource server                                                     |
| `ENABLE_AUTH`                 | Enable/disable authentication                                                              |
| `QR_TYPE`                     | Set to `W3C_VC` to embed a compressed VC in the QR code instead of a verify-credential URL |
| {% endtab %}                  |                                                                                            |
| {% endtabs %}                 |                                                                                            |


# For existing adopters

What's new, what changed, and how to upgrade an existing Sunbird RC deployment.

Already running Sunbird RC? This page brings together what you need before moving to a newer release: what's new, what changed, what stays compatible, and how to upgrade.

{% hint style="info" %}
**This page is being completed.** Some compatibility details are still being confirmed with the RC team. Rows marked **Being confirmed** are incomplete — check the release notes and ask on [GitHub Discussions](https://github.com/orgs/Sunbird-RC/discussions) before relying on them.
{% endhint %}

## What's new

**v2.1.0** adds the **OID4VC service**, which lets any standards-compliant wallet receive credentials through OpenID4VCI 1.0 and present them through OpenID4VP 1.0 (draft-23). The service is **opt-in**: it only runs when you enable the `oid4vc` profile, so an existing deployment keeps working as before until you turn it on.

The release also updates the runtime and dependencies of every service in the repository.

* [v2.1.0 release notes](https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release)
* [Wallet Integration](https://rc.sunbird.org/use/integrations/wallet-integration) — how the OID4VC service works with wallets

## What changed from v1 to v2

The biggest change between major versions is how the Registry signs credentials. From v2, the Registry can use either the legacy signer (Signature V1) or the Credentials services (Signature V2). You choose with the `signature_provider` setting.

|                      | Signature V1 (v1 and older)                                                     | Signature V2                                                                                                                    |
| -------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| **Signing keys**     | Created manually and placed in a config file before deploying                   | Created by the identity service when an issuer is created; the private key is held in HashiCorp Vault                           |
| **Adding a key**     | Add it to the file manually and redeploy                                        | Keys are created as needed                                                                                                      |
| **Signature suites** | `RsaSignature2018`                                                              | `Ed25519Signature2020`, `Ed25519Signature2018`, `RsaSignature2018`                                                              |
| **Services needed**  | certificate-signer, certificate-api                                             | identity, credential-schema, credentials, Vault                                                                                 |
| **Setting**          | `signature_provider=dev.sunbirdrc.registry.service.impl.SignatureV1ServiceImpl` | `signature_provider=dev.sunbirdrc.registry.service.impl.SignatureV2ServiceImpl`, plus the `did_*` and `signature_v2_*` settings |

For more on each option, see [Signature V1 or V2](https://rc.sunbird.org/use/developer-guide/working-with-source-code#signature-v1-or-v2).

## Compatibility

| Area                           | What changes                                                                                                                                            | Status          |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- |
| **Registry APIs**              | From v2, the list-entity and search APIs are paginated and return a different response structure from v1. Update any client that reads these responses. | Documented      |
| **Registry schemas**           | Schema versioning isn't supported. Adding or removing fields has to be managed outside Sunbird RC.                                                      | Documented      |
| **Keys and DIDs**              | After switching from Signature V1 to V2, new credentials are signed with keys held in Vault and use V2 DIDs.                                            | Documented      |
| **Credentials already issued** | Whether credentials issued under V1 can still be verified after switching to V2.                                                                        | Being confirmed |
| **Data**                       | Whether existing registry data needs migrating between releases.                                                                                        | Being confirmed |
| **Credential schemas**         | Whether existing credential schemas need changes between releases.                                                                                      | Being confirmed |
| **Deployment configuration**   | Which environment variables and settings change between releases.                                                                                       | Being confirmed |

## Upgrade steps (Docker Compose)

{% stepper %}
{% step %}

### Read the release notes

Check the release notes for every version between yours and the one you're moving to. See [Previous versions](#previous-versions) below.
{% endstep %}

{% step %}

### Back up your data

Back up your databases before upgrading. See [Backup and Restore](https://rc.sunbird.org/use/developer-guide/backup-and-restore).
{% endstep %}

{% step %}

### Update the release version

In your `.env` file, set `RELEASE_VERSION` to the new release tag, for example `v2.1.0`. Then pull the new images and restart:

```bash
docker compose pull
docker compose up -d
```

{% endstep %}

{% step %}

### Optional: enable the OID4VC service

```bash
docker compose --profile oid4vc up -d oid4vc-service
```

See [Wallet Integration](https://rc.sunbird.org/use/integrations/wallet-integration) for the settings it needs.
{% endstep %}

{% step %}

### Optional: switch from Signature V1 to V2

From the `sunbird-rc-core` folder, run:

```bash
bash enable-v2.sh
```

This brings up Vault, identity, credential-schema, credentials and claim-ms, and restarts the Registry with signing, DIDs and claims turned on.

{% hint style="warning" %}
Switching changes how new credentials are signed and which DIDs they use. Check the impact on credentials you have already issued before switching.
{% endhint %}
{% endstep %}
{% endstepper %}

{% hint style="info" %}
**Upgrading a Helm deployment?** Helm upgrade steps are being confirmed and will be added here.
{% endhint %}

## Previous versions

**Registry**

* [v2.0.3](https://rc.sunbird.org/use/releases/registry/v2.0.3)
* [v1.0.0](https://rc.sunbird.org/use/releases/registry/v1.0.0)

**Credentials**

* [v2.1.0](https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release)
* [v2.0.3](https://rc.sunbird.org/use/releases/credentialing/v2.0.3)
* [v2.0.0](https://rc.sunbird.org/use/releases/credentialing/v2.0.0)

All releases and changelogs are also on [GitHub](https://github.com/Sunbird-RC/sunbird-rc-core/releases).


# Developer Guide

Building on, configuring, and operating Sunbird RC.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Working with Source Code</strong></td><td>Compile and run the registry from <code>sunbird-rc-core</code>, and switch feature services on.</td><td><a href="https://rc.sunbird.org/use/developer-guide/working-with-source-code">Working with Source Code</a></td></tr><tr><td><strong>Environment Variable Reference</strong></td><td>Every registry-core and service environment variable, by service.</td><td><a href="https://rc.sunbird.org/use/developer-guide/environment-variable-reference">Environment Variable Reference</a></td></tr><tr><td><strong>Configuration Reference</strong></td><td>Frontend, proxy, audit, notification and view-template config files.</td><td><a href="https://rc.sunbird.org/use/developer-guide/configuration-reference">Configuration Reference</a></td></tr><tr><td><strong>Schema Setup</strong></td><td>Define entities, write schemas, and configure <code>_osConfig</code>.</td><td><a href="https://rc.sunbird.org/use/developer-guide/schema-setup">Schema Setup</a></td></tr><tr><td><strong>Setup Backend</strong></td><td>Where the repos, deployment files and schema directory live.</td><td><a href="https://rc.sunbird.org/use/developer-guide/setup-backend">Setup Backend</a></td></tr><tr><td><strong>Setup Frontend</strong></td><td>Run and configure the Angular registry UI.</td><td><a href="https://rc.sunbird.org/use/developer-guide/setup-frontend">Setup Frontend</a></td></tr><tr><td><strong>Backup and Restore</strong></td><td>PostgreSQL and Cassandra backup methods and restore paths.</td><td><a href="https://rc.sunbird.org/use/developer-guide/backup-and-restore">Backup and Restore</a></td></tr><tr><td><strong>Generic IAM</strong></td><td>Use any OAuth2-compliant identity layer, not just Keycloak.</td><td><a href="https://rc.sunbird.org/use/developer-guide/generic-iam">Generic IAM</a></td></tr><tr><td><strong>Metrics</strong></td><td>Emit and aggregate registry events via Kafka or file.</td><td><a href="https://rc.sunbird.org/use/developer-guide/metrics">Metrics</a></td></tr><tr><td><strong>Custom Keycloak Build</strong></td><td>Build the Sunbird RC Keycloak image with toggleable NONCE validation.</td><td><a href="https://rc.sunbird.org/use/developer-guide/custom-keycloak-build">Custom Keycloak Build</a></td></tr><tr><td><strong>VC Verification Module</strong></td><td>Drop-in QR scanning and VC verification for Angular frontends.</td><td><a href="https://rc.sunbird.org/use/developer-guide/vc-verification-module">VC Verification Module</a></td></tr></tbody></table>


# Working with Source Code

Use the `sunbird-rc-core` project — the `java` folder contains all the registry modules plus the claims service.

## Is this the right page for you?

This page is for building and running the **Registry** from source, for example to contribute code or to debug locally. Sunbird RC has two components, Registry and Credentials, which can be used on their own or together. Pick the path that matches what you need:

| You want to…                                      | Start here                                                                                                                                                   |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Try Sunbird RC quickly, without building anything | [Docker Compose Setup](https://rc.sunbird.org/use/getting-started/installation/docker-compose-setup)                                                         |
| Deploy to a cluster                               | [Helm Setup](https://rc.sunbird.org/use/getting-started/installation/helm-setup)                                                                             |
| Run only the Credentials services                 | [Credentialling Services setup (Dev / Docker / Helm)](https://rc.sunbird.org/use/getting-started/installation/credentialling-services-setup-dev-docker-helm) |
| Build and run the Registry from source            | This page                                                                                                                                                    |
| Use Registry and Credentials together from source | This page, then enable **Credentials (Signature V2)** under [Feature services](#feature-services)                                                            |

{% hint style="info" %}
**Already running Sunbird RC?** Read the release notes for the version you're moving to before rebuilding — [Credentials v2.1.0](https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release) and [Registry v2.0.3](https://rc.sunbird.org/use/releases/registry/v2.0.3). If your registry signs with the legacy signer, see **Signature V1 or V2** below before changing any signature settings.
{% endhint %}

{% hint style="info" %}
**Java version**: JDK 11
{% endhint %}

{% stepper %}
{% step %}

### Compile the registry

```bash
$ sh configure-dependencies.sh
$ cd java
$ ./mvnw clean install -DskipTests
$ cd ..
```

This produces a JAR in `java/registry/target`.
{% endstep %}

{% step %}

### Configure schemas

Create a `_schemas/` folder at `java/registry/src/main/resources/public/` and place your schema files there. A sample student-teacher schema set is available in the [registry-cli templates](https://github.com/Sunbird-RC/registry-cli/tree/main/src/templates/config/schemas). See [Creating Your Own Schemas](https://rc.sunbird.org/use/developer-guide/schema-setup/creating-your-own-schemas) to write your own.
{% endstep %}

{% step %}

### Install dependencies and run

1. `cd java`
2. `./mvnw clean install`
3. Set up the database and any feature-dependent services (see **Feature services** below)
4. Set the minimum required env vars: `connectionInfo_uri`, `connectionInfo_username`, `connectionInfo_password`, `authentication_enabled` — variables starting with `connectionInfo_` configure the database (see [Environment Variable Reference](https://rc.sunbird.org/use/developer-guide/environment-variable-reference)); check `docker-compose.yml`'s `registry` service for examples.
5. `cd` to the `registry` package, export the env vars, run `../mvnw spring-boot:run`
   {% endstep %}

{% step %}

### Start the dependent services

```bash
$ curl https://raw.githubusercontent.com/Sunbird-RC/registry-cli/main/src/templates/docker-compose.yml > docker-compose.yml
$ curl https://raw.githubusercontent.com/Sunbird-RC/registry-cli/main/src/templates/config/keycloak/realm-export.json > imports/realm-export.json
$ docker-compose up kc db es cs
```

This starts Keycloak (`kc`), Postgres (`db`), ElasticSearch (`es`), and the Claims Service (`cs`).
{% endstep %}

{% step %}

### Configure the Keycloak secret

1. Go to `http://localhost:8080/auth/admin/master/console/#/realms`
2. Log in as `admin` / `admin`
3. Click **Sunbird RC** → **Clients** → **admin-api** → **Credentials** tab
4. Copy the secret

Then set the frontend URL in Keycloak to whatever URL you use to generate tokens (e.g. `http://localhost:8080/auth`): log in to the Keycloak UI, select realm `sunbird-rc`, and set it under General settings → frontend URL.

{% hint style="warning" %}
Update the frontend URL whenever the deploy DNS changes.
{% endhint %}
{% endstep %}

{% step %}

### Run the registry

```bash
$ java -jar java/registry/target/registry.jar
```

{% endstep %}
{% endstepper %}

## Feature services

Most can run via the project's `docker-compose.yml` for local dev. Enable or disable each with its own flag:

| Service                      | Flag                                                                      | Notes                                                                                                                                                                                                                                                                               |
| ---------------------------- | ------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Encryption Service           | `encryption_enabled=true`                                                 | —                                                                                                                                                                                                                                                                                   |
| ID Gen Service               | `idgen_enabled=true`                                                      | —                                                                                                                                                                                                                                                                                   |
| Credentials (Signature V2)   | `signature_enabled=true`, `did_enabled=true`, `certificate_enabled=true`  | Also set `signature_provider=dev.sunbirdrc.registry.service.impl.SignatureV2ServiceImpl`; the other `signature_v2_*`/`did_*` envs default correctly in `docker-compose.yml`. `certificate_enabled` is what generates PDFs. Use this when running Registry and Credentials together. |
| Legacy signer (Signature V1) | `signature_enabled=true`                                                  | Uses `signature_provider=dev.sunbirdrc.registry.service.impl.SignatureV1ServiceImpl`, which is the registry's default. Configure with `sign_url`, `verify_url`, `keys_url` and `sign_health_check_url`.                                                                             |
| Keycloak Service             | `authentication_enabled=true`                                             | Plus `enableLogin` in the schema; check envs starting with `sunbird_sso_`, `sunbird_keycloak`, `oauth2_resource_`                                                                                                                                                                   |
| ElasticSearch Service        | `search_providerName=dev.sunbirdrc.registry.service.ElasticSearchService` | Supports v6; configure with `elastic_search_*` envs                                                                                                                                                                                                                                 |
| Claims Service               | `claims_enabled=true`                                                     | —                                                                                                                                                                                                                                                                                   |
| File Storage Service         | `filestorage_enabled=true`                                                | Configure with `filestorage_*` envs; backed by Minio (S3-compatible cloud storage or a local Minio instance)                                                                                                                                                                        |
| Kafka & Zookeeper            | —                                                                         | Needed for `async_enabled`, `event_enabled`, or `notification_enabled`/`notification_async_enabled`                                                                                                                                                                                 |
| Metrics Service              | `event_enabled=true`                                                      | Configure with `event_*` envs                                                                                                                                                                                                                                                       |
| Notification Service         | `notification_enabled=true`                                               | Configure with `notification_*` envs                                                                                                                                                                                                                                                |
| Redis Service                | `manager_type=DistributedDefinitionsManager`                              | Configure with `redis_*` envs                                                                                                                                                                                                                                                       |

## Signature V1 or V2

The registry can sign credentials in two ways:

* **Signature V1 (legacy signer)** — the registry's built-in default. Use this if you run the Registry on its own with an existing V1 signer.
* **Signature V2 (Credentials)** — the registry hands signing and DIDs to the Credentials services. The project's `docker-compose.yml` defaults to V2, and `enable-v2.sh` switches an existing setup over.

{% hint style="warning" %}
**Existing adopters:** switching from V1 to V2 changes how new credentials are signed and which DIDs they use. Check the impact on credentials you have already issued before switching.
{% endhint %}

{% hint style="danger" %}
**Troubleshooting — Prisma migration issue.** Happens when Prisma migration tables aren't set and the database isn't empty.

* If you can wipe the database, do so and set up the identity service first.
* In production (or wherever cleanup isn't possible), [baseline the database](https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining) and restart the identity, credential-schema, and credential services.
  {% endhint %}


# Environment Variable Reference

The Registry exposes its behavior almost entirely through environment variables. This is the full property reference — kept separate from the [Configuration Reference](https://rc.sunbird.org/use/developer-guide/configuration-reference), which covers the frontend/proxy/audit/notification/view-template config *files* rather than registry-core env vars.

{% hint style="warning" %}
The **Certificate Api service** and **Certificate signer service** sections below still document `certificate-api` and `certificate-signer` by name. These services no longer exist in the current `services/` directory — certificate generation has moved into the core registry. Treat those env vars as historical until confirmed against the current signing/certificate implementation.
{% endhint %}

## Registry

| Property                                                                                                                                 | Description                                                                                                                   |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `notification_enabled`                                                                                                                   | boolean — whether notifications are sent                                                                                      |
| `notification_url`                                                                                                                       | URL used to send notifications                                                                                                |
| `notification_async_enabled`                                                                                                             | send notifications asynchronously                                                                                             |
| `notification_topic`                                                                                                                     | if async, the Kafka topic notification events are sent to                                                                     |
| `registry_perRequest_indexCreation_enabled`                                                                                              | boolean — whether an index needs to be created at the database level                                                          |
| `external_entities`                                                                                                                      | comma-separated list of external entities                                                                                     |
| `workflow.enable`                                                                                                                        | boolean — enable/disable the workflow (attestation policy)                                                                    |
| `async_enabled`                                                                                                                          | create entities asynchronously                                                                                                |
| `kafka_create_entity_topic`                                                                                                              | if async, the topic new async create requests are pushed to                                                                   |
| `kafka_post_create_entity_topic`                                                                                                         | if async, the topic the create-entity response is pushed to                                                                   |
| `search_offset`                                                                                                                          | default search offset                                                                                                         |
| `search_limit`                                                                                                                           | default/max search result limit                                                                                               |
| `search_expandInternal`                                                                                                                  | boolean — expand search results to include internal objects                                                                   |
| `database_provider`                                                                                                                      | which database to use — `NEO4J`, `SQLG`, `CASSANDRA`, `ORIENTDB`, or `TINKERGRAPH` (in-memory)                                |
| `connectionInfo_uri`                                                                                                                     | DB connection URL, e.g. `jdbc:postgresql://localhost:5432/yourdb`                                                             |
| `connectionInfo_username`                                                                                                                | DB username                                                                                                                   |
| `connectionInfo_password`                                                                                                                | DB password                                                                                                                   |
| `connectionInfo_maxPoolSize`                                                                                                             | DB connection pool size                                                                                                       |
| `verify_url`                                                                                                                             | URL to verify an issued VC — point at `{certificate_signer}/verify`                                                           |
| `certificate_health_check_url`                                                                                                           | certificate API service health-check URL                                                                                      |
| `audit_enabled`                                                                                                                          | enable audit logging                                                                                                          |
| `audit_frame_store`                                                                                                                      | `FILE` (store logs in files) or `DATABASE` (store in the primary DB, and ElasticSearch if enabled)                            |
| `audit_suffix`                                                                                                                           | suffix appended to the schema name to store audit info per entity type                                                        |
| `audit_suffixSeparator`                                                                                                                  | separator between entity name and `audit_suffix`                                                                              |
| `validation_enabled`                                                                                                                     | boolean — validate request body against a specific format                                                                     |
| `validation_type`                                                                                                                        | format to validate against, e.g. `JSON`                                                                                       |
| `service_connection_timeout`                                                                                                             | connection timeout (ms) for the underlying request config                                                                     |
| `service_connection_request_timeout`                                                                                                     | timeout (ms) when requesting a connection from the connection manager                                                         |
| `service_read_timeout`                                                                                                                   | socket read timeout (ms)                                                                                                      |
| `http_max_connections`                                                                                                                   | max HTTP connections                                                                                                          |
| `taskExecutor_index_threadPoolName`                                                                                                      | thread name prefix for the index task executor                                                                                |
| `taskExecutor_index_corePoolSize`                                                                                                        | core pool size                                                                                                                |
| `taskExecutor_index_maxPoolSize`                                                                                                         | max pool size                                                                                                                 |
| `taskExecutor_index_queueCapacity`                                                                                                       | `BlockingQueue` capacity                                                                                                      |
| `auditTaskExecutor_threadPoolName`                                                                                                       | thread name prefix for the audit task executor                                                                                |
| `auditTaskExecutor_corePoolSize`                                                                                                         | core pool size                                                                                                                |
| `auditTaskExecutor_maxPoolSize`                                                                                                          | max pool size                                                                                                                 |
| `auditTaskExecutor_queueCapacity`                                                                                                        | `BlockingQueue` capacity                                                                                                      |
| `elastic_search_connection_url`                                                                                                          | ElasticSearch connection URL (used when `search_providerName` enables it)                                                     |
| `search_providerName`                                                                                                                    | `NativeSearchService` (writes DB doubles as search) or `ElasticSearchService` (default if unset is Native)                    |
| `sunbird_sso_realm`                                                                                                                      | identity-provider realm name                                                                                                  |
| `sunbird_sso_url`                                                                                                                        | identity-provider connection URL                                                                                              |
| `sunbird_sso_admin_client_id`                                                                                                            | admin client ID                                                                                                               |
| `sunbird_sso_admin_client_secret`                                                                                                        | secret for the above admin client                                                                                             |
| `sunbird_keycloak_user_set_password`                                                                                                     | boolean — set a default password for new entity owners                                                                        |
| `sunbird_keycloak_user_password`                                                                                                         | the default password, if the above is true                                                                                    |
| `identity_user_actions`                                                                                                                  | identity-provider actions to trigger, e.g. `VERIFY_EMAIL`, `UPDATE_PROFILE`, `UPDATE_PASSWORD`, `TERMS_AND_CONDITIONS`        |
| `identity_provider`                                                                                                                      | implementation class — `dev.sunbirdrc.auth.genericiam.AuthProviderImpl` or `dev.sunbirdrc.auth.keycloak.KeycloakProviderImpl` |
| `oauth2_resource_uri`                                                                                                                    | identity-provider resource URL, e.g. `http://keycloak:8080/auth/realms/sunbird-rc`                                            |
| `oauth2_resource_email_path`                                                                                                             | JWT path to email, e.g. `email`                                                                                               |
| `oauth2_resource_consent_path`                                                                                                           | JWT path to consent, e.g. `consent`                                                                                           |
| `oauth2_resource_roles_path`                                                                                                             | JWT path to roles, e.g. `realm_access.roles`                                                                                  |
| `oauth2_resource_entity_path`                                                                                                            | JWT path to entity, e.g. `entity`                                                                                             |
| `oauth2_resource_user_id_path`                                                                                                           | JWT path to user id, e.g. `sub`                                                                                               |
| `claims_enabled`                                                                                                                         | default `false` — whether attestation is enabled                                                                              |
| `claims_url`                                                                                                                             | claims service URL                                                                                                            |
| `did_enabled`                                                                                                                            | enable the DID service (required for signature v2)                                                                            |
| `did_health_check_url` / `did_generate_url` / `did_resolve_url`                                                                          | DID service endpoints                                                                                                         |
| `signature_enabled`                                                                                                                      | whether documents get signed                                                                                                  |
| `signature_provider`                                                                                                                     | `dev.sunbirdrc.registry.service.impl.SignatureV1ServiceImpl` or `...SignatureV2ServiceImpl`                                   |
| `signature_v2_credential_did_method`                                                                                                     | DID method for the credential's id                                                                                            |
| `signature_v2_issuer_did_method`                                                                                                         | DID method for the issuer DID                                                                                                 |
| `signature_v2_schema_author`                                                                                                             | credential schema author name                                                                                                 |
| `signature_v2_schema_author_did_method`                                                                                                  | DID method for the schema author                                                                                              |
| `signature_v2_health_check_url` / `_issue_url` / `_get_url` / `_delete_url` / `_verify_url` / `_verify_any_url` / `_revocation_list_url` | SignatureV2 service endpoints                                                                                                 |
| `signature_v2_schema_health_check_url` / `_create_url` / `_update_url` / `_get_by_id_and_version_url` / `_search_by_tags_url`            | SignatureV2 credential-schema endpoints                                                                                       |
| `sign_url` / `sign_health_check_url`                                                                                                     | certificate signer endpoints                                                                                                  |
| `certificate_enabled`                                                                                                                    | default `false` — whether certificates are generated                                                                          |
| `pdf_url`                                                                                                                                | URL to fetch the certificate from the certificate API service                                                                 |
| `template_base_url`                                                                                                                      | endpoint for default templates stored in Sunbird RC                                                                           |
| `filestorage_enabled`                                                                                                                    | default `false` — whether documents are stored                                                                                |
| `filestorage_connection_url` / `_access_key` / `_secret_key` / `_bucket_key`                                                             | Minio connection details                                                                                                      |
| `registry_base_apis_enable`                                                                                                              | enables the legacy `/add` `/update` APIs for backward compatibility                                                           |
| `logging.level.root`                                                                                                                     | log level — `INFO` (default), `DEBUG`, `WARN`, `ERROR`                                                                        |
| `enable_external_templates`                                                                                                              | boolean — allow certificate PDFs via external templates                                                                       |
| `authentication_enabled`                                                                                                                 | enable authentication system-wide                                                                                             |
| `kafka_bootstrap_address`                                                                                                                | Kafka connection URL                                                                                                          |
| `webhook_enabled`                                                                                                                        | enable webhooks (requires `async_enabled`)                                                                                    |
| `webhook_url`                                                                                                                            | URL the caller can retrieve created-entity info from once generated                                                           |
| `redis_host` / `redis_port`                                                                                                              | Redis connection                                                                                                              |
| `manager_type`                                                                                                                           | `DefinitionsManager` (single instance) or `DistributedDefinitionsManager`                                                     |
| `service_retry_maxAttempts` / `service_retry_backoff_delay`                                                                              | retry attempts and backoff interval (ms) when reaching a dependent service                                                    |
| `event_enabled`                                                                                                                          | emit events on ADD/UPDATE/DELETE/READ                                                                                         |
| `event_topic`                                                                                                                            | Kafka topic events are emitted to                                                                                             |
| `encryption_enabled`                                                                                                                     | default `false` — encrypt private fields at storage (requires an external encryption service)                                 |
| `encryption_health_check_url` / `encryption_uri` / `encryption_batch_uri` / `decryption_uri` / `decryption_batch_uri`                    | encryption service endpoints                                                                                                  |
| `encryption_tenant_id`                                                                                                                   | tenant id for encryption                                                                                                      |
| `idgen_enabled`                                                                                                                          | enable/disable ID generation                                                                                                  |
| `idgen_tenant_id`                                                                                                                        | tenant id for ID generation                                                                                                   |
| `idgen_health_check_url` / `idgen_generate_url` / `idgen_id_format_url`                                                                  | ID-gen service endpoints                                                                                                      |
| `swagger_enabled`                                                                                                                        | default `true` — enable/disable Swagger                                                                                       |
| `swagger_title` / `swagger_description` / `swagger_version`                                                                              | custom Swagger metadata                                                                                                       |

## Claims Service

| Property        | Description                                                     |
| --------------- | --------------------------------------------------------------- |
| `sunbirdrc_url` | URL (host + port) the claims service uses to reach the registry |

## Certificate Api Service

| Property                 | Description                                                                               |
| ------------------------ | ----------------------------------------------------------------------------------------- |
| `QR_TYPE`                | `W3C-VC`, `URL-W3C-VC` (VC sent as a URL), or `URL` (QR contains only entity name + osid) |
| `CERTIFICATE_DOMAIN_URL` | base URL used when `QR_TYPE` is `URL`                                                     |

## Certificate Signer Service

| Property             | Description                                               |
| -------------------- | --------------------------------------------------------- |
| `CACHE_CONTEXT_URLS` | context URLs to pre-cache, avoiding runtime network calls |
| `CONFIG_BASE_PATH`   | path to the `config.json` holding the signing keys        |

## Notification Service

| Property                  | Description                                  |
| ------------------------- | -------------------------------------------- |
| `KAFKA_BOOTSTRAP_SERVERS` | Kafka bootstrap servers (`host:port`)        |
| `SMS_AUTH_KEY`            | authorization key for the SMS API            |
| `ENABLE_SMS`              | enable sending SMS                           |
| `TRACK_NOTIFICATIONS`     | track sent notifications for later retrieval |

## Metrics Service

<table data-search="false"><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>CLICK_HOUSE_URL</code></td><td>Clickhouse URL + port</td></tr><tr><td><code>CLICKHOUSE_DATABASE</code></td><td>database name events are stored in</td></tr><tr><td><code>KAFKA_BOOTSTRAP_SERVERS</code></td><td>Kafka URL + port</td></tr><tr><td><code>KAFKA_METRICS_TOPIC</code></td><td>topic the registry publishes events to</td></tr><tr><td><code>DATABASE_PROVIDER_NAME</code></td><td>e.g. <code>clickhouse</code></td></tr><tr><td><code>REDIS_URL</code></td><td>Redis host</td></tr><tr><td><code>CRON_ENABLE</code></td><td>run the aggregation cron job</td></tr><tr><td><code>SCHEDULE_INTERVAL</code></td><td>days between cron runs</td></tr><tr><td><code>SCHEDULE_TIME</code></td><td>time (GMT) to run the cron job</td></tr></tbody></table>

## Bulk Issuance Service

| Property                                                                                    | Description         |
| ------------------------------------------------------------------------------------------- | ------------------- |
| `REGISTRY_BASE_URL`                                                                         | registry host       |
| `DATABASE_HOST` / `DATABASE_PORT` / `DATABASE_USER` / `DATABASE_PASSWORD` / `DATABASE_NAME` | database connection |
| `KEYCLOAK_PUBLIC_KEY` / `KEYCLOAK_URL` / `KEYCLOAK_REALM`                                   | Keycloak connection |

## Digilocker Certificate API

<table data-search="false"><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>DIGILOCKER_HMAC_AUTHKEY</code></td><td>random string used to verify the request HMAC — this is DigiLocker's API key</td></tr><tr><td><code>DIGILOCKER_AUTH_KEYNAME</code></td><td>header name to read the HMAC from (default <code>x-digilocker-hmac</code>)</td></tr><tr><td><code>DIGILOCKER_DOC_ID_PREFIX</code></td><td>document prefix sent in the response, mapping to the correct DigiLocker document (varies per issuer)</td></tr><tr><td><code>KEYCLOAK_TOKEN_URL</code></td><td>Keycloak connection URL</td></tr><tr><td><code>KEYCLOAK_CLIENT_SECRET</code></td><td>secret for the admin client</td></tr><tr><td><code>KEYCLOAK_CLIENT_ID</code></td><td>admin client id</td></tr><tr><td><code>REGISTRY_URL</code></td><td>registry URL</td></tr></tbody></table>

## Encryption Service

Enable via `.env`: `ENCRYPTION_ENABLED=true`

| Property                                      | Description                                                     |
| --------------------------------------------- | --------------------------------------------------------------- |
| `server.port`                                 | port to run on                                                  |
| `server.servlet.context-path`                 | context path                                                    |
| `spring.datasource.url` / `spring.flyway.url` | DB connection, e.g. `jdbc:postgresql://localhost:5432/yourdb`   |
| `spring.flyway.baseline-on-migrate`           | boolean — handle migration versioning                           |
| masterDataProvider                            | `org.egov.enc.masterdata.provider.WebServiceMasterDataProvider` |

## ID Gen Service

Enable via `.env`: `IDGEN_ENABLED=true`. Also see `uniqueIdentifierFields` in [Schema Configuration](https://rc.sunbird.org/use/developer-guide/schema-setup/schema-configuration).

| Property                            | Description                                                    |
| ----------------------------------- | -------------------------------------------------------------- |
| `spring.datasource.url`             | DB connection                                                  |
| `spring.flyway.baseline-on-migrate` | boolean — migration versioning                                 |
| `idformat.from.mdms`                | boolean — fetch id format from MDMS                            |
| masterDataProvider                  | `org.egov.id.masterdata.provider.WebServiceMasterDataProvider` |


# Configuration Reference

The config files behind the frontend, proxy, audit, notification and view-template behavior. For registry-core environment variables, see the [Environment Variable Reference](https://rc.sunbird.org/use/developer-guide/environment-variable-reference).

{% tabs %}
{% tab title="Frontend" %}
Edit `config.json` and update the values below for your deployment.

| Key             | Purpose                                                                                                                      |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `keycloak`      | Keycloak config object: `url` (`domainUrl/auth`), `clientId` (`registry-frontend`), `realm` (`sunbird-rc`)                   |
| `baseUrl`       | your API base URL, e.g. `domainUrl/registry/api/v1`                                                                          |
| `domainName`    | your site's domain, e.g. `https://demo-url.xiv.in`                                                                           |
| `schemaUrl`     | swagger API URL, e.g. `domainUrl/registry/api/docs/swagger.json`                                                             |
| `footerText`    | footer label text                                                                                                            |
| `languages`     | language codes for multilingual support — add translation files under `src/assets/i18n/global/` and `src/assets/i18n/local/` |
| `default_theme` | theme color / site logo object                                                                                               |
| {% endtab %}    |                                                                                                                              |

{% tab title="Proxy" %}
Needed to avoid CORS issues when running locally.

{% stepper %}
{% step %}

#### Create the config file

Create a `proxy.conf.json` in the project root if it doesn't exist.
{% endstep %}

{% step %}

#### Add the proxy config for your API endpoints

{% code title="proxy.conf.json" %}

```json
{
  "/registry/api/docs": {
    "target": "https://domain_name/",
    "secure": false,
    "changeOrigin": true,
    "logLevel": "debug"
  }
}
```

{% endcode %}
{% endstep %}

{% step %}

#### Start with the proxy

```bash
npm start
# or
ng serve --proxy-config proxy.conf.json
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Audit" %}
Sunbird RC logs schema-level `ADD`/`READ`/`UPDATE`/`DELETE`/`SEARCH` operations. Two logging modes:

| Mode       | Where logs go                                                     | Requires                                                                                                                                                                                                             |
| ---------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FILE`     | Files, with a 30 MB rolling policy                                | —                                                                                                                                                                                                                    |
| `DATABASE` | The configured primary database, and ElasticSearch too if enabled | An audit schema, per [`raw_audit_schema.json`](https://github.com/Sunbird-RC/sunbird-rc-core/blob/main/java/registry/src/main/resources/raw_audit_schema.json), placed in the registry's configured schema directory |

Toggle via `audit_enabled`; see `audit_frame_store`, `audit_suffix`, `audit_suffixSeparator` in the [Environment Variable Reference](broken://pages/NsJ5yoaHhT6KFQfHVTnq).
{% endtab %}

{% tab title="Notifications" %}
Sunbird RC can notify an entity's owner on Invite/Create/Modify/Delete/Revoke. Configure notification templates per schema, per operation: `create`, `update`, `invite`, `delete`, `revoke` — each a list, so multiple templates per operation are supported.

Both email (`subject` + `body`) and SMS (`body` only) are supported. Delivery is either:

| Mode                 | How it works                                                                                                               |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------- |
| Asynchronous (Kafka) | The registry publishes a message to the configured topic; the notification service consumes it and sends the notification. |
| Synchronous (API)    | The registry calls the notification service directly.                                                                      |

The Notification Service itself expects SMS/SMTP gateway config — see its env vars in the [Environment Variable Reference](broken://pages/NsJ5yoaHhT6KFQfHVTnq).
{% endtab %}

{% tab title="View Templates" %}
View templates are JSON transformers applied to entity responses at runtime — they can rename/hide fields, evaluate JEXL expressions, and call custom provider functions.

{% code title="person\_view\_template.json" %}

```json
{
  "id": "personDefaultView1",
  "subject": "Person",
  "fields": [
    { "name": "firstName", "title": "NAME" },
    { "name": "lastName", "display": true },
    { "name": "nationalIdentifier", "title": "OS number", "display": false },
    { "title": "Name in passport", "function": "#/functionDefinitions/concat($lastName, $firstName)" },
    { "title": "Name as in DL", "function": "#/functionDefinitions/userDefinedConcat($firstName, $lastName)" }
  ],
  "functionDefinitions": [
    { "name": "concat", "result": "arg1 + \", \" + arg2" },
    { "name": "userDefinedConcat", "provider": "dev.sunbirdrc.provider.SampleViewFunctionProvider" }
  ]
}
```

{% endcode %}

Applied to:

```json
{ "Person": { "nationalIdentifier": "nid823", "firstName": "Ram", "lastName": "Moorthy", "gender": "MALE", "dob": "1990-12-10" } }
```

...produces:

```json
{ "Person": { "NAME": "Ram", "lastName": "Moorthy", "Name in passport": "Moorthy, Ram", "Name as in DL": "Ram : Moorthy" } }
```

Fields default to `"display": true`; set `"display": false` to hide a field while still keeping it available for internal referencing (e.g. `nationalIdentifier` above).

**Applying a template** — to GET APIs (Get An Entity, Get An Entity By Id) via a `viewTemplateId` header:

```bash
curl --location 'localhost:8081/api/v1/StudentWithPassword/1-2ee0c034-0a81-4c7f-a971-058af35911cb' \
  --header 'viewTemplateId: student_view_template.json'
```

...and to search/discovery APIs via the request body:

```json
{ "filters": { }, "viewTemplateId": "student_view_template.json" }
```

{% endtab %}
{% endtabs %}


# Schema Setup

Entities in Sunbird RC are defined by JSON schemas. Start with the concepts, then write your own.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Introduction To Schemas</strong></td><td>What an entity is, using the sample Teacher and Student schemas.</td><td><a href="broken://pages/b57wrqeqEwOSp3G6spul">Broken link</a></td></tr><tr><td><strong>Creating Your Own Schemas</strong></td><td>Write a schema, drop it in, and restart the registry.</td><td><a href="broken://pages/1pD1ancxYXe7OwtQxmrl">Broken link</a></td></tr><tr><td><strong>Schema Configuration</strong></td><td>The <code>_osConfig</code> block: visibility, indexes, roles, attestation, templates.</td><td><a href="broken://pages/aHPmnDhOUX38jkvv5g50">Broken link</a></td></tr><tr><td><strong>Create Schemas With Custom Password</strong></td><td>Let entities set their own password at invite time.</td><td><a href="broken://pages/beFNDrOe0KpjrJe8Urof">Broken link</a></td></tr></tbody></table>


# Introduction To Schemas

Each registry stores data as entities. The example registry set up via the CLI already has two entity types: `Teacher` and `Student`. View them with:

```bash
$ cat config/schemas/student.json
$ cat config/schemas/teacher.json
```

Or view the samples on [Github](https://github.com/Sunbird-RC/registry-cli/tree/main/src/templates/config/schemas).

| Entity      | Fields                                              | Required                                 |
| ----------- | --------------------------------------------------- | ---------------------------------------- |
| **Teacher** | `name`, `phoneNumber`, `email`, `subject`, `school` | `name`, `phoneNumber`, `email`, `school` |
| **Student** | `name`, `phoneNumber`, `email`, `school`            | all four                                 |

`subject` on a Teacher is one of Math, Hindi, English, History, Geography, Physics, Chemistry, Biology.

{% hint style="info" %}
Setting `school` on a Student makes a claim — that the student attends that school — which can be attested by a teacher from the same school.
{% endhint %}


# 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 %}


# Schema Configuration

Sunbird RC uses standard JSON-LD schemas. Example — a `Place` concept with `name`, `city`, `addressRegion`, `country`:

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

```json
{
  "$schema": "http://json-schema.org/draft-07/schema",
  "type": "object",
  "properties": { "Place": { "$ref": "#/definitions/Place" } },
  "required": ["Place"],
  "title": "Place",
  "definitions": {
    "Place": {
      "$id": "#/properties/Place",
      "type": "object",
      "required": ["name", "city", "addressRegion", "country"],
      "properties": {
        "name": { "type": "string" },
        "city": { "type": "string" },
        "addressLocality": { "type": "string" },
        "addressRegion": { "type": "string" },
        "country": { "type": "string" },
        "postalCode": { "type": "string" },
        "contact": { "type": "string" },
        "email": { "type": "string" }
      }
    }
  }
}
```

{% endcode %}

## `_osConfig` extensions

Access, indexing, and primary-key behavior beyond plain JSON-LD.

| Key                                          | What it does                                                                                                                    |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| `privateFields`                              | Visible to the owner and consenting third parties                                                                               |
| `internalFields`                             | Never exposed to any actor                                                                                                      |
| `systemFields`                               | `osCreatedAt`, `osUpdatedAt`, `osCreatedBy`, `osUpdatedBy`, `_osClaimId`, `_osCredentialId`, `_osSignedData`, `_osAttestedData` |
| `indexFields`                                | Index field set for faster lookups                                                                                              |
| `uniqueIndexFields`                          | Primary keys — enforces uniqueness                                                                                              |
| `roles` / `inviteRoles`                      | Gate CRUD and invite operations by Keycloak role; either can be `"anonymous"` for open access                                   |
| `ownershipAttributes`                        | Email/mobile/userId/password JSON paths, with `enableLogin: true`                                                               |
| `attestationPolicies`                        | List of attestation policies (see below)                                                                                        |
| `credentialTemplate`                         | W3C-compliant VC template, inline object or external URL                                                                        |
| `certificateTemplates.svg`                   | The visual-certificate template                                                                                                 |
| `PrivateFieldConfig` / `InternalFieldConfig` | How private/internal fields get emitted                                                                                         |
| `uniqueIdentifierFields`                     | Auto-generated formatted IDs (see below)                                                                                        |

Property types are String, Enum, Number, Integer, Object, Array, Boolean — see [type-specific keywords](https://json-schema.org/understanding-json-schema/reference/type).

Notification templates are configured per-schema, per-operation (`create`/`invite`/`update`/`delete`/`revoke`).


# 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 %}


# Setup Backend

<a href="https://github.com/Sunbird-RC" class="button primary" data-icon="github">Sunbird RC on GitHub</a> <a href="https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/helm" class="button secondary" data-icon="github">Deployment files</a>

| What                        | Where                                                                                                                                                                                              |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Backend repos               | [github.com/Sunbird-RC](https://github.com/Sunbird-RC)                                                                                                                                             |
| Kubernetes deployment files | [`Sunbird-RC/devops`](https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/helm), with the [README here](https://github.com/Sunbird-RC/devops/blob/main/deploy-as-code/helm/v1/README.md) |
| Schemas                     | [`sunbird-rc-core/java/registry/src/main/resources/public/_schemas`](https://github.com/Sunbird-RC/sunbird-rc-core/tree/main/java/registry/src/main/resources/public/_schemas)                     |

{% hint style="info" %}
The `_schemas` directory doesn't show up in a GitHub file browse — git doesn't track empty directories — but it's the live default `SCHEMA_DIR` mount point in `docker-compose.yml`. You're expected to populate it yourself.
{% endhint %}


# Setup Frontend

Get the latest code from the Sunbird RC UI repository — an **Angular 10** project. Install dependencies and run.

<a href="https://github.com/Sunbird-RC/sunbird-rc-ui" class="button primary" data-icon="github">Sunbird RC/sunbird-rc-ui</a>

## Configuration

Example config lives in `src/examples`. Key pieces:

* API base URL / schema URL for your deployment
* `forms.json` in `src/assets/config` — defines form schemas per entity, built on [formly.dev](https://formly.dev/)

| `forms.json` key                      | Contains                               |
| ------------------------------------- | -------------------------------------- |
| `fields`                              | name, class, required, disabled        |
| `layout`                              | api, title                             |
| `blocks`                              | definition, title, add, edit, multiple |
| `fields.includes` / `fields.excludes` | Response field filtering               |

## Proxy configuration

To avoid CORS locally:

```bash
npm start
# or
ng serve --proxy-config proxy.conf.json
```

## Hosting the frontend

As a container (image built from the Angular build output), on a VM, or from blob storage (e.g. S3 behind a CDN).


# Backup and Restore

Sunbird RC can connect to a range of data sources, as covered in [the High-Level Architecture page](https://rc.sunbird.org/registry).

{% hint style="warning" %}
Beyond the primary database, also plan backups for Kafka, ElasticSearch, and Filestore if you use them.
{% endhint %}

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>PostgreSQL</strong></td><td>SQL dump, file-system-level backup, and continuous archiving with PITR.</td><td><a href="broken://pages/pNVtxcZ6eK1ynS7NtCxl">Broken link</a></td></tr><tr><td><strong>Cassandra</strong></td><td>Snapshot and incremental backups, plus the two restore methods.</td><td><a href="broken://pages/oYUi2uPVJrcBn6onLvOd">Broken link</a></td></tr></tbody></table>


# PostgreSQL

Three backup methods, each with different tradeoffs.

| Method                      | Server downtime | Selective restore       | Portable across versions |
| --------------------------- | --------------- | ----------------------- | ------------------------ |
| SQL dump                    | No              | Yes (custom format)     | Yes                      |
| File-system-level           | Yes (full stop) | No — whole cluster only | No                       |
| Continuous archiving (PITR) | No              | Point-in-time           | No                       |

{% tabs %}
{% tab title="SQL Dump" %}

```bash
pg_dump dbname > dumpfile      # backup
psql dbname < dumpfile         # restore
```

`pg_dump` produces an internally-consistent snapshot and is portable across PostgreSQL versions and architectures; it can run against a remote host with read access to the tables being backed up.

For restore, create the target database and ensure the relevant users exist first. `psql` continues past SQL errors by default — set `ON_ERROR_STOP` to change that:

```bash
psql --set ON_ERROR_STOP=on dbname < dumpfile
```

Pipe directly between servers:

```bash
pg_dump -h host1 dbname | psql -h host2 dbname
```

{% endtab %}

{% tab title="File System Level" %}

```bash
tar -cf backup.tar /usr/local/pgsql/data
```

{% hint style="warning" %}
Limitations versus `pg_dump`: the server must be fully stopped for a usable backup (not just disallowing new connections), and you can't selectively restore individual tables — it's whole-cluster only, and the commit log files (`pg_xact/*`) must travel with the data files.
{% endhint %}

An alternative is a filesystem-level consistent snapshot (if your filesystem supports it) — snapshot the volume, copy the data directory out, release the snapshot. This allows backing up while the server runs, but starting from that backup triggers WAL replay as if the server had crashed, so the WAL files must be included (and a `CHECKPOINT` beforehand shortens recovery). `rsync` is another option — sync while running, then a brief `rsync --checksum` during a short shutdown window minimizes downtime.

File-system backups tend to be larger than `pg_dump` output (which excludes index contents) but can be faster to take.
{% endtab %}

{% tab title="Continuous Archiving (PITR)" %}
Combining a file-system backup with archived WAL files (from `pg_wal/`) lets you recover to any point since the base backup: restore the file-system backup, then replay the archived WAL.

Benefits: the base backup doesn't need to be perfectly consistent (WAL replay fixes it), backups can be continuous rather than periodic full dumps, and a warm standby is achievable by continuously streaming WAL to another machine.

{% hint style="info" %}
`pg_dump`/`pg_dumpall` can't participate in this scheme — they don't produce file-system-level backups with the metadata WAL replay needs.
{% endhint %}
{% endtab %}
{% endtabs %}


# Cassandra

SSTables live under the keyspace directory (default `/var/lib/cassandra/data/`), per the path in `cassandra.yaml`.

## Backup

{% tabs %}
{% tab title="Snapshot-based" %}
Via `nodetool snapshot`, which flushes memtables and hard-links SSTables.

```bash
nodetool snapshot                                  # all keyspaces
nodetool snapshot -t 2023.06.27 organization       # one keyspace, named
nodetool snapshot --table employee organization    # one table
```

Transfer snapshots off-box (S3, GCS, Azure) afterward. `nodetool clearsnapshot` removes them locally.

{% hint style="warning" %}
Snapshots don't back up the schema — do that separately.
{% endhint %}

* *Advantages*: simple, easy to manage.
* *Disadvantages*: daily full-keyspace snapshots don't scale well for large datasets; transfer to cold storage can get expensive.
  {% endtab %}

{% tab title="Incremental" %}
Set `incremental_backups: true` in `cassandra.yaml`. Cassandra then hard-links newly-flushed SSTables into a backup directory as they're written, on top of the last full snapshot.

* *Advantages*: lower disk usage, lower transfer cost.
* *Disadvantages*: Cassandra doesn't clean these up automatically (you need your own pruning script); produces many small files; can't selectively back up individual column families.
  {% endtab %}
  {% endtabs %}

## Data Restore

{% tabs %}
{% tab title="nodetool refresh" %}
Loads newly-placed SSTables without a restart.

1. Create the schema if missing
2. Truncate the table if needed
3. Copy the snapshot's SSTable directory into place
4. Run `nodetool refresh`
   {% endtab %}

{% tab title="sstableloader" %}
Loads a set of SSTables into a running cluster — works for external data, existing SSTables, or snapshot restores:

```bash
sstableloader -d <ip> /home/data
```

Create the schema and truncate the table first if needed.
{% endtab %}
{% endtabs %}


# Generic IAM

SunbirdRC was originally tightly coupled to Keycloak. It now supports any OAuth2-compliant identity layer for both purposes an IAM platform serves here: authN/authZ between user and entity, and managing the user accounts created for entities.

## Configure the registry core

```bash
oauth2_resource_uri=https://domain/auth/
oauth2_resource_email_path=email
oauth2_resource_consent_path=consent
oauth2_resource_roles_path=realm_access.roles
oauth2_resource_entity_path=entity
```

| Platform   | `oauth2_resource_uri`                            |
| ---------- | ------------------------------------------------ |
| Keycloak   | `https://keycloak-domain/auth/realms/sunbird-rc` |
| Auth0      | `https://xxxx.us.auth0.com/` (API domain)        |
| FusionAuth | The tenant's configured issuer URL               |

## Enabling user-account creation on a new IAM platform

SunbirdRC ships **three** submodules under [`java/middleware/registry-middleware`](https://github.com/Sunbird-RC/sunbird-rc-core/tree/main/java/middleware/registry-middleware):

| Submodule      | Keycloak                                           | auth0                                       | generic-iam                                       |
| -------------- | -------------------------------------------------- | ------------------------------------------- | ------------------------------------------------- |
| Path           | `java/middleware/registry-middleware/keycloak`     | `java/middleware/registry-middleware/auth0` | `java/middleware/registry-middleware/generic-iam` |
| Provider class | `dev.sunbirdrc.auth.keycloak.KeycloakProviderImpl` | —                                           | `dev.sunbirdrc.auth.genericiam.AuthProviderImpl`  |

To support a different platform, take one of two paths.

{% tabs %}
{% tab title="Build a submodule" %}
{% stepper %}
{% step %}

#### Create the submodule

Under `java/middleware/registry-middleware`.
{% endstep %}

{% step %}

#### Implement IdentityProvider

Implement the [`IdentityProvider`](https://github.com/Sunbird-RC/sunbird-rc-core/blob/generic-auth/java/middleware/registry-middleware/identity-provider/src/main/java/dev/sunbirdrc/registry/identity_providers/providers/IdentityProvider.java) interface (returns an `IdentityManager`); see the [Keycloak implementation](https://github.com/Sunbird-RC/sunbird-rc-core/blob/generic-auth/java/middleware/registry-middleware/keycloak/src/main/java/dev/sunbirdrc/auth/keycloak/KeycloakProviderImpl.java) as an example.
{% endstep %}

{% step %}

#### Implement IdentityManager

[`IdentityManager`](https://github.com/Sunbird-RC/sunbird-rc-core/blob/generic-auth/java/middleware/registry-middleware/identity-provider/src/main/java/dev/sunbirdrc/registry/identity_providers/pojos/IdentityManager.java) handles user creation and returns the user id.
{% endstep %}

{% step %}

#### Register as a Service Provider

Under `META-INF/services` — file name is the fully-qualified SPI name, contents are the fully-qualified implementation name.
{% endstep %}

{% step %}

#### Point the registry at it

Set `identity_provider` to your new implementation's package name.
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Build an external wrapper" %}
Skip the submodule and build an external wrapper service exposing an API to create users in your IAM platform, following [this API spec](https://github.com/Sunbird-RC/sunbird-rc-core/blob/6a99ab9d564ef0518ff5fa8f6730a58e51808f6d/services/sample-fusionauth-service/api-spec.yml). A [sample FusionAuth implementation](https://github.com/Sunbird-RC/sunbird-rc-core/tree/6a99ab9d564ef0518ff5fa8f6730a58e51808f6d/services/sample-fusionauth-service) is provided.

{% hint style="info" %}
Both links are pinned to a historical commit — the `services/` directory has since evolved, but the commit links still resolve.
{% endhint %}

Then set:

```bash
identity_provider=dev.sunbirdrc.auth.genericiam.AuthProviderImpl
sunbird_sso_url=http://localhost:8080/auth/   # replace with your service endpoint
```

{% endtab %}
{% endtabs %}


# Metrics

Sunbird RC can emit `ADD`/`UPDATE`/`DELETE`/`READ` events from the registry, in the Sunbird telemetry event format. Enable with `event_enabled=true`, set `event_topic`, and set `event_providerName` to one of the providers below.

Sample event:

```json
{
  "eid": "ADD", "ets": 1678958110872, "ver": "3.1", "mid": "abc-123",
  "actor": { "id": "123", "type": "User" },
  "context": { "channel": "sunbird-rc-core", "env": "dev" },
  "object": { "id": "xyz-123", "type": "Student" },
  "edata": { "...": "entity fields, masked per the schema's privateFields/internalFields config" }
}
```

{% tabs %}
{% tab title="Kafka-based" %}
`event_providerName=dev.sunbirdrc.registry.service.impl.KafkaEventService`

The registry publishes to the configured topic (default `events`); a consumer stores it in Clickhouse. Entity data is masked per the schema's `privateFields`/`internalFields` config.
{% endtab %}

{% tab title="File-based" %}
`event_providerName=dev.sunbirdrc.registry.service.impl.FileEventService.java`

Events are appended to `metrics_log/metrics.log`, with a 30 MB rolling policy.
{% endtab %}
{% endtabs %}

## Metrics Service

The Kafka consumer, using Clickhouse by default:

```sql
create table <table_name> (
  operationType String,
  createdAt Date,
  entityId String,
  entity JSON
)
```

One table per distinct schema type. Exposes two APIs: an event-count API (across all tables) and an aggregates API — a cron job computes aggregates and caches them in Redis, served from there. Configure the cron with `CRON_ENABLE`, `SCHEDULE_INTERVAL` (days), `SCHEDULE_TIME` (GMT).

{% hint style="info" %}
See the [full discussion](https://github.com/orgs/Sunbird-RC/discussions/) for the end-to-end interaction diagram.
{% endhint %}


# Custom Keycloak Build

SunbirdRC uses a custom Keycloak image that makes NONCE validation toggleable — a change not available in stock Keycloak, added specifically to support Digilocker Meripehchaan SSO ([tracking issue](https://github.com/Sunbird-RC/community/issues/593)).

<a href="https://github.com/Sunbird-RC/keycloak/tree/configurable-nonce-validation" class="button primary" data-icon="github">Sunbird RC/keycloak</a> <a href="https://github.com/Sunbird-RC/keycloak/blob/configurable-nonce-validation/docs/building.md" class="button secondary">Build docs</a>

{% hint style="info" %}
NONCE validation is on by default; set `VALIDATE_NONCE=false` to disable it.
{% endhint %}

**Prerequisites**: JAVA 11 (tested with 11.0.8), Maven.

{% stepper %}
{% step %}

### Build the distribution jar

```bash
git clone https://github.com/Sunbird-RC/keycloak/tree/configurable-nonce-validation
mvn clean install -Pdistribution
```

Output lands in `distribution/server-dist/target`.
{% endstep %}

{% step %}

### Build the Docker image

```bash
git clone https://github.com/keycloak/keycloak-containers/tree/main/
git checkout 14.0.0
cd server
python -m http.server 8001
docker build -t sunbirdrc/keycloak --build-arg KEYCLOAK_DIST=http://<YOUR_IP_ADDRESS>:8001/keycloak-14.0.0.tar.gz .
```

{% endstep %}

{% step %}

### Push it

Tag and push to your Docker registry.
{% endstep %}
{% endstepper %}


# \~Custom QR Code design\~

{% hint style="danger" %}
**Removed — directory doesn't exist.** This page describes configuring a custom QR-styling canvas via a `certificate-api` service, `ENABLE_CUSTOM_QR_CODE_CANVAS`, and a `qr_code_config.json` file. None of this exists in the current `sunbird-rc-core` codebase — there's no `certificate-api` service, no such env flag, and no styling config anywhere in the repo. QR generation today happens inside `credentials-service` (`rendering.utils.service.ts`), using the plain `qrcode` npm package with no styling hook. This page needs new content once/if custom QR styling is reintroduced — not a link fix.
{% endhint %}


# VC Verification Module

A common library for VC verification, usable across Sunbird RC frontends. Scans QR codes inside Angular apps.

<a href="https://github.com/Sunbird-RC/vc-verification" class="button primary" data-icon="github">View the source on GitHub</a>

{% stepper %}
{% step %}

### Install the library

```bash
npm i vc-verification
```

{% endstep %}

{% step %}

### Install the scanner

The deprecated `ngx-scanner` integration was removed starting from `vc-verification@0.0.13`. Install `@zxing/ngx-scanner` separately, matching your Angular version:

```bash
npm i @zxing/ngx-scanner@vx.x.x
```

| Angular Version                   | ngx-scanner version |
| --------------------------------- | ------------------- |
| 9.0.0 – <10                       | 3.0.0, 3.0.1        |
| 10.1.5                            | 3.1.0 – 3.1.3       |
| 11.2.11 \|\| ^12.0.4              | 3.2.0, 3.3.0        |
| 11.2.11 \|\| ^12.0.4 \|\| ^13.0.0 | 3.4.2, 3.5.0        |

For anything beyond this table, check compatibility directly against the [`ngx-scanner` README](https://github.com/zxing-js/ngx-scanner#readme).
{% endstep %}

{% step %}

### Add the zbar-wasm script

{% code title="index.html" %}

```html
<script src="https://cdn.jsdelivr.net/npm/@undecaf/zbar-wasm@0.9.12/dist/index.js"></script>
```

{% endcode %}
{% endstep %}

{% step %}

### Wire up the module

{% code title="app.module.ts" %}

```typescript
import { VerifyModule } from 'vc-verification';
import { ZXingScannerModule } from '@zxing/ngx-scanner'; // not required >=0.0.13
import * as configData from '../assets/config.json';

@NgModule({
  imports: [
    VerifyModule.forChild(configData),
    ZXingScannerModule, // not required >=0.0.13
  ],
})
export class AppModule {}
```

{% endcode %}
{% endstep %}
{% endstepper %}

## Using the module

{% tabs %}
{% tab title="Default scan template" %}
Drop `<sb-vc-verification></sb-vc-verification>` into `app.component.html`.

To customize labels/messages, pass an `item` input (`showResult` array of `{title, path}` entries, plus copy strings like `scanNote`, `certificateTitle`, etc.).

From v10, `showResult` entries also support a `type: 'date'` formatter and a `removeStr` value-stripping option.
{% endtab %}

{% tab title="Service directly" %}
For a fully custom UI, import `VerifyService` from `'verify-module'` and call `scanSuccessHandler(event)`.

Available methods:

* `enableScanner()` — toggle scanner visibility
* `scanSuccessHandler($event)` — verify scanned data
  {% endtab %}
  {% endtabs %}

## Scanners

| Scanner        | Default in    | Notes                                        |
| -------------- | ------------- | -------------------------------------------- |
| `ZXING_QRCODE` | pre-0.0.13    | Deprecated; struggles with large-payload QRs |
| `ZBAR_QRCODE`  | 0.0.13 onward | Handles large payloads better                |

Set via the `scanner_type` property. Override `.vc-btnPrimary` in your stylesheet to change the button color.


# Integrations

Connecting Sunbird RC to existing identity systems and credential wallets.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>SSO with existing systems</strong></td><td>Standard OAuth-based integration with an existing identity provider.</td><td><a href="https://rc.sunbird.org/use/integrations/sso-with-existing-systems">SSO with existing systems</a></td></tr><tr><td><strong>Digilocker Meripehchaan SSO</strong></td><td>Add the Meripehchaan login button via Keycloak identity brokering.</td><td><a href="https://rc.sunbird.org/use/integrations/digilocker-meripehchaan-sso">Digilocker Meripehchaan SSO</a></td></tr><tr><td><strong>Digilocker Integration</strong></td><td>Pull Sunbird RC-issued credentials into the DigiLocker wallet.</td><td><a href="https://rc.sunbird.org/use/integrations/digilocker-integration">Digilocker Integration</a></td></tr><tr><td><strong>Wallet Integration</strong></td><td>OpenID4VC wallet interoperability, from v2.1.0 onward.</td><td><a href="https://rc.sunbird.org/use/integrations/wallet-integration">Wallet Integration</a></td></tr></tbody></table>


# SSO with existing systems

<mark style="color:$info;">Standard OAuth-based integration.</mark>

{% stepper %}
{% step %}

### <mark style="color:$info;">Onboard a new API client</mark>

{% endstep %}

{% step %}

### <mark style="color:$info;">Set up the redirect URL and valid origin</mark>

{% endstep %}

{% step %}

### <mark style="color:$info;">Configure scope-field mapping, if required</mark>

{% endstep %}
{% endstepper %}

## Using OAuth based authentication from registry

* Onboard new api client
* Setup redirect url and Valid origin
* Configure the mapping for scope fields if any required.

{% content-ref url="/pages/OeSh1W91DxX9EwrUjYJZ" %}
[Digilocker Meripehchaan SSO](https://rc.sunbird.org/use/integrations/digilocker-meripehchaan-sso)
{% endcontent-ref %}


# Digilocker Meripehchaan SSO

To surface the Digilocker Meripehchaan SSO login button, use Keycloak's own login theme instead of the default custom theme.

{% hint style="info" %}
**Prerequisites**

* Keycloak
* A [DigiLocker partner account](https://www.digilocker.gov.in/web/partners/)
* Client secrets generated via [APISetu's DigiLocker resource center](https://apisetu.gov.in/digilocker)
* Redirect URL set to `<domain>/auth/realms/master/broker/oidc/endpoint`
  {% endhint %}

{% stepper %}
{% step %}

### Add the identity provider in Keycloak

Keycloak admin page (`<domain>/auth/`) → Identity Providers → Add provider → **OpenID Connect v1.0**.
{% endstep %}

{% step %}

### Set the endpoints

| Setting               | Value                                                              |
| --------------------- | ------------------------------------------------------------------ |
| Authorization URL     | `https://digilocker.meripehchaan.gov.in/public/oauth2/1/authorize` |
| Token URL             | `https://digilocker.meripehchaan.gov.in/public/oauth2/2/token`     |
| Disable User Info     | On                                                                 |
| Client Authentication | Client secret sent as post                                         |
| Prompt                | consent                                                            |
| Use PKCE              | Enabled, method `S256`                                             |

Set the Client Id / Client Secret generated in the DigiLocker partner portal.
{% endstep %}

{% step %}

### Enable the default Keycloak theme

Clients → `registry-frontend` → Login Theme → `keycloak` → Save.
{% endstep %}
{% endstepper %}


# Digilocker Integration

Covers pulling Sunbird RC-issued credentials into the DigiLocker wallet.

{% hint style="info" %}
**Prerequisites**

* A [DigiLocker partner account](https://www.digilocker.gov.in/web/partners/)
* Familiarity with the [DigiLocker Issuer API spec](https://cf-media.api-setu.in/resources/DigiLocker-Issuer-APISpecification-v1-13.pdf)
  {% endhint %}

{% hint style="warning" %}
DigiLocker has no sandbox — all testing happens against production. Be careful with changes in the partner portal.
{% endhint %}

## Onboarding Sunbird RC in DigiLocker

{% stepper %}
{% step %}

### Add a Pull URI Request

Log in to the partner account → **Pull URI Request** section → **+ Add**.
{% endstep %}

{% step %}

### Fill in the callback details

The VC pull URL, e.g. `https://<host>/digilocker/v1/digilocker/pullUriRequest`, and the HMAC key used to verify DigiLocker's request signatures. Then Next.
{% endstep %}

{% step %}

### Define the user parameters

Which parameters get sent to your backend to fetch the VC — existing profile fields like Aadhaar, or custom parameters like a Certificate ID. Then Next.
{% endstep %}

{% step %}

### Add the document type

Add the document type being fetched → Update.
{% endstep %}

{% step %}

### Test and publish

Test via **Test Service** — a correct config returns the VC certificate. Then publish; only published configs are visible to users in the DigiLocker portal.
{% endstep %}
{% endstepper %}

## Configure Sunbird RC to serve VCs to DigiLocker

Requires a JSON mapping file per document type:

```json
{
  "docType": {
    "schema": "Schema",
    "template": "html",
    "searchFilter": { "filters": { "osid": { "eq": "{{.certificate_id}}" } } }
  }
}
```

| Key            | Meaning                                                                                  |
| -------------- | ---------------------------------------------------------------------------------------- |
| `docType`      | The document type configured in DigiLocker                                               |
| `schema`       | The schema the VC is fetched from                                                        |
| `template`     | The rendering template key                                                               |
| `searchFilter` | Search parameters (matching DigiLocker's Add New API step) used to locate the credential |

Sunbird RC fetches the credential as a PDF and returns an XML response to DigiLocker.

{% code title="Example — Pre-Matric Scholarship" %}

```json
{
  "SACER": {
    "schema": "PreMatricScholarship",
    "template": "html",
    "searchFilter": { "filters": { "osid": { "eq": "{{.certificate_id}}" } } }
  }
}
```

{% endcode %}


# Wallet Integration

{% hint style="info" %}
**Applies to** Sunbird RC v2.1.0 and later · **Service** `oid4vc-service` · **Protocols** OpenID4VCI 1.0, OpenID4VP 1.0/draft-23
{% endhint %}

From v2.1.0, Sunbird RC speaks wallet protocols directly — a conformant wallet can receive a credential from a Sunbird RC issuer and present it back to a Sunbird RC verifier with zero Sunbird-specific integration (no SDK, no issuer pre-registration, no proprietary API).

{% stepper %}
{% step %}

### Demo apps

Two thin reference UIs over the public `oid4vc-service` endpoints demonstrate both halves of the flow (issuer and verifier), with no privileged access beyond what a third party could build.
{% endstep %}

{% step %}

### Issuer flow

A schema must opt in with an `oid4vciConfig` block (`oid4vciEnabled: true`, plus `oid4vciFormats`) before it's visible to wallets. Discovery is a live lookup, so newly-opted-in schemas show up immediately — no cache to bust.
{% endstep %}

{% step %}

### Verifier flow

Pick or write a DCQL query in the verifier app → scan the presentation-request QR with the same wallet → consent to disclosure.

The verifier's status panel reports six checks: `holderSignature`, `nonce`, `credentialSignatures`, `holderBinding`, `revocation`, `dcql`. All six passing means the presenter controls the holder key, the credential is genuine and unrevoked, it's bound to that holder, and the disclosed claims satisfy the query exactly. Any failure shows which stage failed.
{% endstep %}
{% endstepper %}

For the curl-level setup and full API walkthrough, see `services/oid4vc-service/README.md` §5 (deployment) and §6 (manual testing) in the `sunbird-rc-core` repo.

## Wallet compatibility flags

Three flags exist purely to accommodate wallets at different points on the OpenID4VC standards timeline. None affect the credential itself, only the protocol envelope.

| Flag                             | Default | Effect                                                                                                                                                                                                                                            |
| -------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DRAFT13_COMPAT_MODE`            | `false` | Emit OpenID4VCI draft-13 shapes instead of final 1.0 (`credentials_supported` in metadata, `credentials` in the offer object, `user_pin_required` in the grant, retained `c_nonce` in the token response). Needed by the MOSIP Inji Wallet today. |
| `OID4VP_SIGN_REQUEST`            | `true`  | Sign the OpenID4VP request object as a JAR with a `did:`-prefixed `client_id`. Set `false` for unsigned plain JSON; overridable per-request via `{"signed": false}`.                                                                              |
| `OID4VP_LEGACY_CLIENT_ID_SCHEME` | `false` | Emit the pre-draft-22 shape — `client_id` is the bare `response_uri`, with `client_id_scheme: "redirect_uri"` as a separate field, unsigned. Needed by walt.id.                                                                                   |

**OpenID4VP request modes**

| Mode               | `client_id`                                    | Signing                                | Selected by                           |
| ------------------ | ---------------------------------------------- | -------------------------------------- | ------------------------------------- |
| signed *(default)* | `did:<VERIFIER_DID>`                           | JWS, `application/oauth-authz-req+jwt` | `OID4VP_SIGN_REQUEST` unset or `true` |
| unsigned           | `<response_uri>`                               | none, plain JSON                       | `{"signed": false}` per request       |
| legacy             | `<response_uri>` + separate `client_id_scheme` | none, plain JSON                       | `OID4VP_LEGACY_CLIENT_ID_SCHEME=true` |

{% hint style="info" %}
Per spec, the `redirect_uri` client-id scheme must never be signed — which is why choosing signed mode forces the `did:` prefix.
{% endhint %}

## What the wallet actually talks to

Issuer/verifier-side calls like `POST /oid4vc/offer` and `POST /vp/request` are never wallet-facing.

{% tabs %}
{% tab title="Issuance (OpenID4VCI)" %}

| Endpoint                                    | Purpose                                                     |
| ------------------------------------------- | ----------------------------------------------------------- |
| `GET /.well-known/openid-credential-issuer` | Discovery, live from `credential-schema`'s opted-in schemas |
| `GET /oid4vc/offer/:id`                     | Dereference the offer deep link                             |
| `POST /oid4vc/token`                        | `pre-authorized_code` grant → access token + `c_nonce`      |
| `POST /oid4vc/credential`                   | Proof-of-possession JWT → signed credential                 |
| {% endtab %}                                |                                                             |

{% tab title="Presentation (OpenID4VP)" %}

| Endpoint                            | Purpose                                      |
| ----------------------------------- | -------------------------------------------- |
| `GET /vp/request-object/:id`        | Fetch the request object (JWS or plain JSON) |
| `POST /vp/response` (`direct_post`) | Submit the `vp_token`                        |
| {% endtab %}                        |                                              |
| {% endtabs %}                       |                                              |

Deep links: `openid-credential-offer://...` (offers), `openid4vp://...` (presentation requests) — both delivered as `qr_data`. Holder binding accepts either a resolvable DID (`kid` in the PoP JWT) or an inline JWK/`did:jwk`, so wallets that don't publish DIDs still work. `oid4vc-service` itself holds no credential keys or storage — only short-lived session state and its own protocol signing key (which lives in Vault via `identity-service`).

For the complete env-var reference (TTL settings, Keycloak auth setup, per-schema issuer DID behavior), see `services/oid4vc-service/README.md` §4 in the `sunbird-rc-core` repo.

{% hint style="success" %}
**Verified wallet interop** — beyond the self-driven test harness (all four credential formats issue and verify end-to-end), `jwt_vc_json` and `vc+sd-jwt` issuance and presentation have been confirmed against independent third-party wallet implementations.
{% endhint %}


# Connectors

Checkout the connectors here:

{% content-ref url="/pages/42Yzq9vtq4bxUeXDQQrd" %}
[OpenID for Verifiable Credentials (OID4VCI)](https://rc.sunbird.org/use/connectors/openid-for-verifiable-credentials-oid4vci)
{% endcontent-ref %}


# \~G2P Connect\~

{% hint style="danger" %}
**Empty — needs real content, not a fix.** This page has no body content on the live site. Someone with G2P Connect integration knowledge needs to write it from scratch; there's nothing in the old docs or the repo to reconstruct from.
{% endhint %}


# OpenID for Verifiable Credentials (OID4VCI)

`oid4vc-service` is a protocol façade: it speaks OpenID4VCI 1.0 (issuance) and OpenID4VP 1.0/draft-23 (presentation) on the wallet-facing side, and delegates everything else internally.

```mermaid
flowchart LR
    Wallet -->|OpenID4VCI / OpenID4VP| OID4VC[oid4vc-service]
    OID4VC -->|issue / verify| Creds[credentials-service]
    OID4VC -->|oid4vci-configs| Schema[credential-schema]
    Creds -->|signing| Identity[identity-service]
    Identity --> Vault[(Vault)]
```

| Service               | Endpoints used                              | Role                                                   |
| --------------------- | ------------------------------------------- | ------------------------------------------------------ |
| `credentials-service` | `/credentials/issue`, `/credentials/verify` | Builds and signs the VC, stores it; keys stay in Vault |
| `credential-schema`   | `/credential-schema/oid4vci-configs`        | Drives the published issuer metadata                   |

{% hint style="info" %}
`oid4vc-service` itself holds no credential keys or storage — only its own short-lived session state and (optionally) its own OAuth/protocol signing key, delegated to `identity-service`.
{% endhint %}

## Supported credential formats

Chosen per credential type via `oid4vciConfig.oid4vciFormats`:

| Format     | Selective disclosure | Notes                              |
| ---------- | -------------------- | ---------------------------------- |
| JWT VC     | No                   | Signed by identity-service         |
| SD-JWT VC  | Yes                  | Via `_sd` digests                  |
| `mso_mdoc` | Per-element          | ES256 COSE\_Sign1, ISO/IEC 18013-5 |

Credentials can also carry a W3C VC Render Method entry (inline SVG or a hosted URL) for wallet-side visual rendering.

## Issuance flow

{% stepper %}
{% step %}

### Discovery

`GET /.well-known/openid-credential-issuer` — `oid4vc-service` looks up opted-in schemas live from `credential-schema` and returns one `credential_configurations_supported` entry per `<schemaId>_<format>` combination.
{% endstep %}

{% step %}

### Offer creation (issuer-side)

`POST /oid4vc/offer` with `{credential_configuration_id, format, claims}`, returns `{offer_id, credential_offer_uri, credential_offer, qr_data}`.
{% endstep %}

{% step %}

### Wallet dereferences the offer

`GET /oid4vc/offer/:id` returns the `credential_offer`, including a `pre-authorized_code` grant.
{% endstep %}

{% step %}

### Token exchange

`POST /oid4vc/token` with the single-use pre-authorized code (a replay returns `400 invalid_grant`), returns a short-lived access token plus a single-use `c_nonce`.
{% endstep %}

{% step %}

### Credential issuance

The wallet presents a proof-of-possession (bound via `kid`, or an inline JWK/`did:jwk`); `oid4vc-service` verifies it, delegates to `credentials-service` (which delegates signing to `identity-service`), and returns the signed credential.
{% endstep %}
{% endstepper %}

## Presentation flow

{% stepper %}
{% step %}

### Request

Verification requests default to a signed JAR (`client_id` is a `did:...`); unsigned and legacy pre-draft-22 modes are available — see [Wallet Integration](broken://pages/CMaqpL3FZl00iepOjCGx) → Wallet compatibility flags.
{% endstep %}

{% step %}

### Response

The wallet posts to `/vp/response` (`direct_post`) with its `vp_token`.
{% endstep %}

{% step %}

### Verification chain

`oid4vc-service` checks, in order: holder/device signature, nonce/session-transcript freshness, each embedded credential's signature and revocation status, holder binding, and finally DCQL satisfaction against the disclosed claims.
{% endstep %}

{% step %}

### Status

`GET /vp/status/:id` reports whether the presentation verified.
{% endstep %}
{% endstepper %}

For the complete config reference, see `services/oid4vc-service/README.md` §4 in the `sunbird-rc-core` repo.

## Getting started

```bash
docker compose up -d db vault redis
bash enable-v2.sh   # inits vault, brings up identity/credential-schema/credential
docker compose --profile oid4vc up -d --build oid4vc-service
curl -s http://localhost:3400/health
```

For the full local deployment walkthrough (including Apple Silicon build notes), manual testing guide, and production hardening checklist, see `services/oid4vc-service/README.md` §5–§8.


# Releases

## Latest release — v2.1.0

**Released 10 August 2026** · Tagged `v2.1.0`

v2.1.0 is the first feature-bearing release of Sunbird RC in roughly two years — the last was v2.0.2 in August 2024, with v2.0.3 a maintenance release in between. It is both a major feature release and a platform-wide upgrade: every service in the repository has been touched, either to add the new capability or to bring its runtime and dependency tree up to date.

The headline is **OpenID Connect for Verifiable Credentials**. A new `oid4vc-service` makes the platform speak OpenID4VCI 1.0 for issuance and OpenID4VP 1.0/draft-23 for presentation, so any conformant wallet can receive a credential from a Sunbird RC deployment and present it back to a Sunbird RC verifier — with no Sunbird-specific integration on the wallet side.

{% content-ref url="/pages/TES2EBXdlACN3ZRtcLpk" %}
[v2.1.0 — Latest release](https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release)
{% endcontent-ref %}

{% hint style="info" %}
**Checkout other** <a href="https://github.com/orgs/Sunbird-RC/packages?repo_name=sunbird-rc-core" class="button primary small" data-icon="box-isometric">Releases & Changelogs</a>
{% endhint %}


# Registry

Release history for the Sunbird RC core registry.

{% updates format="full" %}
{% update date="2026-05-21" tags="fixes,improvements" %}

## v2.0.3 — Security and stability <a href="#v2.0.3" id="v2.0.3"></a>

A maintenance release: CVE remediation and platform hardening across all core services, with no new capability. Java and Spring dependencies moved onto patched versions, service images were rebuilt on Eclipse Temurin 11 as non-root with pinned tags and healthchecks, committed secrets were purged from the repository, and three concurrency fixes landed in the registry itself.

{% content-ref url="/pages/4SIKwagjaNVH0kUyRFEO" %}
[v2.0.3](https://rc.sunbird.org/use/releases/registry/v2.0.3)
{% endcontent-ref %}
{% endupdate %}

{% update date="2023-11-15" tags="improvements" %}

## v1.0.0 — OAuth2 everywhere, field-level encryption, functional identifiers <a href="#v1.0.0" id="v1.0.0"></a>

The release that decoupled Sunbird RC from Keycloak — any OAuth2/OIDC-compliant provider can now serve as the identity layer. Also introduced field-level encryption and masking for private fields, functional identifier generation via DIGIT Id-Gen, Registry CLI enhancements, and the migration of platform images from Docker Hub to GHCR.

{% content-ref url="/pages/ykfoz3gSe5bHNA4Gtx4s" %}
[v1.0.0](https://rc.sunbird.org/use/releases/registry/v1.0.0)
{% endcontent-ref %}
{% endupdate %}

{% update date="2023-06-30" %}

## v0.0.14 <a href="https://rc.sunbird.org/v0.0.14/use/releases" class="button secondary small" data-icon="gitbook">Checkout the v0.0.14 Release Notes</a> <a href="#v0.0.14" id="v0.0.14"></a>

See the release notes on Gitbook for the details of this release.
{% endupdate %}
{% endupdates %}

***

## Artifacts

All images are published on GHCR. `latest` always points to the newest platform version, which is also tagged explicitly on the image.

| Artifact                    | Image                                                      |
| --------------------------- | ---------------------------------------------------------- |
| Sunbird-RC Core             | `ghcr.io/sunbird-rc/sunbird-rc-core`                       |
| Claims services             | `ghcr.io/sunbird-rc/sunbird-rc-claims-ms`                  |
| Certificate Signer services | `ghcr.io/sunbird-rc/sunbird-rc-certificate-signer`         |
| Certificate services        | `ghcr.io/sunbird-rc/sunbird-rc-certificate-api`            |
| Notification services       | `ghcr.io/sunbird-rc/sunbird-rc-notification-service`       |
| Digilocker services         | `ghcr.io/sunbird-rc/sunbird-rc-digilocker-certificate-api` |
| Metrics services            | `ghcr.io/sunbird-rc/sunbird-rc-metrics`                    |
| Bulk issuance services      | `ghcr.io/sunbird-rc/sunbird-rc-bulk-issuance`              |
| Public Key services         | `ghcr.io/sunbird-rc/sunbird-rc-public-key-service`         |
| Context Proxy services      | `ghcr.io/sunbird-rc/sunbird-rc-context-proxy-service`      |
| Keycloak                    | `ghcr.io/sunbird-rc/sunbird-rc-keycloak`                   |
| ID Generation services      | `ghcr.io/sunbird-rc/id-gen-service`                        |
| Encryption services         | `ghcr.io/sunbird-rc/encryption-service`                    |

{% hint style="warning" %}
Per the Custom QR Code and LEARN-section audit findings, `certificate-signer` and `certificate-api` images may be deprecated/renamed — confirm against the current [Sunbird-RC package registry](https://github.com/orgs/Sunbird-RC/packages?repo_name=sunbird-rc-core) before relying on these image names.
{% endhint %}


# v2.0.3

**Tag:** `v2.0.3`\
**Released:** 21 May 2026

***

This is a security-focused release that fixes known CVEs and hardens the platform across all core services.

### [#highlights](#highlights "mention")

* Java & Spring Framework Upgrades

The registry core and Java services have been upgraded from Spring Boot 2.2 to Spring Boot 2.7.18, along with:

* Spring Security 5.7.13
* Embedded Tomcat 9.0.116
* Jackson 2.15.4
* Logback 1.2.13
* Apache Shiro 1.13.0
* commons-text 1.10.0

These upgrades remediate multiple critical and high severity CVEs in the Java dependency chain.

#### Docker Image Hardening

* All service images migrated from **JDK 8** to **Eclipse Temurin 11**
* Images now run as **non-root users**
* Base images use **pinned tags** instead of `latest`
* **Container healthchecks** added for better orchestration and monitoring

#### Secrets & Credentials Cleanup

* Hardcoded credentials and the committed `.env` file have been removed from the repository
* A sanitized `.env.example` template has been added
* `.gitignore` updated so environment secrets are never committed again

#### Go Services Modernisation

* Metrics and Notification services moved from the CGO-based `confluent-kafka-go` client to the pure-Go `segmentio/kafka-go` client
* Go toolchain upgraded from **Go 1.15/1.20** to **Go 1.23/1.24**
* All reachable Go vulnerabilities reported by `govulncheck` are now resolved

#### Node.js Dependency Updates

Vulnerable packages updated across the Credential, Credential Schema, Identity, and utility services, including:

* `axios`
* `handlebars`
* `passport`
* `jsonwebtoken`
* `semver`
* `elliptic`

#### Stability & Concurrency Fixes

Thread-safety improvements in the registry core:

* Lazy initialization of the Tenant JWT decoder
* Thread-safe `DBProviderFactory`
* Per-label locking in `EntityParenter` to prevent race conditions during entity schema setup

### Docker Images

The `latest` tag always points to the latest version of the platform. The current version is also tagged to the image.

**Current version:** `v2.0.3`

Docker image details: <a href="https://github.com/Sunbird-RC/sunbird-rc-core/releases/tag/v2.0.3" class="button primary" data-icon="github">v2.0.3 Release</a>


# v1.0.0

**Tag:** `v1.0.0`\
**Released:** 15 November 2023

***

* **Full OAuth and OIDC support -** Sunbird-RC was dependent on Keycloak for its Identity and Access Management needs. Sunbird-RC has been enhanced to support any OAuth 2.0 and OIDC-compliant provider.
* **Enhanced Data Privacy with Encryption & Decryption on the Private Fields -** Sunbird-RC has been enhanced to encrypt, mask or hash data at a field level even during storage. Earlier, data was encrypted and masked only when shared with other integrators.
* **Unique ID Generation for Fields -** Sunbird-RC has incorporated the capability to generate and add functional identifiers in registries, moving away from generic UUIDs. This enhancement facilitates seamless integration with DIGIT's Id-Gen service.
* **Cleanup of Registry Startup Errors -** Users reported various startup issues, especially when authentication is disabled or related to keycloak, elastic search, and auxiliary services. The update addresses these concerns for a smoother startup.
* **Enhanced Registry-CLI -** Registry-CLI has been upgraded and new options have been added for enabling or disabling various features. These updates empower users to tailor the CLI to their specific needs and streamline its operation based on individual use cases.
* Migrated all Registry Core Docker images from Dockerhub to the GitHub Container Registry (GHCR)
* Various bug fixes to enhance the overall user experience.

For a comprehensive list of changes in all our releases, you can find the detailed change log available at this link. <https://github.com/Sunbird-RC/sunbird-rc-core/releases>

### Artifacts

The various artifacts that form the crux of the Sunbird-RC platform are as follows. All of Sunbird-RC's artifacts are hosted on the Github Container Registry.

| Artifact               | Image                                                    |
| ---------------------- | -------------------------------------------------------- |
| Sunbird-RC Core        | ghcr.io/sunbird-rc/sunbird-rc-core                       |
| Claims services        | ghcr.io/sunbird-rc/sunbird-rc-claims-ms                  |
| Signer services        | ghcr.io/sunbird-rc/sunbird-rc-certificate-signer         |
| Certificate services   | ghcr.io/sunbird-rc/sunbird-rc-certificate-api            |
| Notification services  | ghcr.io/sunbird-rc/sunbird-rc-notification-service       |
| Digilocker services    | ghcr.io/sunbird-rc/sunbird-rc-digilocker-certificate-api |
| Metrics services       | ghcr.io/sunbird-rc/sunbird-rc-metrics                    |
| Bulk issuance services | ghcr.io/sunbird-rc/sunbird-rc-bulk-issuance              |
| Public Key services    | ghcr.io/sunbird-rc/sunbird-rc-public-key-service         |
| Context Proxy services | ghcr.io/sunbird-rc/sunbird-rc-context-proxy-service      |
| Keycloak               | ghcr.io/sunbird-rc/sunbird-rc-keycloak                   |
| ID Generation services | ghcr.io/sunbird-rc/id-gen-service                        |
| Encryption services    | ghcr.io/sunbird-rc/encryption-service                    |

The **`latest`** tag always points to the latest version of the platform. The current version is also tagged to the image. The current version is **`v1.0.0`**

The details about the various docker images are available at: <a href="https://github.com/Sunbird-RC/sunbird-rc-core/releases/tag/v1.0.0" class="button primary" data-icon="github">v1.0.0 Release</a>


# Credentialling

Release history for the Credentialling Services — Identity, Credential Schema, and Credential.

{% updates format="full" %}
{% update date="2026-08-10" tags="new-release,improvements" %}

## v2.1.0 — Standards-based wallet interoperability <a href="#v2.1.0" id="v2.1.0"></a>

{% content-ref url="/pages/TES2EBXdlACN3ZRtcLpk" %}
[v2.1.0 — Latest release](https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release)
{% endcontent-ref %}

The first feature-bearing release in roughly two years. A new `oid4vc-service` makes the platform speak **OpenID4VCI 1.0** for issuance and **OpenID4VP 1.0/draft-23** for presentation, so any conformant wallet can receive a credential from a Sunbird RC deployment and present it back to a Sunbird RC verifier with no Sunbird-specific integration. Four credential formats are supported end-to-end, and W3C VC Data Model 2.0 lands alongside the existing 1.1 support.

Read the full v2.1.0 release notes
{% endupdate %}

{% update date="2026-05-21" tags="fixes" %}

## v2.0.3 — Security and stability <a href="#v2.0.3" id="v2.0.3"></a>

{% content-ref url="/pages/UNWhhtE0080IM5XQgASw" %}
[v2.0.3](https://rc.sunbird.org/use/releases/credentialing/v2.0.3)
{% endcontent-ref %}

The platform-wide maintenance release, as it applied to the credentialling stack: Node dependency remediation across the Credential, Credential Schema and Identity services, the same hardened image baseline, and the repository-wide secrets cleanup.
{% endupdate %}

{% update date="2024-02-13" tags="improvements" %}

## v2.0.0-beta3 — Initial Credentialling Services release <a href="#v2.0.0-beta3" id="v2.0.0-beta3"></a>

{% content-ref url="/pages/9uzKKpxhOUrNnDpJqN01" %}
[v2.0.0](https://rc.sunbird.org/use/releases/credentialing/v2.0.0)
{% endcontent-ref %}

The first release of the three-service credentialling stack — Identity Service, Credential Schema Service and Credential Service — which replaced the registry's older built-in signing and certificate path.
{% endupdate %}
{% endupdates %}

***

## Artifacts

All images are published on GHCR.

| Artifact                  | Image                                              |
| ------------------------- | -------------------------------------------------- |
| Identity Service          | `ghcr.io/sunbird-rc/sunbird-rc-identity-service`   |
| Credential Schema Service | `ghcr.io/sunbird-rc/sunbird-rc-credential-schema`  |
| Credential Service        | `ghcr.io/sunbird-rc/sunbird-rc-credential-service` |


# v2.1.0 — Latest release

## Standards-Based Wallet Interoperability: OpenID4VC Comes to Sunbird RC <a href="https://github.com/Sunbird-RC/sunbird-rc-core/releases/tag/v2.1.0" class="button primary medium" data-icon="github">Release Version v2.1.0</a>

**Tag:** `v2.1.0`\
**Released:** 10 August 2026

***

### Introduction

**v2.1.0 is the first feature-bearing release of Sunbird RC** — the last one was `v2.0.2` in August 2024. (`v2.0.3`, in July 2026, was a maintenance release: CVE remediation and stability fixes, no new capability.) It is therefore both a **major feature release** and a **platform-wide upgrade**: every service in the repository has been touched, either to add the new capability or to bring its runtime and dependency tree up to date.

**The core feature of this release is OpenID Connect for Verifiable Credentials (OID4VC).** Until now, getting a Sunbird RC credential into a wallet meant integrating against Sunbird's own APIs. From v2.1.0 the platform speaks the standards that wallets already speak — **OpenID4VCI 1.0** for issuance and **OpenID4VP 1.0/draft-23** for presentation — via a new `oid4vc-service`. Any conformant wallet can now receive a credential from a Sunbird RC deployment and present it back to a Sunbird RC verifier, with no Sunbird-specific integration on the wallet side.

Three things make this a genuinely additive release rather than a migration:

1. **Nothing existing changes.** `oid4vc-service` is a protocol facade. It holds no credential keys and no credential storage of its own; it delegates every key operation and every persistence concern to the services that already own them. The registry's hook into it is flag-gated and off by default (`oid4vc.enabled=false`), fail-open, and cannot fail entity creation or claim grant. The service ships behind a Docker Compose profile (`--profile oid4vc`) and its nginx routes are separate, gated locations that degrade gracefully rather than blocking gateway startup.
2. **Four credential formats are supported end-to-end** — `ldp_vc`, `jwt_vc_json`, `vc+sd-jwt`, and `mso_mdoc` — including selective disclosure, and all four were verified issuance-through-verification in a self-driven harness. Two of them were additionally confirmed against independent third-party wallets in real interop testing.
3. **W3C VC Data Model 2.0** support lands alongside the existing 1.1 support, opt-in via `@context`, with no database migration and no behavior change for existing callers.

Alongside the feature work, this release completes a **security and dependency pass across the whole platform**: a focused review of the new OID4VC code path (8 fixes, all pre-release), a CVE remediation sweep across the Java registry and both Java services, and Go/Node runtime and library upgrades everywhere else. Service-by-service detail is in the next section.

***

### Service-by-Service Upgrade Status

<table><thead><tr><th width="175">Service</th><th width="184">Status in v2.1.0</th><th>What changed</th></tr></thead><tbody><tr><td><strong><code>oid4vc-service</code></strong></td><td><strong>New service</strong></td><td>The OpenID4VCI / OpenID4VP protocol façade. Modules for <code>oid4vci</code>, <code>oid4vp</code>, session store, auth, and downstream clients. Ships as a new Docker image and under the optional <code>oid4vc</code> Compose profile. Stateless with respect to keys and credential storage.</td></tr><tr><td><strong><code>credentials-service</code></strong></td><td><strong>Feature upgrade</strong></td><td>W3C VC Data Model 2.0 support; new credential-format abstraction layer covering all four formats; status-list (revocation) support; Prisma migration <code>add_vc_format_enveloped_statuslist</code>. Dependencies: <code>@digitalbazaar/vc</code> 6.3 → 7.1.1, added <code>@digitalbazaar/credentials-context</code> 3.2.</td></tr><tr><td><strong><code>identity-service</code></strong></td><td><strong>Feature upgrade</strong></td><td>New signing endpoints <code>/utils/sign-jwt</code>, <code>/utils/sign-sd-jwt</code>, <code>/utils/sign-mdoc</code>; published JWKS at <code>/.well-known/jwks.json</code>; resolution for self-contained DID methods (<code>did:key</code>, <code>did:jwk</code>) for holder binding; vault write hardening with new unit tests. Dependencies: added <code>@auth0/mdl</code> 3.0, <code>@peculiar/x509</code> 1.9, <code>jose</code> 4.15, <code>@digitalbazaar/credentials-context</code> 3.2.</td></tr><tr><td><strong><code>credential-schema</code></strong></td><td><strong>Feature upgrade</strong></td><td>Schemas can opt into OID4VCI via a new <code>oid4vciConfig</code> block (formats, render method); surfaced through the new <code>GET /credential-schema/oid4vci-configs</code>endpoint. Prisma migration <code>add_oid4vci_config</code>. No dependency changes.</td></tr><tr><td><strong><code>encryption-service</code></strong></td><td><strong>Maintenance upgrade</strong></td><td>CVE remediation pass in <code>pom.xml</code>, no functional change: spring-framework → 5.3.39, spring-security → 5.8.16, jackson-core → 2.18.8 / jackson-databind → 2.18.9, snakeyaml → 2.0, nimbus-jose-jwt → 9.37.2, postgresql → 42.7.12, kafka-clients → 3.9.2, spring-kafka → 2.9.13, commons-io → 2.14.0, snappy-java → 1.1.10.4, lz4-java → 1.8.1, org.json → 20231013, libthrift → 0.14.0, mssql-jdbc → 12.8.2.jre11.</td></tr><tr><td><strong><code>id-gen-service</code></strong></td><td><strong>Maintenance upgrade</strong></td><td>Same CVE remediation pass as <code>encryption-service</code>, applied to this service's own <code>pom.xml</code>. No functional change.</td></tr><tr><td><strong><code>notification-service</code></strong></td><td><strong>Maintenance upgrade</strong></td><td>Go 1.23 → 1.25. SMS client migrated off the unmaintained <code>imroc/req</code> to <code>go-resty/resty</code> v2.17.2. <code>golang.org/x/net</code> → 0.57.0, <code>golang.org/x/text</code> → 0.40.0, <code>golang.org/x/sys</code> → 0.47.0. Behaviour unchanged.</td></tr><tr><td><strong><code>metrics</code></strong></td><td><strong>Maintenance upgrade</strong></td><td>Go 1.24 → 1.25. <code>go-redis/v9</code> 9.0.5 → 9.6.3, <code>golang.org/x/net</code> 0.50.0 → 0.57.0, <code>golang.org/x/sys</code> → 0.47.0. No functional change.</td></tr><tr><td><strong>nginx gateway</strong></td><td><strong>Config upgrade</strong></td><td>New public routes for the OID4VC endpoints, gated so they degrade gracefully rather than blocking gateway startup on deployments that don't enable the feature. <code>nginx.conf</code>is now bind-mounted in Compose so local edits take effect.</td></tr></tbody></table>

**Upgrade takeaway:** every service ships a new image in v2.1.0. Deployments that do not want OID4VC can upgrade for the security and runtime fixes alone and see **no behavioural change** — the new service need not be deployed.

***

### OpenID4VCI Credential Issuance

A new `oid4vc-service` speaks OpenID4VCI 1.0 (with an optional `DRAFT13_COMPAT_MODE`) on the wallet-facing side, while delegating all key operations and storage to the existing platform services — it holds no credential keys and no credential storage of its own. It supports:

* Discovery via `.well-known/openid-credential-issuer`, sourced live from `credential-schema`'s opted-in schemas.
* The `pre-authorized_code` grant, with atomically single-use codes and `c_nonce` values.
* Proof-of-possession verification at the credential endpoint, supporting both DID-bound (`kid`) and inline-JWK (`did:jwk`) holder keys.
* Deferred issuance for credentials pending an external claim resolution.
* W3C VC Render Method support (inline SVG or hosted URL) for wallet-side visual rendering.

### OpenID4VP Presentation Verification

The same service also implements OpenID4VP 1.0/draft-23 for verifiers:

* Presentation requests default to a signed JAR (`did:`-prefixed `client_id`); an unsigned mode and a legacy pre-draft-22 shape (`OID4VP_LEGACY_CLIENT_ID_SCHEME`) are available for wallets that haven't caught up to the latest draft.
* DCQL (Digital Credentials Query Language) evaluation against disclosed claims.
* A six-point verification chain per presentation — holder/device signature, nonce/session-transcript freshness, credential signature, revocation, holder binding, and DCQL satisfaction — all of which must pass before a verifier's `GET /vp/status/:id` reports `verified: true`.

### Credential Format Support

Four credential formats are supported end-to-end, selected per schema via `oid4vciConfig.oid4vciFormats`:

| Format        | Selective disclosure | Notes                                     |
| ------------- | -------------------- | ----------------------------------------- |
| `ldp_vc`      | No                   | W3C Data Integrity (Ed25519Signature2020) |
| `jwt_vc_json` | No                   | W3C VC-JWT convention                     |
| `vc+sd-jwt`   | Yes                  | IETF SD-JWT VC                            |
| `mso_mdoc`    | Yes (per-element)    | ISO/IEC 18013-5 mobile documents          |

All four formats were verified end-to-end in a self-driven test harness (issuance → wallet receipt → presentation → verification, all checks OK), and `jwt_vc_json` / `vc+sd-jwt` were additionally confirmed against two independent third-party wallets — [**Paradym Wallet**](https://paradym.id/) (presentation) and [**walt.id Wallet**](https://walt.id/wallet) (issuance and presentation) — in real interop testing.

👉 [**See Wallet Integration**](https://rc.sunbird.org/use/integrations/wallet-integration) for the demo apps, per-wallet interop results, and the wallet-compatibility configuration flags.

### W3C VC Data Model 2.0

`credentials-service` now supports the W3C Verifiable Credentials Data Model 2.0 alongside the existing 1.1 support:

* **Context-aware issuance:** the `@context` on an incoming credential request determines whether `validFrom`/`validUntil` (2.0) or `issuanceDate`/`expirationDate` (1.1) are populated — existing 1.1 callers see no behavior change.
* Verification reads whichever date fields are present, so 1.1 and 2.0 credentials both verify correctly.
* **No database migration required** — 2.0's date fields map onto the existing `issuanceDate`/`expirationDate`columns.
* Fully backward compatible and opt-in: existing credential templates keep issuing 1.1 credentials until explicitly updated to a 2.0 `@context`.

### Supporting Service Enhancements

* **`identity-service`:** new signing endpoints for the additional formats (`/utils/sign-jwt`, `/utils/sign-sd-jwt`, `/utils/sign-mdoc`), a published JWKS endpoint (`/.well-known/jwks.json`), and resolution support for self-contained DID methods (`did:key`, `did:jwk`) needed for wallet holder-binding.
* **`credential-schema`:** schemas can now opt into OID4VCI via an `oid4vciConfig` block, surfaced through a new `/credential-schema/oid4vci-configs` endpoint.
* **`credentials-service`:** a credential-format abstraction layer and status-list (revocation) support, now active across all four formats.
* **`nginx`:** new public gateway routes for the OID4VC endpoints, gated so they degrade gracefully rather than blocking gateway startup on deployments that don't enable the feature.

### Security Hardening

A focused security review of the new OID4VC code path led to several fixes prior to this release:

* Closed a replay bypass where a presented SD-JWT with its Key Binding JWT stripped could be accepted without proof of holder possession.
* Closed a holder-binding bypass where a self-asserted inline JWK header wasn't checked against the DID it claimed to represent, at both issuance and presentation time.
* Made pre-authorized-code and nonce consumption genuinely atomic under concurrent requests (in-memory session store).
* Made status-list index allocation atomic, preventing double-allocation of a revocation index under concurrent issuance.
* Hardened key storage against silently overwriting an existing secret on a transient vault error.
* Pinned JWT verification to a fixed signing algorithm and stopped falling back to an unrelated key on a `kid`mismatch.
* Added authentication to the two remaining unauthenticated internal verifier endpoints.
* Mitigated a stored-XSS vector in schema-supplied SVG render templates.

Separately, the platform-wide CVE remediation pass covering the Java registry, `encryption-service`, `id-gen-service`, and the Go services is summarised per service in the table above.

### Docker Images&#x20;

A new image, **`sunbird-rc-oid4vc-service`**, is published alongside the existing platform images. As with prior releases, the `latest` tag always points to the latest version of the platform; this release is tagged **`v2.1.0`**.


# v2.0.3

**Tag:** `v2.1.0`\
**Released:** 21 May 2026

***

This is a security-focused release that fixes known CVEs and hardens the platform across all core services.

### Highlights

#### Java & Spring Framework Upgrades

The registry core and Java services have been upgraded from Spring Boot 2.2 to Spring Boot 2.7.18, along with:

* Spring Security 5.7.13
* Embedded Tomcat 9.0.116
* Jackson 2.15.4
* Logback 1.2.13
* Apache Shiro 1.13.0
* commons-text 1.10.0

These upgrades remediate multiple critical and high severity CVEs in the Java dependency chain.

#### Docker Image Hardening

* All service images migrated from **JDK 8** to **Eclipse Temurin 11**
* Images now run as **non-root users**
* Base images use **pinned tags** instead of `latest`
* **Container healthchecks** added for better orchestration and monitoring

#### Secrets & Credentials Cleanup

* Hardcoded credentials and the committed `.env` file have been removed from the repository
* A sanitized `.env.example` template has been added
* `.gitignore` updated so environment secrets are never committed again

#### Go Services Modernisation

* Metrics and Notification services moved from the CGO-based `confluent-kafka-go` client to the pure-Go `segmentio/kafka-go` client
* Go toolchain upgraded from **Go 1.15/1.20** to **Go 1.23/1.24**
* All reachable Go vulnerabilities reported by `govulncheck` are now resolved

#### Node.js Dependency Updates

Vulnerable packages updated across the Credential, Credential Schema, Identity, and utility services, including:

* `axios`
* `handlebars`
* `passport`
* `jsonwebtoken`
* `semver`
* `elliptic`

#### Stability & Concurrency Fixes

Thread-safety improvements in the registry core:

* Lazy initialization of the Tenant JWT decoder
* Thread-safe `DBProviderFactory`
* Per-label locking in `EntityParenter` to prevent race conditions during entity schema setup

### Docker Images

The `latest` tag always points to the latest version of the platform. The current version is also tagged to the image.

**Current version:** `v2.0.3`

Docker image details: <a href="https://github.com/Sunbird-RC/sunbird-rc-core/releases/tag/v2.0.3" class="button primary" data-icon="github">v2.0.3 Release</a>


# v2.0.0

**Tag:** `v2.0.0-beta3`\
**Released:** 13 February 2024

***

### Artifacts

The various artifacts that form the crux of the Sunbird-RC Credentialling platform are as follows. All of Sunbird-RC's artifacts are hosted on the Github Container Registry.

| Artifact                  | Image                                            |
| ------------------------- | ------------------------------------------------ |
| Identity Service          | ghcr.io/sunbird-rc/sunbird-rc-identity-service   |
| Credential Schema Service | ghcr.io/sunbird-rc/sunbird-rc-credential-schema  |
| Credential Service        | ghcr.io/sunbird-rc/sunbird-rc-credential-service |

The **`latest`** tag always points to the latest version of the platform. The current version is also tagged to the image. The current version is **`v2.0.0-beta3`**

The details about the various docker images are available at: <a href="https://github.com/Sunbird-RC/sunbird-rc-core/releases/tag/v2.0.0" class="button primary" data-icon="github">v2.0.0 Release</a>


# Discussion Forum

We have multiple channels available for the community to discuss use cases, ask for support from fellow community members, discuss existing features and brainstorm new ones.

{% hint style="info" %}
Reporting a bug or requesting a feature rather than starting a discussion? Go straight to the [Issue Tracker](https://github.com/Sunbird-RC/sunbird-rc-core/issues).
{% endhint %}

We encourage you to participate in the discussion forum, ask questions, and share your knowledge and experience with others. By working together, we can build a stronger and more engaged community.

General questions, ideas and enhancement suggestions, show-and-tell — anything worth keeping searchable. Discussions here often become issues, so it's the right place to float something before it's a formal request.

<a href="https://github.com/Sunbird-RC/community/discussions" class="button primary" data-icon="github">Join GitHub Discussions</a>

Real-time chat — quick questions, debugging help, and informal conversation. <a href="https://discord.gg/Q5mvw2mGC8" class="button primary small" data-icon="discord">Discord Invite</a>


# Use case Walkthroughs

Short videos showing Sunbird RC in action for real-world use cases.

These videos walk through how Sunbird RC's Registry and Credentials components can be used for a specific domain. Each demo shows a reference flow — from creating records to issuing and verifying credentials — rather than a particular production deployment.

## Education

{% columns %}
{% column width="58.333333333333336%" %}

<details open>

<summary>English</summary>

**Where the student’s journey begins ?**

* A brand new wallet on the student’s phone, with nothing in it yet
* A PIN binds the wallet to this device, so it can’t be copied elsewhere
* Fingerprint unlock can be added for faster, everyday access
* Three registries are ready to issue: School, College, and University

</details>

<details open>

<summary>Português (Brasil)</summary>

**Onde a jornada do estudante começa ?**

* Uma carteira nova no celular do estudante, ainda sem nada dentro
* Um PIN vincula a carteira a este aparelho, impedindo que seja copiada para outro
* A digital pode ser adicionada para um desbloqueio mais rápido no dia a dia
* Três registros prontos para emitir: Escola, Faculdade e Universidade

</details>

<details>

<summary>Español</summary>

**¿Dónde comienza el recorrido del estudiante?**

* Una billetera nueva en el teléfono del estudiante, todavía vacía
* Un PIN vincula la billetera a este dispositivo, para que no pueda copiarse a otro
* Se puede agregar el desbloqueo con huella digital para un acceso más rápido en el día a día
* Tres registros listos para emitir: Escuela, Instituto y Universidad

</details>
{% endcolumn %}

{% column width="41.666666666666664%" %}
&#x20;

<div data-with-frame="true"><figure><img src="https://lh3.googleusercontent.com/d/1IdwVXQXVZWNE1ozYX0suT5M5PzUz7wtL" alt="Education demo, part 1"><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

***

{% columns %}
{% column width="58.333333333333336%" %}

<details open>

<summary>English</summary>

**Credentials that belong to the student**

* Each registry issues a digital credential directly to the wallet
* School, college, and university records now sit in one place
* The wallet is closed and reopened, and all three credentials are still there
* No re-downloading, no requesting copies from each institution again

</details>

<details open>

<summary>Português (Brasil)</summary>

**Credenciais que pertencem ao estudante**

* Cada registro emite uma credencial digital direto para a carteira
* Os registros da escola, faculdade e universidade ficam em um só lugar
* A carteira é fechada e reaberta, e as três credenciais continuam lá
* Sem baixar de novo, sem pedir cópias a cada instituição

</details>

<details>

<summary>Español</summary>

**Credenciales que pertenecen al estudiante**

* Cada registro emite una credencial digital directamente a la billetera
* Los registros de la escuela, el instituto y la universidad quedan en un solo lugar
* La billetera se cierra y se vuelve a abrir, y las tres credenciales siguen ahí
* Sin volver a descargar, sin pedir copias a cada institución

</details>
{% endcolumn %}

{% column width="41.666666666666664%" %}
&#x20;

<div data-with-frame="true"><figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FudsOCd5GchCgL0u2D7mA%2F1792048329677995.gif?alt=media&#x26;token=06b746fe-c9f9-4933-a97a-d40aaf421877" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

***

{% columns %}
{% column width="58.333333333333336%" %}

<details open>

<summary>English</summary>

**Verified in seconds, with the student’s consent**

* Verified in seconds, with the student’s consent
* The verifier displays a QR code requesting the three credentials
* The student sees exactly what’s being asked for before sharing
* One approval sends all three at once
* The credentials are verified instantly and the result appears on screen

</details>

<details open>

<summary>Português (Brasil)</summary>

**Verificado em segundos, com o consentimento do estudante**

* O verificador exibe um QR code solicitando as três credenciais
* O estudante vê exatamente o que está sendo pedido antes de compartilhar
* Uma única aprovação envia as três de uma vez
* As credenciais são verificadas na hora e o resultado aparece na tela

</details>

<details>

<summary>Español</summary>

**Verificado en segundos, con el consentimiento del estudiante**

* El verificador muestra un código QR que solicita las tres credenciales
* El estudiante ve exactamente qué se le pide antes de compartir
* Una sola aprobación envía las tres a la vez
* Las credenciales se verifican al instante y el resultado aparece en pantalla

</details>
{% endcolumn %}

{% column width="41.666666666666664%" %}
&#x20;

<div data-with-frame="true"><figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FXa0V3f8vib4CQjnTHDt8%2Fqr_presentation.gif?alt=media&amp;token=caff5dd8-0165-411c-b701-bf81df415d9c" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

## Agriculture

{% columns %}
{% column width="58.333333333333336%" %}

<details open>

<summary>English</summary>

**Where the farmer’s journey begins**

* A new wallet on the farmer’s phone, secured with a PIN and biometrics
* Two registries are ready to issue: the Farmer Registry and the Land Registry
* The farmer signs in to the Farmer Registry and reviews the card before accepting it
* A Farmer Identity Credential, with farmer ID, district and category, lands in the wallet

</details>

<details open>

<summary>Português (Brasil)</summary>

**Onde a jornada do agricultor começa**

* Uma carteira nova no celular do agricultor, protegida por PIN e biometria
* Dois registros prontos para emitir: o Registro de Agricultores e o Registro de Terras
* O agricultor entra no Registro de Agricultores e revisa o cartão antes de aceitá-lo
* Uma Credencial de Identidade do Agricultor, com ID, distrito e categoria, chega à carteira

</details>

<details>

<summary>Español</summary>

**Dónde comienza el recorrido del agricultor**

* Una billetera nueva en el teléfono del agricultor, protegida con PIN y biometría
* Dos registros listos para emitir: el Registro de Agricultores y el Registro de Tierras
* El agricultor inicia sesión en el Registro de Agricultores y revisa la tarjeta antes de aceptarla
* Una Credencial de Identidad del Agricultor, con su ID, distrito y categoría, llega a la billetera

</details>
{% endcolumn %}

{% column width="41.666666666666664%" %}
&#x20;

<div data-with-frame="true"><figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FO9MvtngHZgCGqhuLcHwm%2Ffarmer_intro.gif?alt=media&amp;token=784ed621-c2e3-4bac-962d-ac761fd33ca8" alt=""><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

***

{% columns %}
{% column width="58.333333333333336%" %}

<details open>

<summary>English</summary>

**One consent, two cards, one loan decision**

* The wallet is closed and reopened, and the farmer identity card is still there
* The farmer collects a Land Ownership Credential from a second registry, the Land Registry
* Gramin Bank shows a QR code on a laptop, and the farmer’s phone answers it
* One consent shares both cards, and the bank shows the farmer is eligible, with the maximum loan worked out

</details>

<details open>

<summary>Português (Brasil)</summary>

**Um consentimento, dois cartões, uma decisão de crédito**

* A carteira é fechada e reaberta, e o cartão de identidade do agricultor continua lá
* O agricultor recebe uma Credencial de Propriedade da Terra de um segundo registro, o Registro de Terras
* O Gramin Bank exibe um QR code em um notebook, e o celular do agricultor responde
* Um único consentimento compartilha os dois cartões, e o banco mostra que o agricultor é elegível, com o valor máximo do empréstimo calculado

</details>

<details>

<summary>Español</summary>

**Un consentimiento, dos tarjetas, una decisión de crédito**

* La billetera se cierra y se vuelve a abrir, y la tarjeta de identidad del agricultor sigue ahí
* El agricultor recibe una Credencial de Propiedad de la Tierra de un segundo registro, el Registro de Tierras
* Gramin Bank muestra un código QR en una computadora portátil, y el teléfono del agricultor lo responde
* Un solo consentimiento comparte ambas tarjetas, y el banco muestra que el agricultor es elegible, con el monto máximo del préstamo calculado

</details>
{% endcolumn %}

{% column width="41.666666666666664%" %}
&#x20;

<div data-with-frame="true"><figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2F6ktCayL2oRWdKA8nQFDH%2Ffarmer_cred.gif?alt=media&amp;token=6d8fb4ae-b3d9-48ae-ae7c-6f5056d38460" alt="Agriculture demo, part 2"><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

***

{% columns %}
{% column width="58.33333333333333%" %}

<details open>

<summary>English</summary>

**The same check, different outcomes**

* The Farm Credit app on the same phone asks the wallet directly, with no QR code
* The bank asks for only six facts, not the farmer’s National ID, name or size of holding
* A second farmer passes every cryptographic check but is refused, because the land is not actively owned
* Two genuine cards that don’t belong together are refused, even though every check passes

</details>

<details open>

<summary>Português (Brasil)</summary>

**A mesma verificação, resultados diferentes**

* O app Farm Credit, no mesmo celular, pede os dados direto à carteira, sem QR code
* O banco pede apenas seis informações, e não o documento nacional, o nome ou o tamanho da propriedade
* Um segundo agricultor passa em todas as verificações criptográficas, mas é recusado, porque a terra não está com posse ativa
* Dois cartões legítimos que não combinam entre si são recusados, mesmo com todas as verificações aprovadas

</details>

<details>

<summary>Español</summary>

**La misma verificación, resultados distintos**

* La app Farm Credit, en el mismo teléfono, le pide los datos directamente a la billetera, sin código QR
* El banco pide solo seis datos, no el documento nacional, el nombre ni el tamaño de la propiedad
* Un segundo agricultor pasa todas las verificaciones criptográficas, pero es rechazado, porque la tierra no tiene propiedad activa
* Dos tarjetas auténticas que no corresponden entre sí son rechazadas, aunque se cumplan todas las verificaciones

</details>
{% endcolumn %}

{% column width="41.66666666666667%" %}
&#x20;

<div data-with-frame="true"><figure><img src="https://lh3.googleusercontent.com/d/1T7lYv2ueB9LK3wK2_u7eMFxjLSF8Spwf" alt="Agriculture demo, part 3"><figcaption></figcaption></figure></div>
{% endcolumn %}
{% endcolumns %}

## Presentation

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FYF0UJPdDBoS93sbWXhrY%2Fpresentation.mp4?alt=media&token=4a13434c-474d-4a77-a3a4-679e673c3861>" %}

{% tabs %}
{% tab title="English" %}
**Verify credentials without collecting documents**

* Generate a QR code requesting the credentials you need
* The student scans it and approves what to share
* Credentials arrive directly from the student’s wallet
* Each one is checked instantly: issuer signature, credential status, and revocation
* The result appears on your screen, with nothing to chase and nothing to re-check manually
  {% endtab %}

{% tab title="Português (Brasil)" %}
**Verifique credenciais sem coletar documentos**

* Gere um QR code solicitando as credenciais de que você precisa
* O estudante escaneia e aprova o que será compartilhado
* As credenciais chegam diretamente da carteira digital do estudante
* Cada uma é verificada na hora: assinatura do emissor, status da credencial e revogação
* O resultado aparece na sua tela, sem correr atrás de documentos e sem conferência manual
  {% endtab %}

{% tab title="Español" %}
**Verifica credenciales sin recopilar documentos**

* Genera un código QR que solicite las credenciales que necesitas
* El estudiante lo escanea y aprueba lo que se va a compartir
* Las credenciales llegan directamente desde la billetera digital del estudiante
* Cada una se verifica al instante: firma del emisor, estado de la credencial y revocación
* El resultado aparece en tu pantalla, sin perseguir documentos y sin revisiones manuales
  {% endtab %}
  {% endtabs %}

### Try it yourself

To get the demo credentials into your wallet, you'll need the sandbox and the demo wallet app.

* **Presentation Sandbox:** [sandbox.rc.org](https://sandbox-rc.sunbird.org/presentation/)
* **Sunbird Demo Wallet:** [Download the Android APK](https://drive.google.com/file/d/1BeEciu6uTfZCkVzqRx09FJvarUSBYhRT/view?usp=sharing)

Use one of these test accounts to get the credentials in the wallet:

| Institute  | Email                          | Password   |
| ---------- | ------------------------------ | ---------- |
| DPS        | <krishna.sharma36@example.com> | abcd\@1234 |
| St Stephen | <rohan.das82@yopmail.com>      | abcd\@1234 |

## More demos

Have a demo of Sunbird RC for another domain? Share it on [GitHub Discussions](https://github.com/orgs/Sunbird-RC/discussions).


# Contributing

Thank you for your interest in contributing to Sunbird Registry and Credentials (RC). Contributions of every kind are welcome, and you don't need to be a programmer to make one — reporting a bug, improving a page of these docs or answering someone's question all count.

<a href="https://github.com/Sunbird-RC/sunbird-rc-core?tab=contributing-ov-file#sunbird-rc-contributing-guide" class="button primary" data-icon="github">Read the contributing guide</a> <a href="https://github.com/Sunbird-RC/sunbird-rc-core/issues?q=is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22" class="button secondary">Find a good first issue</a>

## Ask a question

Start with this documentation site, then search the [community discussions](https://github.com/Sunbird-RC/community/discussions). If you still need help, open a new discussion. See [Discussion Forum](https://rc.sunbird.org/engage/discussions) for all the ways to reach the community.

## Report bugs or request features

Search the [issue tracker](https://github.com/Sunbird-RC/sunbird-rc-core/issues) first, in case someone has already reported it. If not, [open an issue](https://github.com/Sunbird-RC/sunbird-rc-core/issues/new/choose) and pick the bug report or feature request template.

{% hint style="danger" %}
Never report security vulnerabilities in a public issue. Use the **Security → Report a vulnerability** tab on the [sunbird-rc-core repository](https://github.com/Sunbird-RC/sunbird-rc-core/security) instead.
{% endhint %}

## Contribute to the core registry and services

The [Sunbird RC contributing guide](https://github.com/Sunbird-RC/sunbird-rc-core?tab=contributing-ov-file#sunbird-rc-contributing-guide) in the `sunbird-rc-core` repository covers everything you need: setting up and building the stack, which branch to work from, running the tests, and the checklist to complete before opening a pull request.

## Contribute to the Registry CLI

Take a look at the [contributing guide for the Registry CLI](https://github.com/Sunbird-RC/registry-cli/blob/main/contributing.md) and jump straight into fixing bugs or adding new features.

## Improve documentation

Documentation fixes are real contributions and an ideal first one — if something tripped you up during setup, that's a genuine bug. Most user-facing documentation lives on this site; Markdown in the `sunbird-rc-core` repository covers the build, the services and the compose setup.

Useful documentation contributions include:

* making a page clearer or easier to follow
* fixing typos, broken links or wrong commands
* adding a section about something new
* documenting something that was previously left out

To suggest a change to this site, [open an issue](https://github.com/Sunbird-RC/sunbird-rc-core/issues/new/choose) naming the page and what should change. For in-repository docs, open a pull request.

## Before you start

Read the [Contribution Guidebook](https://rc.sunbird.org/engage/contribution-guidebook) to see how we work as a community, and the [Code of Conduct](https://rc.sunbird.org/engage/code-of-conduct) that everyone taking part is expected to follow.


# Contribution Guidebook

Thank you for your interest in contributing to Sunbird Registry and Credentials (RC)! This guidebook is designed to help you get started with contributing to the Sunbird RC project.

**There are many ways to contribute to an open-source project, even if you are not a programmer or developer. Here are some suggestions on how you can start.**

1. Start small: If you are new to open source, start with small contributions such as reporting bugs or fixing documentation.
2. Read the documentation: Read the project's documentation to understand how it works and what needs to be done.
3. Join the community: Join the project's community, ask questions, and get to know the developers and other contributors.
4. Contribute code: If you are a programmer, you can contribute code to the project. Start by looking for "good first issues" or "beginner-friendly" issues that are easy to fix.
5. Write documentation: If you are good at writing, you can help improve the project's documentation by writing tutorials, guides, or documentation.
6. Test and report bugs: Help the project by testing it and reporting bugs. This helps the developers identify and fix issues.

## How we work as a community

1. **Engage with the community**

   You can engage using [Discussions](https://github.com/Sunbird-RC/community/discussions) for general questions, Ideas & Enhancement suggestions, Show & tell, etc.

   <figure><img src="https://1708923393-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5AiA9iZeHXWMn8BoXoxo%2Fuploads%2FM5fv2qb8xqJNRaVfWI50%2Fimage.png?alt=media&#x26;token=c720c758-af15-41d4-a176-2320dc5a1f9d" alt="GitHub Discussions categories for Sunbird RC"><figcaption></figcaption></figure>
2. **Create an issue (or a ticket)**
   1. Provide sufficient details i.e. Title, Description, Screenshots, Videos, Environment, etc
   2. Create it in the [sunbird-rc-core repository](https://github.com/Sunbird-RC/sunbird-rc-core/issues/new/choose) by selecting the issue type (template) - Bug or Feature
   3. Never report a security vulnerability in a public issue — use the **Security → Report a vulnerability** tab on the [sunbird-rc-core repository](https://github.com/Sunbird-RC/sunbird-rc-core/security) instead
3. **Find issues to contribute**
   1. Look for issues/items tagged as “[good first issue](https://github.com/Sunbird-RC/sunbird-rc-core/issues?q=is%3Aissue%20is%3Aopen%20label%3A%22good%20first%20issue%22)”. If there are no good first issues, check out [the roadmap](https://github.com/orgs/Sunbird-RC/projects/16/views/1).
   2. From the Roadmap, look for [Priority items](https://github.com/orgs/Sunbird-RC/projects/16/views/6) that are not already in a Sprint
   3. Navigate using the components (labels) to find items relevant to your skillset/area of interest
   4. Comment on the ticket by tagging at least the current assignee and the reporter to get more clarity if needed or validate your approach to solving the issue. If you are clear on what needs to be done, you can go ahead & create a Pull Request to contribute code.
4. **Processes and Rituals**
   1. Assume you have identified a ticket you wish to contribute
   2. Self-assign the ticket
   3. Ensure it has sufficient details
      1. Meaningful Title e.g. As a \<user persona>, I should be able to \<do something>, so that \<I benefit from it>
      2. Clear Description e.g. What is the problem?, Proposed Solution, Implementation Approach
         1. Acceptance criteria or Test cases
   4. Labeled appropriately to tag the Component, Priority, Issue Type
   5. Assigned to someone/you - only one person ideally
   6. Estimated time/days for completion, Target date
   7. Tagged to a Sprint
   8. Tag the Component owner/maintainer to review the implementation approach, code contribution
5. **Governance**
   1. Working Group
   2. Triage team
   3. Product council
   4. Architecture council
   5. Marking the issue as a duplicate
      1. Adding \[Duplicate] in the heading and closing the issue with the original issue link as a comment


# Code of Conduct

This Code of Conduct applies to everyone who takes part in the Sunbird RC community — contributors, maintainers, adopters and anyone joining our discussions. Contributing to the project means you agree to uphold these principles.

## Our principles

* **Be considerate.** Your work and words affect users and other contributors. Think about how they will land, and remember that many people in this community work in a second or third language.
* **Be respectful.** Disagree about ideas, not people. Harassment, personal attacks, and discriminatory or exclusionary language are not acceptable.
* **Be available.** If you take on an issue or a review, keep others informed of your progress. If you need to step back, say so, so someone else can pick the work up.
* **Be honest.** Be open about what you know and what you don't, credit other people's work, and be upfront about the limitations of your contributions.
* **Exercise discretion and confidentiality at appropriate times.** Don't share other people's private information. Report security vulnerabilities privately rather than in public issues, and respect anything shared with you in confidence.

## Where this applies

These principles apply in every project space: the Sunbird RC GitHub repositories, GitHub Discussions, Discord, community calls and events.


# Roadmap

Sunbird RC is one package with two components, Registry and Credentials, which can be used on their own or together. Each component has its own release line. This page shows what is released today, what comes next, and what is planned later for each.

## Status labels

| Label              | Meaning                                                        |
| ------------------ | -------------------------------------------------------------- |
| **Released**       | Available in a published release and supported.                |
| **Experimental**   | Available, but may change; not recommended for production yet. |
| **In Development** | Actively being built; not yet in a release.                    |
| **Roadmap**        | Planned for a future release; scope may change.                |

## Current

* **Credentials v2.1.0** — Released. See the [v2.1.0 release notes](https://rc.sunbird.org/use/releases/credentialing/v2.1.0-latest-release).
* **Registry v2.0.3** — Released. See the [v2.0.3 release notes](https://rc.sunbird.org/use/releases/registry/v2.0.3).

## Next

* **Authority Service** (Registry + Credentials) — In Development. A domain-neutral administrative layer for multi-tenant access control, configuration and record review. Target release to be confirmed. See [Authority Service](https://rc.sunbird.org/learn/readme/core-capabilities#authority-service).

{% hint style="info" %}
**Coming soon.** Full scope for the next release of each component will be published here.
{% endhint %}

## Later

{% hint style="info" %}
**Coming soon.** Longer-term roadmap items will be published here.
{% endhint %}

In the meantime, you can follow progress and share ideas on [GitHub](https://github.com/orgs/Sunbird-RC/discussions).


# FAQs

## General Section

<details>

<summary><strong>Who is responsible for developing and maintaining Sunbird RC?</strong></summary>

Sunbird RC is available under the MIT open-source license. All components included in Sunbird RC are developed as open-source and are freely accessible to anyone across the globe. This project is maintained by EkStep Foundation, India.

</details>

<details>

<summary><strong>Can an entity self-host it ? What support is available to facilitate the process?</strong></summary>

Yes, It is possible for the entities to host Sunbird RC on their own, thereby retaining complete control over the data. The implementation of Sunbird RC can be completed in just 6 to 8 weeks, and consulting and system integrator organizations can be engaged to assist with the installation, configuration, operation, monitoring, and management of the system. The detailed <a href="https://rc.sunbird.org/use/developer-guide" class="button primary small" data-icon="folder">Documentation Guide</a>provided outlines the necessary steps and configurations required for setting up and implementing Sunbird RC.

</details>

<details>

<summary><strong>How can countries/organizations benefit from this?</strong></summary>

Sunbird RC offers entities the freedom to utilize, manage, and distribute the platform as they wish, without any restrictions on modifications or distribution. This flexibility allows entities to tailor the software to their specific needs and deploy it at scale to benefit their citizens/users.

</details>

<details>

<summary><strong>Can we use only Verifiable Credentials component of Sunbird RC?</strong></summary>

Yes, it is possible as credentialing is a specific and independent microservice and it can function autonomous from the registries.

</details>

<details>

<summary><strong>What makes Sunbird RC verifiable credentials secure and tamper-proof?</strong></summary>

Two methods have been implemented in the underlying architecture to ensure the security and integrity of the QR code. The first method involves compressing the QR data payloads using popular compression models to make the QR size manageable for wider readability among verifier applications. Verifier applications are required to decompress the signed QR payloads in order to access the message content. The second method involves digitally signing the QRs using cryptographic keys generated via a PKI technology that uses RSA or ECDSA algorithms. Adopter countries have the option to determine the distribution channels of the "public key" with verifiers to enable them to verify the authenticity of the signed QR code. These two approaches provide the necessary layer of security to prevent unauthorized entities from tampering with the QR content.

</details>

<details>

<summary><strong>Can the credentials issued by Sunbird RC be in multiple languages?</strong></summary>

Yes, Sunbird RC supports the issuance of credentials in multiple languages. Organizations/Countries can provide their citizens with credentials that are localized to their language of choice.

</details>

<details>

<summary><strong>Are the credentials issued by Sunbird RC usable offline?</strong></summary>

Yes, the credentials issued by Sunbird RC are usable offline.

</details>

<details>

<summary><strong>Does Sunbird RC support bulk issuance of credentials via file upload?</strong></summary>

To facilitate the issuance of credentials in bulk, a dedicated bulk API has been developed that enables organizations to issue a large number of credentials at once. This API is not directly integrated with Sunbird RC, but instead, we have built a middleware or BFF (backend for frontend) service that acts as an intermediary between the bulk API and Sunbird RC.

</details>

<details>

<summary><strong>How much time it takes to get a test instance of RC up and running it?</strong></summary>

If you already have the necessary schemas prepared, configuring RC should be a relatively quick process, possibly taking only a few hours. The docker compose file is readily accessible for this purpose.

The process of defining the schemas is similar to designing a database or entity-relationship model. It involves starting with identifying the entities and their relationships, determining the actions or flows that need to be supported, and ultimately specifying the fields for each entity.

</details>

<details>

<summary><strong>Do the private fields get stored as encrypted format?</strong></summary>

We can encrypt the private data, but the encryption service is not provided by default in the package.

</details>

<details open>

<summary><strong>Is there a sandbox environment available for testing the Sunbird RC registry engine and API handshakes?</strong></summary>

Yes, Sunbird RC provides a number of sandboxes and demos that are available for testing and familiarizing with the platform's capabilities. ~~These sandboxes can be found in the "SAMPLES" section of the Sunbird RC documentation website and include a variety of use cases and scenarios.~~

One of them is available in [education sample](https://docs.sunbirdrc.dev/sample-use-cases/edu-registries). This sample is designed to showcase how Sunbird RC can be used in an education context.

</details>

<details>

<summary><strong>Do we have the deployment scripts for running the instance in a Kubernetes cluster?</strong></summary>

Yes, Sunbird RC provides deployment scripts that can be used to run the platform in a Kubernetes cluster. You can access the deployment scripts at [sunbird-rc/Devops](https://github.com/Sunbird-RC/devops).These scripts are designed to be easy to use and provide a streamlined deployment process for running Sunbird RC in a Kubernetes environment.

</details>

<details>

<summary><strong>How are the security and privacy concerns handled when working with verifiable identity?</strong></summary>

Sunbird RC uses Verifiable Credentials (VCs) which are signed by asymmetric keys, ensuring that only the public key is shared publicly. This provides a high level of security and privacy, as the private key is kept confidential and is used only by the credential holder to prove their identity when required.

</details>

<details>

<summary><strong>How can I follow updates?</strong></summary>

Sunbird RC provides multiple channels through which you can follow updates and stay informed about the latest developments. These channels include:

* **GitHub**: Sunbird RC's [GitHub repository](https://github.com/orgs/Sunbird-RC/repositories) is the primary source for technical and project management updates. You can follow the repository to receive notifications about new releases, bug fixes, and other technical updates.
* **Social accounts**: Sunbird maintains active social media accounts on [Twitter](https://twitter.com/Sunbird_EkStep) and [LinkedIn](https://www.linkedin.com/company/sunbirdbuildingblocks/). By following these accounts, you can receive regular updates and news about the platform, as well as insights from the Sunbird team.
* **GitHub Discussions and Discord**: Sunbird RC has active discussion forums on [GitHub](https://github.com/Sunbird-RC/community/discussions) and [Discord](https://discord.gg/Q5mvw2mGC8), where community members can engage with one another and discuss topics related to the platform. These forums are a great way to stay connected with the Sunbird RC community and get involved in ongoing discussions.

</details>

<details>

<summary><strong>How can I contribute/participate?</strong></summary>

Sunbird RC welcomes contributions from the community. There are several ways in which you can contribute, including:

**Reporting bugs/requesting features**: If you encounter any issues while using Sunbird RC or have suggestions for new features, you can [report ](https://github.com/sunbird-rc/community/issues/new/choose)them on the project's GitHub repository. This helps the Sunbird RC team identify and address issues more quickly.

**Contributing to the core registry:** If you have experience with software development, you can contribute to the core registry by submitting bug fixes, code improvements, or new features. You can do this by submitting a pull request on the Sunbird RC GitHub repository.

**Contributing to the registry CLI**: If you have experience with CLI development, you can [contribute to the registry CLI ](https://github.com/Sunbird-RC/sunbird-rc-core/blob/main/tools/cli/contributing.md)by submitting code improvements or new features.

**Improving documentation:** Another way to contribute to Sunbird RC is by improving the documentation. This can include updating existing documentation, adding new sections, or improving the clarity and accuracy of the documentation.

</details>

<details>

<summary><strong>How do i get started ? Which services should i start and how? Which repository should i use for my use-case?</strong></summary>

We should understand the Sunbird registry and credentials first before jumping directly into applying it in a real use-case. we can follow the below roadmap to get started quickly -

1. Introduction - [link](https://rc.sunbird.org/)
2. Read about services and high level architecture -
   * [registry and other services](broken://pages/hISnjaCAjhkamOE1VHN3)
   * [credentialling services architecture](https://rc.sunbird.org/learn/technical-overview/credentialling/high-level-architecture)
3. Write down your requirements and the feature you can leverage to using sunbird-rc
4. Understand how to configure a schema, micro level details are here - [link](https://rc.sunbird.org/use/developers-guide/functional-registry/schema-setup/schema-configuration)
5. Check the Api references for registry - [link](https://rc.sunbird.org/api-reference/registry-apis)
6. Try out deployments with default configurations to understand more, installation guides are there
   * If your requirement is only credentialing, you can checkout this - [link](https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/docker/v2/credentialling) , Also checkout this demo project -&#x20;
     * [demo-mosip-rc](https://github.com/Sunbird-RC/demo-mosip-rc) (it uses registry for only storing data only) - this has postman collections as well to try out. And one click installation - just start with `make start`
   * If your requirement is registry and credentialing use this - [link](https://github.com/Sunbird-RC/devops/tree/main/deploy-as-code/docker/v2/registry_and_credentialling)
7. Create your own schemas and then try
8. Search [here](https://rc.sunbird.org/?q=) if there are some issues or doubts
9. Still there are issues and not resolved, reach out to community discord or github discussions

</details>

<details>

<summary><strong>What is the difference between a credential schema and a registry schema?</strong></summary>

**Credential schema** - It is a JsonSchema of draft - \`<https://json-schema.org/draft/2020-12/schema>\`. It is created and managed using credential-schema service and used in credentials service to validate the credential subject while issuing a Verifiable Credential.

**Registry Schema** - It is a JsonSchema of draft - \`<http://json-schema.org/draft-07/schema\\`>. It is used in registry service. It is responsible for -

1. Creating APIs for an entity to be managed in the registry.
2. Schema Configurations used in registry - is configured with key `_osConfig` , more details \[here]\(<https://rc.sunbird.org/use/developers-guide/functional-registry/schema-setup/schema-configuration>)

</details>

<details>

<summary><strong>What are the differences between registry release v1 and release v2?</strong></summary>

There are a couple of difference and changes between v1 and v2 releases of registry. we can read more in the release notes on github though. The main difference is here -&#x20;

v2 release of registry introduced new signing and credentialing architecture design. v2 release is configurable to use v1 signing services or the new architecture. \
The env variables in registry, which can be used to configure or switch between the two versions -

* SIGNATURE\_PROVIDER `dev.sunbirdrc.registry.service.impl.SignatureV2ServiceImpl , dev.sunbirdrc.registry.service.impl.SignatureV1ServiceImpl`
* When using v2 version, make sure all the variables which has prefix `did_`, `signature_v2_` are provided in the registry

v2 has pagination support for List entity and Search entity APIs and have different response structure for these apis then v1

Both has difference in signing services and architecture -

| Release v1 and older                                                                               | Release v2                                                                                                                                                                            |
| -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Keys used to sign should be created manually and place them in a file config.json before deploying | Keys used to sign are created when issuer is created using identity service while signing using registry. the keys are stored in db and private key part is stored in hashicorp vault |
| To add new key, create and store them in the file manually and deploy                              | Keys are dynamically created while signing                                                                                                                                            |
| Are not very safe are private keys also stored in the same file                                    | Are safe as private key is stored in hashicorp vault                                                                                                                                  |
| Supports only one signature suite `RsaSignature2018`                                               | Has support for different signature suites `Ed25519Signature2020` , `Ed25519Signature2018` ,  `RsaSignature2018`                                                                      |
| Depends on services certificate-signer, certificate-api                                            | Depends on services identity, credential-schema, credentials and the vault                                                                                                            |

v2 support complete unique indexes and indexes creation

v2 has a lot more bug fixes which makes it easy to use without facing many errors.

v2 can be used to verify any verifiable credentials(with above signature types) then just issued by itself

Above are the main differences between two releases, checkout release notes for more details

#### Facing issues while creating an entity like "User is not allowed to perform the operation on this entity" or "Exception executing consequence for rule 'Create entity owner for newly added owner fields'" or&#x20;

</details>

## Registry Section

<details>

<summary>Can an existing database, which gets routinely updated tho’ Business processes of department, be used as a source to create and dynamically update a sunbird powered registry?</summary>

Yes, we can treat the Sunbird-registry as a master registry (a layer above the source databases), which is updateable (hence, “live” at all times) by any approved changes in the source databases. However, what constitutes an “update” and how should a “change in the source database” result in an “update” in the master-registry is determined by the business processes & rules established by the program. Technically, this is feasible.

</details>

<details>

<summary>Can excel sheet or other dBs be used as an one time source for creating a registry?</summary>

Yes, this can be done through scripts that allow bulk import of the source data into the registry.

</details>

<details>

<summary>Can we configure rules-based validation on data which comes into the registry either through API or data being input through a form?</summary>

Yes, since Sunbird RC supports defining a registry schema using a JSON Schema format, the properties can be defined with validations like mentioned here: <https://json-schema.org/draft/2019-09/json-schema-validation.html#:\\~:text=JSON%20Schema%20validation%20asserts%20constraints,descriptive%20metadata%20and%20usage%20hints>.

</details>

<details>

<summary>Is there a facility to easily create a form for inputting data into registry followed by approval process?</summary>

Yes, the Sunbird RC UI supports the generation of dynamic forms, based on the schema created; as well as support creating “approval” workflows to aid the attestation & subsequent persistence of the “data” into the registry.

</details>

<details>

<summary>Can schema be re-defined (i.e., adding some extra data fields or removing certain fields)? If Yes, how versioning is managed and what happens to existing requests with old schema.</summary>

No, it doesn't support versioning now. This needs to be handled manually outside Sunbird RC 2.

</details>

<details>

<summary>Can validations be defined at field level, at the database level and also at the user interface level?</summary>

Yes, field and user interface level validations can be defined.

</details>

<details>

<summary>Does bulk upload of facilities create schema automatically, if yes all that one can do while creating schema be achieved through bulk upload also?</summary>

The schema needs to be created first, before seeding the data to the registry

</details>

<details>

<summary><strong>What databases can be used for Registry?</strong></summary>

The registry requires a main DB that is used as the main store for storing all data. The following DB providers can be used:

* Graph database (Neo4J)
* Relational databases (Postgresql, HSQLDB, H2, MariaDB, MySQL, MSSQLServer)
* NoSQL databases (Cassandra)

</details>

<details>

<summary><strong>The registry is throwing unauthorized issues (401) on retrieving entity. The registry       throws "getaddrinfo ENOTFOUND keycloak" error.</strong></summary>

In dev/local setup, it is required that keycloak hostname is added to '/etc/hosts' file.

```bash
vi /etc/hosts
# add the below content to the above file.
...
127.0.0.1 keycloak
...
```

Use \`<http://keycloak:8080/auth/realms/sunbird-rc/protocol/openid-connect/token>\` url to fetch the token

API documentation for generating the token is available here, [Broken mention](broken://pages/qiQVpwn2HYdJOyFiVjjQ) [Broken mention](broken://pages/aivBBIXUncuWGGNAtFvH)

If the above steps did not resolve the problem, please follow the next steps provided.

1. Goto the registry container / docker-compose and identify the value set for `sunbird_sso_url` . Copy the value for further user.
2. Goto keycloak admin console and select the realm Ex:`sunbird rc (if no new realm was created)` and goto `Realm Settings`
3. Paste the value copied in `Frontend URL` text box
4. Click on `Save`
5. If your url is not secure / doesn't have a SSL, goto `login` tab, select `none` for `Require SSL` and click on `Save`
6. Restart the registry

</details>

<details>

<summary><strong>How can I create QR codes using VC in Sunbird RC?</strong></summary>

Firstly [certificate API service](broken://pages/P6rPTrHCeKZWSSf9t6Or#certificate-api-service) should be configured to generate certificates.

* The certificate template should have the handlebars parameter `{{qrCode}}` to render a QR code in the certificate.
* Explore a sample template here - [svg](https://github.com/Sunbird-RC/demo-certificate-issuance/blob/main/sample.svg?short_path=bd1d135) , [html](https://raw.githubusercontent.com/Sunbird-RC/demo-certificate-issuance/main/samples/TrainingCertificate.html)

*Additionally to know more about how to create a certificate template, please go through the documentation* [*developers-guide/schema-setup/schema-configuration#certificate-template*](broken://pages/yKQbObePFqugxBEQVByS#certificate-template)

</details>

## Ownership Section

<details>

<summary><strong>Can citizens be allowed to login into the registry to view and suggest updation to his registry entry?</strong></summary>

Yes, Sunbird-RC supports “user login” and also ownership management for a schema. Hence if the registry needs to have “citizen” access; it can be enabled. Just a point to reiterate, the purpose of a registry can be non-individual centric as well (in which case, the authorized “user”, can be institutional staff roles as well).

</details>

<details>

<summary><strong>Can we we use single sign on? or use any other authentication?</strong></summary>

Currently, Sunbird works on Keycloak OAuth. However, we can write a custom service to authenticate the user, with other authentication methods.

</details>

## Consent Section

<details>

<summary><strong>Is consent given individually or can be given to a group of individuals or entities?</strong></summary>

Currently, consent is given by an individual to the entities that he/she has ownership of (i.e. to the entities which were created by him/her). Consent can be given to one or more attributes that are part of the schema.

</details>

<details>

<summary><strong>Can consent be revoked or made time bound or limited to some number of times?</strong></summary>

Currently, consent can only be revoked manually. For time/count-based revocation of consent, we need to build a custom service to handle it.

</details>

## Attestation Section

<details>

<summary><strong>Can we have automatic verification and attestation through existing databases?</strong></summary>

Yes, attestation can be done with an external system. We need to write the functionality to enable data exchange between these two systems.

</details>

## **Postgres Section**

<details>

<summary><strong>For what all purpose Postgres is used?</strong></summary>

We have three services that uses Postgres.

1. Keycloak: Data related to user management, client management, realm management, consent etc will be stored
2. Registry core: All data created under the schemas will be stored.
3. Claims: All data related to attestation flows(claims) will be stored.

Sunbird RC can work on the below DBs:

1. Graph database (Neo4J)
2. Relational databases (Postgresql, HSQLDB, H2, MariaDB, MySQL, MSSQLServer)
3. NoSQL databases (Cassandra)

</details>

## Keycloak Section

<details>

<summary><strong>How to setup keycloak with sunbird RC and what are the prerequisites needed?</strong></summary>

You can check the following registry cli <https://docs.sunbirdrc.dev/developer-documentation/installation-guide.> All the prerequisites are mentioned here. Using this cli you will be able to bring up all the services required.\
The following keycloak configurations need to be configured in SB-RC.

<https://github.com/Sunbird-RC/sunbird-rc-core/blob/main/docker-compose.yml#L36-L40>

</details>

<details>

<summary><strong>How to enable password based login in keycloak instead of otp based login?</strong></summary>

Currently, we have added custom SPI and themes to support otp based login in keycloak. If your usecase requires password based login, then the below changes need to be done in keycloak.\
**Changing the theme**\
1\. Login to keycloak admin console\
2\. Goto `Clients` > `registry-frontend`\
3\. Select `keycloak` in `Login Theme` option\
4\. Save the changes\
**Update login flow**\
1\. Login to keycloak admin console\
2\. Goto `Authentication` > `Bindings`\
3\. Select `browser` in `Browser Flow` option\
4\. Save the changes

</details>

<details>

<summary><strong>How to fix the "401 unauthorized code" error when authentication enabled and providing the correct token?</strong></summary>

Check what url host being used to generate a token

* If you are not using <http://keycloak:8080/auth> then follow these steps -
  1. Change the keycloak frontend url using keycloak UI
  2. Login to the keycloak UI
  3. Select the realm - default `sunbird-rc`
  4. Go to `General Settings`
  5. Check for the field `frontend url`
  6. i.e., if you want to use `http://localhost:8080/auth` to generate token then set this value
  7. Recreate the registry container
  8. Regenerate a new token and use.
* If you have fixed point 2, then check if the client credentials are valid -
  1. Login to keycloak UI and select the realm
  2. Go to `Credentials` tab
  3. Regenerate the secret and copy
  4. Use them as keycloak secret in the registry
  5. Env Variable exposed in docker-compose.yml is `KEYCLOAK_SECRET` which can be set in .env file and recreate the registry container

</details>

<details>

<summary><strong>How to fix the `Role creation exception` error in registry logs?</strong></summary>

In the registry, while creating/inviting an entity it throws/returns an error mentioning `Role creation exception`. This could be because `admin-api,` the client which is configured for the registry does not have the required roles. The below steps need to be configured for the same.

1. Goto keycloak admin console (<http://keycloak-host/auth/>
2. Login admin credentials
3. Goto `clients` tab in configure section on the left
4. Click on `admin-api` client and goto `Service Account Roles` tab
5. In `Client roles` drop-down, select `realm-management`
6. Make sure `manage-realm` is present `Assigned Roles` section
7. If not select `manage-realm` from `Available Roles` section and click on `Add selected`
8. Restart the registry service

</details>

## Identity Service Section

<details open>

<summary><strong>How to fix 'The database schema is not empty. Read more about how to baseline an existing production database' error?</strong></summary>

Follow the steps [here](https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining) in prisma documentation to initialise the migration with empty migration. Then restart the identity service. Or you can setup from scratch, then empty your database and start identity service first, then after run other services like registry, claim-ms, keycloak etc.

</details>

## Frontend Section

<details open>

<summary><strong>How to resolve CORS errors on local development environment?</strong></summary>

Please Refer to the link for the solution: <https://github.com/Sunbird-RC/sunbird-rc-ui#faqs>

</details>


# Glossary

| **Data**                          | \*\*Electronic data of any type. It could be simple data or composite data. \*\*                                                                                                                                                                                                                                                                                                              |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Database**                      | **A software system that stores and manages data.**                                                                                                                                                                                                                                                                                                                                           |
| **Schema**                        | **Machine readable definition of data.**                                                                                                                                                                                                                                                                                                                                                      |
| **Actor (Subject)**               | **A person, entity, or a thing who/which has been identified.**                                                                                                                                                                                                                                                                                                                               |
| **Transaction/ Interaction Data** | **Data representing details of an interaction/transaction that was done among one or more actors within a system.**                                                                                                                                                                                                                                                                           |
| **SoR (System of Record)**        | **A software system that is the primary system to enable a specific set of transactions/interactions through a set of workflows and user interfaces. Identities of actors participating in these transactions/interactions maybe linked to a registry.**                                                                                                                                      |
| **Registration**                  | **Act of registering/enrolling the actor into a system**                                                                                                                                                                                                                                                                                                                                      |
| **Claim**                         | **A statement that is made by an actor which can be verified.**                                                                                                                                                                                                                                                                                                                               |
| **Attestation**                   | **An act of verifying and authorizing specific data in a digitally signed fashion by an authorized individual/entity (whose identities are typically linked to some other registries).**                                                                                                                                                                                                      |
| **Discovery**                     | \*\*An act of finding specific entries in a registry through a search/find mechanism. \*\*                                                                                                                                                                                                                                                                                                    |
| **Assertion**                     | **An act of verifying a claim.**                                                                                                                                                                                                                                                                                                                                                              |
| **Consent**                       | **Approval of an actor given to another person/system to access the data of that actor for purposes of transaction/interaction.**                                                                                                                                                                                                                                                             |
| **Credential**                    | **Digitally represented verifiable artifacts containing a qualification, achievement, milestone, fact, etc issued to an actor for them to be able to make claims.**                                                                                                                                                                                                                           |
| **Registry**                      | **An Electronic Registry is a system, acting as a single source of truth that houses a set of common attributes of the actor in a trustable (attested) and non-repudiable (audited) fashion, made available in the control of the actor enabling actors to authenticate themselves and make claims about them with their consent which can be electronically verified by 3rd party systems.** |
| **Holder**                        | **Someone who owns the credentials as a proof and is responsible for generating presentations from them. Examples include students, employees, citizens, customers, parents of a children etc.**                                                                                                                                                                                              |
| **Issuer**                        | **A legal entity responsible for asserting claims about the holder or the subject about a verifiable event by issuing a verifiable credential to a holder. Few examples of issuers include the government issuing national ID to the citizens, Universities issuing degrees to the students and employers issuing experience certificates to the employees.**                                 |
| **Subject**                       | **An entity about which the verifiable claim is being made. For example: children, student, citizen etc.**                                                                                                                                                                                                                                                                                    |
| **Proof**                         | **A proof provides the information about the issuer of verifiable credentials,proving the authenticity of the issued credentials, such as issuer details, date of issue, time stamp, signature, etc**                                                                                                                                                                                         |
| **Verifier**                      | **An entity who is responsible for verifying an issued credential. Few examples include employers, event organizers, universities etc**.                                                                                                                                                                                                                                                      |
| **Revocation**                    | **The process of revoking or invalidating a verifiable credential**                                                                                                                                                                                                                                                                                                                           |
| **Credential Metadata**           | **A credential metadata consists of credential identifier and information to describe the properties of the credentials, such as certificate ID. It is cryptographically signed by an issuer**                                                                                                                                                                                                |


# Guide to Electronic Registries and Verifiable Credentials

{% content-ref url="/pages/ej4TyZLRm8YacbjAu3dM" %}
[Verifiable Credentials](https://rc.sunbird.org/help/comprehensive-overview-electronic-registries-and-verifiable-credentials/verifiable-credentials)
{% endcontent-ref %}

{% content-ref url="/pages/1K7ZXu0lZB4MlgoIhmP2" %}
[Electronic Registries](https://rc.sunbird.org/help/comprehensive-overview-electronic-registries-and-verifiable-credentials/electronic-registries)
{% endcontent-ref %}

{% content-ref url="/pages/ZoZRfBDU7MAicGJpLFkG" %}
[Leveraging Existing data stores](https://rc.sunbird.org/help/comprehensive-overview-electronic-registries-and-verifiable-credentials/leveraging-existing-data-stores-directories)
{% endcontent-ref %}


# Verifiable Credentials

Verifiable Credentials are the future of identity documents, academic achievements, licenses, employment, associations and more. They are digital and cryptographically secured versions of both paper based and digital credentials that can be presented across the ecosystem as a proof.

Verifiable credentials enable the organizations to instantly verify the authenticity of any credential presented to them. This eliminates the need for manual verification processes which can be time consuming and prone to errors. Verifiable credentials also make it easier for the individuals to prove their identity or qualifications etc. in a secure manner without having to provide physical documents or sensitive personal data.

Verifiable Credentials serve as a robust “instrument of trust”, & are independently verifiable (both via online & offline methods) along with supplemental capabilities like multi-lingual extensions & multimodal outputs i.e., both, paper & digital forms - thus cutting through the digital divide.

A recent example for verifiable credential is Covid 19 vaccination certificate.


# What issues will Verifiable Credentials address?

There are multiple issues with our traditional verification process. The traditional verification process is becoming increasingly difficult to manage due to its complexity and time-consuming nature. It requires the holder to show the entire credential resulting in exposing the personal information which is not even required to be shared. It can be a lengthy process to manually verify the authenticity of the document, especially in cases where multiple documents are needed for authentication.

With the advancement of technology, it is now easier than ever to create fake documents that appear authentic. This makes it difficult for individuals and organizations to trust the authenticity of any physical certificate or document they receive.

The consequences of forging physical certificates and documents can be dire, as they can lead to misuse of data, manipulation of records, frauds, scams, identity thefts and other criminal activities.

To resolve the aforementioned challenges, Verifiable Credentials play a crucial role and offer several benefits:

* Verifiable Credentials help in automation, reducing time, effort, and cost. The information that a physical credential contains can also be represented by a verifiable credential.
* Verifiable credentials are more tamper-evident and reliable than physical credentials.
* They can be issued quickly and can be instantly presented to the organizations for the verification.
* Verifiable Credentials are private, and users can always choose what attributes of their identity they want to disclose.
* These can be verified everywhere, anytime instantly.

These benefits contribute to a more efficient and secure verification process, alleviating the issues associated with traditional methods.


# What are the key roles in Verifiable Credentials?

<figure><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/VTD02AGxc1UYyJJjFEKU/image%20(1)%20(1)%20(1)%20(1)%20(1).png" alt=""><figcaption><p>Daniel H Hardman, CC BY-SA 4.0 <a href="https://creativecommons.org/licenses/by-sa/4.0">https://creativecommons.org/licenses/by-sa/4.0</a>, via Wikimedia Commons</p></figcaption></figure>

The Key roles involved in the Verifiable Credentials ecosystem are:

**Holder:** Someone who owns the credentials as a proof and is responsible for generating presentations from them. Examples include students, employees, citizens, customers, parents of a children etc.

**Issuer:** A legal entity responsible for asserting claims about the holder or the subject about a verifiable event by issuing a verifiable credential to a holder. Few examples of issuers include government issuing national ID to the citizens, Universities issuing degrees to the students and employers issuing experience certificate to the employees.

**Subject:** An entity about which the verifiable claim is being made. For example: children, student, a pet etc.

**Verifier:** An entity who is responsible for verifying an issued credentials. Few examples include employers, event organizers, universities etc.

**Verifiable Data Registry:** This refers to a role that a system may perform by mediating the creation and verification of identifiers, keys, and other relevant data, such as verifiable credential schemas, revocation registries, issuer public keys, and so on, which may be required to use verifiable credentials.


# What are the components of Verifiable Credentials?

There are 3 main components of Verifiable Credentials:

1. **Credential Metadata:** A credential metadata consists of credential identifier and information to describe the properties of the credentials, such as certificate ID. It is cryptographically signed by an issuer.
2. **Claim:** A claim is an assertion made about a subject. It describes a quality or qualities, property or properties of a subject which establish its existence and uniqueness, such as vaccination details, government IDs etc.
3. **Proof:** A proof provides the information about the issuer of verifiable credentials,proving the authenticity of the issued credentials, such as issuer details, date of issue, time stamp, signature, etc


# What are the benefits of Verifiable Credentials?

<figure><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/DUhMPtwXg2j9Jy364oqI/Artboard%207%20(1).png" alt=""><figcaption></figcaption></figure>

Verifiable credentials offer several benefits over traditional forms of identity and credential verification:

1. **Shareable:** Verifiable credentials can be easily shared across different platforms and systems, making them highly interoperable. This means that they can be used across different organizations and contexts and can be integrated with other digital systems and services.
2. **Privacy preserving:** With verifiable credentials, individuals can share only the specific information needed for a particular transaction, rather than sharing their entire identity or personal information. This reduces the risk of identity theft and enhances privacy.
3. **Improved security**: Verifiable credentials are tamper-evident and cryptographically secure, making them much harder to forge or falsify. This reduces the risk of fraud and ensures that the information being verified is accurate.
4. **Instantly Verifiable**: Verifiable credentials can be easily verified by third parties, reducing the need for manual verification processes that are time-consuming and expensive. This can lead to increased efficiency and cost savings.
5. **Greater control & data ownership:** Individuals have greater control over their own data with verifiable credentials. They can choose which information to share, with whom, and for how long. This puts individuals in control of their own data and reduces the risk of data breaches or misuse.
6. **Interoperability:** Verifiable credentials are designed to be interoperable across different systems and platforms. This means that credentials issued by one organization can be easily verified by another, even if they use different technologies or standards. This increases the usefulness and adoption of verifiable credentials.


# Digital Credentials vs Verifiable Credentials

| Digital Credentials                                                                                                                                                                                                  | Verifiable Credentials                                                                                                                                                                                                                             |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A digital credential is a digital representation of a qualification, achievement, or other form of evidence of learning or experience. It can be used to demonstrate a person's skills, knowledge, and achievements. | A verifiable credential is a type of digital credential that is designed to be shared and verified in a secure and decentralized manner. These are issued by trusted entities & include cryptographic proof that they have not been tampered with. |
| Digital credentials are not always verifiable. They may be issued in a format that is difficult to verify, such as a PDF or image file.                                                                              | Verifiable credential includes a digital signature that enables anyone to verify its authenticity and integrity.                                                                                                                                   |
| Digital credentials may be shareable, but they are often tied to a specific platform or system thus make it difficult to share across the platforms.                                                                 | Verifiable credentials can be easily shared and verified across different platforms and systems, making them highly interoperable.                                                                                                                 |
| Digital credentials may be vulnerable to fraud or tampering. Thus, there are high chances of forgery and documentation fraud.                                                                                        | Verifiable credentials, on the other hand, are designed to be secure and tamper-proof, using cryptographic methods to ensure their authenticity.                                                                                                   |


# QR code vs Verifiable QR code

## Let's first understand What is a QR code?

A QR code, short for Quick Response code, is a two-dimensional barcode that can be scanned by a QR code reader or smartphone camera to retrieve information.

QR codes can contain various types of data, such as website URLs, text, email addresses, phone numbers, and more.

QR codes are widely used in marketing, advertising, and other industries as a way to quickly provide information to customers or users. They are also used for contactless payment systems, where customers can scan a QR code to make a payment without physically swiping or inserting a credit or debit card.

QR codes are easy to create and can be printed on a paper, plastic, and metal. They can also be displayed on electronic screens, such as smartphones, tablets, and computer monitors.

### Normal QR code vs Verifiable QR code

| Normal QR Code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Verifiable QR code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A normal QR Code is a two-dimensional barcode that contains information that can be read using a QR code scanner or a smartphone camera. This information is usually a website URL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | A signed QR code encodes the verifiable data set or information within the QR itself, rather than on any website.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| QR codes are susceptible to tampering and alteration, making the verification process untrustworthy and vulnerable to hacking.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | Verifiable QR codes use digital signatures to ensure the authenticity and integrity of the data/information contained within them. When a verifiable QR code is scanned, the digital signature is verified to ensure that the data/information has not been altered or tampered with. This makes them more secure and trustworthy than normal QR code.                                                                                                                                                                                                                                  |
| QR codes are a quick and convenient way to share information such as website details, contact details etc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | Verifiable QR codes are used when the security and integrity of the data are of utmost importance. They are typically used for sensitive data, such as personal identification details, financial information, and medical records.                                                                                                                                                                                                                                                                                                                                                     |
| Normal QR codes can be read by most QR code scanners or smartphone cameras, ensuring broad compatibility across different devices and platforms                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Verifiable QR codes can still be read by most QR code scanners or smartphone cameras, maintaining compatibility across different devices and platforms. However, the verification process may require specific software or systems capable of validating the digital signatures.                                                                                                                                                                                                                                                                                                        |
| Normal QR codes may contain digital credentials, which are digital representations of qualifications, achievements, or evidence of learning or experience. These credentials can be embedded within the QR code to provide information about the individual's skills, knowledge, or accomplishments. However, it's important to note that digital credentials in normal QR codes lack the built-in mechanisms for verification and cryptographic proof found in verifiable QR codes. As a result, the authenticity and integrity of the digital credentials within normal QR codes may be more difficult to ascertain compared to verifiable QR codes. | Verifiable QR codes contain verifiable credentials, which are digital representations of qualifications, achievements, or evidence of learning or experience. These credentials are securely embedded within the QR code and include cryptographic proof of their authenticity. Verifiable credentials are issued by trusted entities and can be easily shared and verified across different platforms and systems. The presence of verifiable credentials in verifiable QR codes enhances their trustworthiness and ensures that the information contained within them can be reliably |


# Use Cases

<figure><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/SEXCz3xC7vtYwh6xI9TJ/Artboard%208%20(1).png" alt=""><figcaption></figcaption></figure>

Verifiable Credentials have several use cases across different industries and domains, including:

1. **Student IDs and Certificates:** Verifiable credentials can be used to issue and verify academic degrees, certifications, and diplomas. This can reduce the risk of credential fraud and make it easier for employers to verify the qualifications of job candidates.
2. **Healthcare Professional IDs and Credentials:** Verifiable credentials can be used to issue and verify medical licenses, certifications, and other healthcare-related credentials. This can help to ensure that healthcare professionals have the necessary qualifications and training thus ensuring the patient safety and better patient outcomes.
3. **Financial Services:** Verifiable credentials can be used to verify the identity of customers and to issue and verify financial licenses and certifications. This can reduce the risk of fraud and improve compliance with regulatory requirements.
4. **Identity Management:** Verifiable credentials can be used to issue and verify government-issued IDs, passports, and other official documents. This can improve the efficiency of government services and reduce the risk of identity theft.
5. **Employment:** Verifiable credentials can be used to issue and verify employment credentials, such as work permits, background checks, and professional licenses. This can help employers make better hiring decisions, reduce spends and time on background verification and ensure that their employees are properly qualified and trained.
6. **Supply Chain:** Verifiable credentials can be used to issue and verify the authenticity and provenance of products and materials in the supply chain. This can help to prevent counterfeiting, fraud, and other supply chain risks in the ecosystem.
7. **Civic Registration:** Verifiable credentials can offer a more secure, efficient, and privacy-preserving way to issue and verify birth and death certificates, which can benefit individuals, government agencies, and other organizations involved in the process.


# Electronic Registries

An electronic registry is a structured & live identification system that gathers, saves, and maintains uniformed updated data or information on an entity, such as a patient, person, employee, student, or facility, and is constantly updated to serve as the entity's "Single Source of Truth'' which is also verifiable.

Registries function as a shared digital infrastructure foundational layer for national digital initiatives by facilitating a common source of verifiable data that can be utilized by any Govt or private entity or system with consent for execution of a digital initiative. Such registries enable consented subjects (people, entities, things) to enroll, manage their record with the necessary degrees of verification, and use third-party services that are built on it by using its authentication and KYC services.

Electronic registries are commonly used to increase transparency, reduce fraud, and improve efficiency in various industries. For example, a government might use an electronic land registry to manage property ownership and ensure that property transfers are properly recorded and tracked. A financial institution might use an electronic securities registry to track ownership and facilitate trading of securities.

Overall, electronic registries provide a digital solution for managing information and transactions, making them faster, more efficient, and more secure than traditional paper-based systems.

{% embed url="<https://www.youtube.com/watch?v=r86n8RPemaM>" %}


# Evolution of Electronic Registries

The 1st generation of registries were purely a paper-based list maintained in registers. As part of early computerisation, such lists got digitised giving birth to the 2nd generation of registries. They were digitised data, but typically maintained in an internal database.

With the advent of the Internet and smartphones, as more systems went online, data also migrated to 3rd generation portal based systems. They partially addressed liveness and reuse. But such portals can only be used by humans by visiting a portal or mobile app, making it non-scalable and costly by not allowing other systems to access data in an automated and trustworthy manner.

<figure><img src="https://content.gitbook.com/content/5AiA9iZeHXWMn8BoXoxo/blobs/2GOAEudcuBD5hjBCNvPq/Evaluation.png" alt=""><figcaption></figcaption></figure>

### **Evolution of Registries**

4th generation electronic registries solve the three core issues with portal based approach by having open APIs through which digitally signed data is made available for read, search, and subsequent usage. Open APIs allow automated access by external systems, making data use scalable and cost efficient. Digitally signed data available via these APIs brings in tamper-resistance, electronic verifiability, and portability of data. Such registries should be designed to allow viewing and updating of data (with appropriate verification workflow) by the person or entity whose data it is by aligning incentives.

By creating 4th generation electronic registries that allow data to be kept up to date, offering open APIs for consented access, and providing data in digitally signed fashion, India can dramatically reduce the cost of repeated data collection and maintenance of various master data. Examples of registries include geographical data registry, institution registry, school registry, teacher registry, and so on.\\


# What issues will Electronic Registries address?

With the technological advancements “Digital Registries” are becoming the need of the day in every sector. These registries do not just provide data about entities they are designed for, but enable verification and authentication of the entities, thus making the information stored “reliable “ & “trustworthy”. One of example of the digital registry is AADHAAR- National Identity Registry for India, which enables storing, authentication & online verification of Indian citizens and is widely used for all Government program enrollments, beneficiary verification, and citizen’s identity data validation.

In addition, if these registries are augmented with the capability to issue digitally verifiable credentials (VC) enabling offline & online verification of the entity/holder in question can turn out to be the solution to “augment trust” & reduce frauds in any sector.

By having verified data within various registries, stakeholders and partners can easily enroll and access these services and benefits, while eliminating the need for repeated data collection and validation. Additionally, the use of open APIs allows other systems to easily onboard users and share data, further streamlining the process.


# Benefits of Electronic Registries

Electronic Registries can help organizations save time and money, reduce errors, increase security and transparency, and improve their overall data management capabilities. Some of the key benefits of electronic registries are:

1. **Improved transparency:** Electronic registries provide an audit trail, showing who has accessed or updated a record, and when. This can improve accountability, reduce fraud, and increase trust.
2. **Better data management:** Electronic registries can enable organizations to better manage and track different types of assets and transactions, providing more accurate and timely insights into their operations.
3. **Enhanced security:** Electronic registries are typically more secure than paper-based systems, using encryption, access controls, and other measures to protect data from theft, loss, or damage.
4. **Increased efficiency:** Electronic registries can streamline processes, reduce manual effort, and improve turnaround times, helping organizations save time and money.


# Registry vs Database

| Registry                                                                                                                                                                                                                                                                                                                              | Database                                                                                                                                                                                                                                                |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| An electronic registry is a structured & live identification system that gathers, saves, and maintains uniformed updated data or information on an entity, such as a patient, person, employee, student, or facility.                                                                                                                 | Database provides a way to simply store and manage the data.                                                                                                                                                                                            |
| Electronic registries have standards/schema-compliant, structured data records with unique IDs, which are accessible via API. The unique ID is present for the record itself and for each element of the entities referenced in the record. Electronic registries provide APIs, that third-party services can use to access the data. | In contrast, databases may have structured data records but may not necessarily be compliant with any standard/schema and may not have unique IDs for each element                                                                                      |
| Electronic registries are constantly updated to serve as the entity's "Single Source of Truth'' which is also verifiable. The data is updated as soon as any change occurs, and the changes are immediately reflected in the registry.                                                                                                | Unlike electronic registries, databases do not always maintain a single source of truth for an entity. Instead, multiple applications and users may have their own copies of the data, which can lead to inconsistencies or discrepancies between them. |


# Design Principles

### Principles

1. **Minimalism and Decentralisation (federated)**\
   Registries should be built for specific purposes containing just enough attributes for serving that purpose. Registries should leverage other existing registries, avoid creating multiple sources of truths, and allowing other federated linked registries to be built on top.
2. **Accountability & Non-repudiability**\
   Complexity is an inherent characteristic of large-scale ecosystems, and solutions can not be trusted and sustained if the authenticity of authorship and validity of contracts can be repudiated. Registry will enable non-repudiation of authorship and contracts as an embedded feature using user authentication and digital signatures.
3. **Empowerment & Self-maintainability**\
   \*\*\*\*Empowering data owners, by giving them the ability to view, initiate correction and control how their information is accessed or used, by giving them the ability to give and withdraw consent at the attribute level (consent-based architecture).
4. **Security & Consented Access**\
   \*\*\*\*Ensuring that data is exchanged in a secured manner with well defined privacy rules and in alignment with access allowed by data owner and issuer.
5. **Universal Access & Open APIs**\
   \*\*\*\*Enable secure digital access and interoperable communication across systems using APIs to ensure seamless integration across diverse systems.

Registries based on these principles will drive data accuracy and build trust in the system among the actors of the ecosystem.


# Use Cases

Electronic registries have numerous use cases across different industries and sectors. Here are some examples:

1. **Property Management:** Electronic land registries can be used by governments to manage and record property ownership and transfers, as well as to provide information on property boundaries, zoning regulations, and other relevant details.
2. **Healthcare:** Electronic health registries can be used to manage the data of healthcare professionals, health institutes, patients, track patient health data, manage medical records, and monitor public health issues, such as disease outbreaks.
3. **Employment:** Electronic registries can be used to manage employee records, including personal information, job history, and performance evaluations.
4. **Education:** Electronic registries can be used to manage student records, including enrollment, grades, transfer certificates, scholarships, achievements and transcripts.
5. **Agriculture:** Electronic registries can be used to manage the data relate to lands, markets, farmers, crops and seeds etc.

Overall, electronic registries offer an efficient, secure, and transparent way to manage and track different types of assets and transactions, making them useful across a wide range of industries and sectors.


# Leveraging Existing data stores

leverage existing trustworthy sources of data to accelerate registry implementation

### Why

If you are implementing a registry in a scenario where some pre-work has already happened & data exists in the form of some sort of a database, it might be prudent (if the data is deemed accurate & trustworthy) that some sort of an import mechanism be facilitated.

Benefits include faster implementation as well as alignment & utilisation of work done in the past allowing you to build on it rather than starting from scratch.

### How

If an existing database or directory where data exists which needs to be leveraged, following are the scenarios in which it can be done without compromising the core registry principles.

**Invitation for Registration Scenario**

Existing databases can be used to trigger invitations for registration to the respective registries.

**Leverage existing Data for Registration, Authentication & data pre-fill**

1. User logs in using existing SSO system
2. Select Data from connected database is pre filled in registration form based on primary key (email/phone/GST/ UDISE ID)
3. User ensures the pre filled information is correct & registers
4. Data Fields (apart from those that are self claimed) that need verification will need to be verified via prevalent systems - eg : Phone number & email via OTP or Date of Birth via Aadhar.

**Leverage existing data for pre-filling Registration form**

1. User registers themselves on the registry
2. On the page where they need to fill detailed information a button is provided to allow the user to import data fields from an existing system
3. Select Data from connected database is pre filled in registration form based on primary key (email/phone/GST/ UDISE ID)
4. User ensures the pre filled information is correct & registers
5. Data Fields (apart from those that are self claimed) that need verification will need to be verified via prevalent systems - eg : Phone number & email via OTP or Date of Birth via Aadhar.


# External Open Source Software Attributions

Sunbird RC is an independently usable digital building block and is part of overall [Sunbird](https://sunbird.org/) open-source initiative. We've compiled a list of the open-source software and libraries we use. Check out the details below, including versions, licenses, and more:

<table><thead><tr><th width="185">Open Source Used</th><th width="241">Website</th><th>License</th><th>Link to license</th></tr></thead><tbody><tr><td>Java</td><td><a href="http://openjdk.java.net/">http://openjdk.java.net/</a></td><td>GNU GPL + Linking Exception</td><td><a href="http://openjdk.java.net/legal/gplv2+ce.html">http://openjdk.java.net/legal/gplv2+ce.html</a></td></tr><tr><td>Go</td><td><a href="https://golang.org/project/">https://golang.org/project/</a></td><td>BSD Style</td><td><a href="https://golang.org/LICENSE">https://golang.org/LICENSE</a></td></tr><tr><td>Redis</td><td><a href="https://github.com/antirez/redis">https://github.com/antirez/redis</a></td><td>BSD license</td><td><a href="https://github.com/antirez/redis/blob/unstable/COPYING">https://github.com/antirez/redis/blob/unstable/COPYING</a></td></tr><tr><td>Keycloak</td><td><a href="https://www.keycloak.org/">www.keycloak.org</a></td><td>Apache 2.0 license</td><td><a href="https://github.com/keycloak/keycloak/blob/main/LICENSE.txt">https://github.com/keycloak/keycloak/blob/main/LICENSE.txt</a></td></tr><tr><td>Elastic Search</td><td><a href="https://www.elastic.co/products/elasticsearch">https://www.elastic.co/products/elasticsearch</a></td><td>Apache 2.0</td><td><a href="https://github.com/elastic/elasticsearch/blob/master/LICENSE.txt">https://github.com/elastic/elasticsearch/blob/master/LICENSE.txt</a></td></tr><tr><td>Node.js</td><td><a href="https://nodejs.org/en/">https://nodejs.org/en/</a></td><td>MIT License</td><td><a href="https://raw.githubusercontent.com/nodejs/node/master/LICENSE">https://raw.githubusercontent.com/nodejs/node/master/LICENSE</a></td></tr><tr><td>Docker</td><td><a href="https://www.docker.com/">https://www.docker.com/</a></td><td>Apache 2.0</td><td><a href="https://github.com/docker/docker/blob/master/LICENSE">https://github.com/docker/docker/blob/master/LICENSE</a></td></tr><tr><td>Nginx</td><td><a href="https://www.nginx.com/">https://www.nginx.com/</a></td><td>BSD-like</td><td><a href="http://nginx.org/LICENSE">http://nginx.org/LICENSE</a></td></tr><tr><td>Postgres</td><td><a href="https://www.postgresql.org/">https://www.postgresql.org/</a></td><td>The PostgreSQL Licence</td><td><a href="https://www.postgresql.org/about/licence/">https://www.postgresql.org/about/licence/</a></td></tr><tr><td>MinIO</td><td><a href="https://min.io/">https://min.io/</a></td><td>GNU AGPL v3</td><td><a href="https://subnet.min.io/terms-and-conditions/standard">https://subnet.min.io/terms-and-conditions/standard</a></td></tr><tr><td>Kafka</td><td><a href="https://kafka.apache.org/">https://kafka.apache.org/</a></td><td><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></td><td><a href="https://www.apache.org/licenses/">https://www.apache.org/licenses/</a></td></tr><tr><td>Tinkerpop</td><td><a href="https://tinkerpop.apache.org/gremlin.html">https://tinkerpop.apache.org/gremlin.html</a></td><td><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a></td><td><a href="https://www.apache.org/licenses/">https://www.apache.org/licenses/</a></td></tr><tr><td>karate-junit5</td><td><a href="https://github.com/karatelabs/karate">https://github.com/karatelabs/karate</a></td><td>MIT License</td><td><a href="https://github.com/karatelabs/karate?tab=MIT-1-ov-file#readme">https://github.com/karatelabs/karate?tab=MIT-1-ov-file#readme</a></td></tr><tr><td>elasticsearch rest client</td><td><a href="https://mvnrepository.com/artifact/org.elasticsearch.client">https://mvnrepository.com/artifact/org.elasticsearch.client</a></td><td>Apache License, Version 2.0</td><td><a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_license.html">https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/_license.html</a></td></tr><tr><td>json schema validator</td><td><a href="https://mvnrepository.com/artifact/com.github.java-json-tools/json-schema-validato">https://mvnrepository.com/artifact/com.github.java-json-tools/json-schema-validato</a></td><td>Apache License, Version 2.0</td><td><a href="https://github.com/java-json-tools/json-schema-validator/blob/master/LICENSE">https://github.com/java-json-tools/json-schema-validator/blob/master/LICENSE</a></td></tr><tr><td>Gson</td><td><a href="https://github.com/google/gson">https://github.com/google/gson</a></td><td>Apache 2.0</td><td><a href="https://github.com/google/gson/blob/main/LICENSE">https://github.com/google/gson/blob/main/LICENSE</a></td></tr><tr><td>AngularJS</td><td><a href="https://angularjs.org/">https://angularjs.org/</a></td><td>MIT License</td><td><a href="https://material.angularjs.org/latest/license">https://material.angularjs.org/latest/license</a></td></tr><tr><td>Apache Tomcat</td><td><a href="https://tomcat.apache.org/">https://tomcat.apache.org/</a></td><td>Apache License v2.0</td><td><a href="https://tomcat.apache.org/legal.html">https://tomcat.apache.org/legal.html</a></td></tr><tr><td>clickhouse</td><td><a href="https://clickhouse.com/">https://clickhouse.com/</a></td><td>Apache License v2.0</td><td><a href="https://github.com/ClickHouse/ClickHouse/blob/master/LICENSE">https://github.com/ClickHouse/ClickHouse/blob/master/LICENSE</a></td></tr><tr><td>Spring Framework</td><td><a href="https://github.com/spring-projects/spring-framework">https://github.com/spring-projects/spring-framework</a></td><td>Apache License v2.0</td><td><a href="https://github.com/spring-projects/spring-framework/blob/main/LICENSE.txt">https://github.com/spring-projects/spring-framework/blob/main/LICENSE.txt</a></td></tr><tr><td>Apache Commons</td><td><a href="https://commons.apache.org/">https://commons.apache.org/</a></td><td>Apache License v2.0</td><td><a href="https://commons.apache.org/proper/commons-bsf/license.html">https://commons.apache.org/proper/commons-bsf/license.html</a></td></tr><tr><td>Akka</td><td><a href="https://doc.akka.io/docs/akka/current/index.html">https://doc.akka.io/docs/akka/current/index.html</a></td><td>Apache License v2.0</td><td><a href="https://doc.akka.io/docs/akka/current/project/licenses.html">https://doc.akka.io/docs/akka/current/project/licenses.html</a></td></tr><tr><td>guava</td><td><a href="https://github.com/google/guava">https://github.com/google/guava</a></td><td>Apache License v2.0</td><td><a href="https://github.com/google/guava/blob/master/LICENSE">https://github.com/google/guava/blob/master/LICENSE</a></td></tr><tr><td>groovy-all</td><td><a href="https://github.com/apache/groovy">https://github.com/apache/groovy</a></td><td>Apache License v2.0</td><td><a href="https://github.com/apache/groovy/blob/master/LICENSE">https://github.com/apache/groovy/blob/master/LICENSE</a></td></tr><tr><td>handlebars</td><td><a href="https://handlebarsjs.com/">https://handlebarsjs.com/</a></td><td>MIT License</td><td><a href="https://github.com/handlebars-lang/handlebars.js/blob/master/LICENSE">https://github.com/handlebars-lang/handlebars.js/blob/master/LICENSE</a></td></tr><tr><td>jedis</td><td><a href="https://github.com/redis/jedis">https://github.com/redis/jedis</a></td><td>MIT License</td><td><a href="https://github.com/redis/jedis/blob/master/LICENSE">https://github.com/redis/jedis/blob/master/LICENSE</a></td></tr><tr><td>slf4j-api</td><td><a href="https://mvnrepository.com/artifact/org.slf4j/slf4j-api">https://mvnrepository.com/artifact/org.slf4j/slf4j-api</a></td><td>MIT License</td><td><a href="https://www.slf4j.org/license.html">https://www.slf4j.org/license.html</a></td></tr><tr><td>Cucumber-JVM</td><td><a href="https://cucumber.io/docs/installation/java/">https://cucumber.io/docs/installation/java/</a></td><td>MIT License</td><td><a href="https://github.com/cucumber/cucumber-jvm/blob/main/LICENCE">https://github.com/cucumber/cucumber-jvm/blob/main/LICENCE</a></td></tr><tr><td>Mockito</td><td><a href="https://site.mockito.org/">https://site.mockito.org/</a></td><td>MIT License</td><td><a href="https://github.com/mockito/mockito/blob/main/LICENSE">https://github.com/mockito/mockito/blob/main/LICENSE</a></td></tr><tr><td>React</td><td><a href="https://react.dev/">https://react.dev/</a></td><td>MIT License</td><td><a href="https://github.com/facebook/react/blob/main/LICENSE">https://github.com/facebook/react/blob/main/LICENSE</a></td></tr><tr><td>Express</td><td><a href="https://github.com/expressjs/express">https://github.com/expressjs/express</a></td><td>MIT License</td><td><a href="https://github.com/expressjs/express/blob/master/LICENSE">https://github.com/expressjs/express/blob/master/LICENSE</a></td></tr><tr><td>perf4j</td><td><a href="https://github.com/perf4j/perf4j">https://github.com/perf4j/perf4j</a></td><td>Apache License v2.0</td><td><a href="https://github.com/perf4j/perf4j/blob/master/LICENSE.txt">https://github.com/perf4j/perf4j/blob/master/LICENSE.txt</a></td></tr><tr><td>Puppeteer</td><td><a href="https://pptr.dev/">https://pptr.dev/</a></td><td>Apache License v2.0</td><td><a href="https://github.com/puppeteer/puppeteer/blob/main/LICENSE">https://github.com/puppeteer/puppeteer/blob/main/LICENSE</a></td></tr><tr><td>Digit-OSS</td><td><a href="https://github.com/egovernments/DIGIT-OSS">https://github.com/egovernments/DIGIT-OSS</a></td><td>MIT License</td><td><a href="https://github.com/egovernments/DIGIT-OSS/blob/master/LICENSE">https://github.com/egovernments/DIGIT-OSS/blob/master/LICENSE</a></td></tr><tr><td>jsonld-signatures</td><td><a href="https://github.com/digitalbazaar/jsonld-signatures">https://github.com/digitalbazaar/jsonld-signatures</a></td><td>BSD 3-Clause License</td><td><a href="https://github.com/digitalbazaar/jsonld-signatures/blob/main/LICENSE">https://github.com/digitalbazaar/jsonld-signatures/blob/main/LICENSE</a></td></tr><tr><td>JSzip</td><td><a href="https://stuk.github.io/jszip/">https://stuk.github.io/jszip/</a></td><td>MIT License</td><td><a href="https://github.com/Stuk/jszip/blob/main/LICENSE.markdown">https://github.com/Stuk/jszip/blob/main/LICENSE.markdown</a></td></tr><tr><td>Mustache</td><td><a href="https://github.com/kainjow/Mustache">https://github.com/kainjow/Mustache</a></td><td><strong>Boost Software License 1.0</strong></td><td><a href="https://github.com/kainjow/Mustache/blob/master/LICENSE">https://github.com/kainjow/Mustache/blob/master/LICENSE</a></td></tr><tr><td>Ramda</td><td><a href="https://ramdajs.com/">https://ramdajs.com/</a></td><td>MIT License</td><td><a href="https://github.com/ramda/ramda/blob/master/LICENSE.txt">https://github.com/ramda/ramda/blob/master/LICENSE.txt</a></td></tr><tr><td>gluegun</td><td><a href="https://github.com/infinitered/gluegun">https://github.com/infinitered/gluegun</a></td><td>MIT License</td><td><a href="https://github.com/infinitered/gluegun/blob/master/LICENSE">https://github.com/infinitered/gluegun/blob/master/LICENSE</a></td></tr></tbody></table>


# High-Level architecture

The microservices that make up the Sunbird RC registry, and what each one does.

<figure><img src="https://content.gitbook.com/content/7jgborogcaGcMV6ZkXme/blobs/avbxvqedLTEnR13f1CMv/high_level_diagram_registry.png" alt=""><figcaption><p>High Level Architecture Diagram</p></figcaption></figure>

The microservices built as part of Sunbird RC, and their purpose, are explained below.

## At a glance

<table data-search="false"><thead><tr><th width="200">Service</th><th>When you need it</th></tr></thead><tbody><tr><td><strong>Registry (core)</strong></td><td>Always — the core service</td></tr><tr><td><strong>Claim ms</strong></td><td>If attestation or workflows are required</td></tr><tr><td><strong>Notification ms</strong></td><td>To send SMS or email (invites, OTPs)</td></tr><tr><td><strong>Metrics service + ClickHouse</strong></td><td>To capture and query registry events</td></tr><tr><td><strong>DB</strong></td><td>Always — the main data store</td></tr><tr><td><strong>Elasticsearch</strong></td><td>To enable discovery of public data</td></tr><tr><td><strong>Keycloak</strong></td><td>For authentication and authorization (replaceable)</td></tr><tr><td><strong>Kafka</strong></td><td>For asynchronous entity creation under high load</td></tr><tr><td><strong>Encryption</strong></td><td>To store private fields encrypted</td></tr><tr><td><strong>ID Gen</strong></td><td>To generate formatted IDs for schema fields</td></tr></tbody></table>

## Core service

### Registry (core)

The core service that enables the major functionality of Sunbird RC. It exposes APIs to configure schemas and manage entities and workflows, and can create entities synchronously or asynchronously. The registry supports several database providers:

1. Graph database (Neo4j)
2. Relational databases (PostgreSQL, HSQLDB, H2, MariaDB, MySQL, MSSQLServer)
3. NoSQL databases (Cassandra)

The registry dynamically generates REST APIs for the schemas you create, and applies authentication and authorization to those APIs based on the schema configuration. It also provides a discovery API for searching the public data of a particular schema.

{% hint style="info" %}
Elasticsearch needs to be configured with the registry to enable schema discovery.
{% endhint %}

## Supporting services

### Claim ms

Needs to be enabled if attestation or workflows are required. This service handles all the claims of an attestation.

### Notification ms

Sends SMS or emails to users. The registry uses it to send invite notifications, and Keycloak uses it to send OTP messages. It can be configured with third-party plugins to send notifications.

### Metrics service

Handles all the events emitted by the registry through Kafka and stores them in ClickHouse, though the service can also connect to other databases. It exposes an API that returns all the emitted events.

### Encryption

Stores private fields configured in a schema in encrypted form in the database; they can only be decrypted by the encryption service. Enable it through the appropriate environment variables.

### ID Gen

Generates IDs in a given format for any fields in the schema. Provide the format configuration in the schema configuration, and enable the service through environment variables.

## Infrastructure

### DB

The registry requires a main database to store all data. Any of the database providers listed under [Registry (core)](#registry-core) can be used.

### ClickHouse

An open-source database used to store all the events emitted by the registry.

### Elasticsearch

Stores all public data and enables its discovery.

### Keycloak

Enables authentication and authorization of users on the APIs. It can be replaced by any OpenID Connect identity provider and OAuth2-compliant resource server.

### Kafka

Required to create entities asynchronously. If the system needs to handle high load and high availability, entity creation (with credential generation) can be processed asynchronously using Kafka.

## Video walkthrough

{% hint style="warning" %}
This video was recorded on Dec 22 for **v0.0.13**, so some details may differ from the current release.
{% endhint %}

{% embed url="<https://youtu.be/mZjYgdxu0gU>" %}
Video recorded on Dec 22. The video is recorded for v0.0.13
{% endembed %}


# Technical Specification Draft

Terminology, schemas, configuration, attestation, enrolment, discovery and consent for the Sunbird RC registry.

## Terminology

<table data-search="false"><thead><tr><th width="260">Term</th><th>Definition</th></tr></thead><tbody><tr><td><strong>Data</strong></td><td>Electronic data of any type. It could be simple data or composite data.</td></tr><tr><td><strong>Database</strong></td><td>A software system that stores and manages data.</td></tr><tr><td><strong>Schema</strong></td><td>Machine-readable definition of data.</td></tr><tr><td><strong>Actor (Subject)</strong></td><td>A person, entity or thing that has been identified.</td></tr><tr><td><strong>Transaction / Interaction Data</strong></td><td>Data representing details of an interaction or transaction done among one or more actors within a system.</td></tr><tr><td><strong>SoR (System of Record)</strong></td><td>A software system that is the primary system enabling a specific set of transactions/interactions through a set of workflows and user interfaces. Identities of actors participating in these transactions/interactions may be linked to a registry.</td></tr><tr><td><strong>Registration</strong></td><td>The act of registering or enrolling an actor into a system.</td></tr><tr><td><strong>Claim</strong></td><td>A statement made by an actor which can be verified.</td></tr><tr><td><strong>Attestation</strong></td><td>The act of verifying and authorizing specific data in a digitally signed fashion by an authorized individual/entity (whose identities are typically linked to some other registries).</td></tr><tr><td><strong>Discovery</strong></td><td>The act of finding specific entries in a registry through a search/find mechanism.</td></tr><tr><td><strong>Assertion</strong></td><td>The act of verifying a claim.</td></tr><tr><td><strong>Consent</strong></td><td>Approval given by an actor to another person/system to access the actor's data for purposes of a transaction/interaction.</td></tr><tr><td><strong>Credential</strong></td><td>A digitally represented, verifiable artifact containing a qualification, achievement, milestone, fact, etc., issued to an actor so they can make claims.</td></tr><tr><td><strong>Registry</strong></td><td>An electronic registry is a system acting as a single source of truth. It houses a set of common attributes of the actor in a trustable (attested) and non-repudiable (audited) fashion, under the actor's control — enabling actors to authenticate themselves and make claims about themselves, with their consent, which can be electronically verified by third-party systems.</td></tr><tr><td><strong>Information Provider</strong></td><td>An authorized entity or person who manages a SoR to enable specific transactions/interactions among various actors. Using their systems of record, this entity provides digitally verifiable credentials, documents, certificates, transaction/interaction data, etc. back to actors.</td></tr><tr><td><strong>Information Users</strong></td><td>An entity accessing credentials/data of an actor, with the actor's consent, to make assertions and provide various services/products.</td></tr></tbody></table>

## Workflow

![](https://content.gitbook.com/content/7jgborogcaGcMV6ZkXme/blobs/m6oM2NweWAKJatA3DIou/screenshot-2021-09-09-at-3.46.52-pm.png)

## Schema

All registries have attributes pertaining to the entity or fact in question, whether a person or a thing. A schema defines the structure and constraints of the entity. Sunbird RC uses standard JSON-LD based schemas.

In the example below, `Place` is the concept the registry stores, supporting `name`, `city`, `addressRegion` (state) and `country`.

### Example

```json
{
 "$schema": "http://json-schema.org/draft-07/schema",
 "type": "object",
 "properties": {
   "Place": {
     "$ref": "#/definitions/Place"
   }
 },
 "required": [
   "Place"
 ],
 "title": "Place",
 "definitions": {
   "Place": {
     "$id": "#/properties/Place",
     "type": "object",
     "title": "The Place Schema",
     "required": [
       "name",
       "city",
       "addressRegion",
       "country"
     ],
     "properties": {
       "name": {
         "type": "string"
       },
       "city": {
         "type": "string"
       },
       "addressLocality": {
         "type": "string"
       },
       "addressRegion": {
         "type": "string"
       },
       "country": {
         "type": "string"
       },
       "postalCode": {
         "type": "string"
       },
       "contact": {
         "type": "string"
       }
     }
   }
 }}
```

## Configuration

In addition to JSON-LD specific data types, Sunbird RC supports various extension configurations under `_osConfig`. Access, indexing, primary keys, etc. are configurable using schema configuration.

### Property data types and restrictions

Supported types:

* **String** — Unicode text; additional regular-expression restrictions can be applied.
* **Enum** — a restricted list of values.
* **Number** — numeric data.

### List of attributes

Collections of data values are also supported, as multiple values might represent an entity property — for example, subjects taught: `["english", "science", "mathematics"]`

### Visibility scope

There are three types of visibility on attributes:

<table data-search="false"><thead><tr><th width="220">Visibility</th><th>Who can access it</th></tr></thead><tbody><tr><td><strong>Public</strong></td><td>Available in discovery by default — no permission or authorization is needed.</td></tr><tr><td><strong>Private</strong> (<code>privateFields</code>)</td><td>Accessible by the owner by default; third parties can access the field with consent.</td></tr><tr><td><strong>Internal</strong></td><td>System fields that only serve internal functionality. These can never be accessed by any actor in the system.</td></tr></tbody></table>

### Primary keys for entities

Primary keys from the domain space help enforce uniqueness of information and make it easily accessible. Use `uniqueIndexFields` to configure them.

```json
"uniqueIndexFields": [ "identityValue", ... ]
```

### Index field set

Indexes help with faster access to information. Index fields can be configured based on the usage context:

```json
"indexFields": ["phoneNumber", ... ],
```

### Validation extensions

JSON-LD schema allows defining basic type constraints such as numeric type, text or a list of items. It also allows a list of possible values for given attributes (enum), and regular-expression based constraints for the value.

### Schema access API

Sunbird RC supports the following API for accessing schemas:

```http
GET /api/docs/{entityName}.json
```

The Swagger document is accessible at:

```http
GET /api/docs/swagger.json
```

## Attestation

### Configuration

Attestation on a given set of fields is configurable with schema configuration. Below is an example of an attestation requirement using DSL:

```json
 "attestationPolicies": [
 {
     "property": "experience/\[\]",
     "paths": [ "experience" ],
     "attestorEntity": "Institute",
     "conditions": "\(ATTESTOR\#$.instituteName\#.contains\(REQUESTER\#$.institute\#\)\)"
 },
  ...
 ]
```

### Attestation types

Attestation requirements will be mixed: some need human verification, while others can be completely digital. To begin with, registries can allow both manual and automatic attestation. For example, a teacher rewarding and attesting grades can be a manual activity, while an identity claim can be attested digitally by an identity provider like Aadhaar.

{% tabs %}
{% tab title="Manual attestation" %}
Manual attestation may need a workflow. By default, the registry supports raising a claim against a pre-configured attestation requirement. The claim is routed to the appropriate authority/role based on the configuration. Once the claim is approved or rejected, the respective fields in the claim show as verified or invalid.

The attestor is controlled with the `attestorEntity` configuration.
{% endtab %}

{% tab title="Automated attestation" %}
Digital registries can interoperate, sharing trusted claims and information among themselves. To do so, a claim can be routed to an automated registry verifier, which proxies for another registry and takes care of verification and attestation. Such attestation can be time-bound or one-time.

**Example:** An identity registry can be used to prove the identity of a subject without manual verification. A mobile OTP-based consent flow can verify the identity and mark the subject's name as verified. Eventually, certificates issued by educational institutions can also be verified digitally.
{% endtab %}
{% endtabs %}

### Attestation API

```http
POST /api/v1/{entityName}/{entityId}/attest/{propertyID}
{
  "action":"GRANT_CLAIM"
  ...
}
```

### Custom extensions

The attestation workflow might need custom stages and transition rules based on the use case. Attestation is extensible, so you can add or customize these workflows and add custom rules as needed.

## Enrolment / signup

### Sign up

The enrolment/signup API supports self-signup and bulk invites to register in the registry.

{% hint style="info" %}
One of the principles of the registry is to avoid loading stale data from databases, and instead give subjects control — letting them participate in registration and manage their own data, rather than someone else managing it for them.
{% endhint %}

```http
POST /api/v1/{entityName}/invite
{
"name":"Suresh",
"email":"suresh@example.com"
}
```

### Update information

```http
PATCH /api/v1/{entityName}/{entityId}
{
  "fieldPaths":["/name"]
}
```

## Discovery

### Search API

```http
POST /api/v1/search
{
  "email":"suresh@example.com"
}
```

### Directory

Example: pincode lookup

```http
POST /api/v1/search { "state":"Karnataka" }
```

## Consent API

### Authentication flow

![](https://content.gitbook.com/content/7jgborogcaGcMV6ZkXme/blobs/V5Jc3KZB9UgVrmjKc9vk/screenshot-2021-09-09-at-3.48.47-pm.png)

### Request scopes and sharing attributes

```http
GET /partner/api/v1/{entityName}
```

## Use cases

* Building a blood donor registry
* Building a simple pincode directory service
* Education registry
* Immunization
* Authentication and consent usage in a learning application


# Tech Stack and Requirements

Software versions and infrastructure needed to run the Sunbird RC registry.

## Architecture diagram

<figure><img src="https://content.gitbook.com/content/7jgborogcaGcMV6ZkXme/blobs/M5C8ux2SvP80rCKeLjeY/architecture_rc.png" alt=""><figcaption></figcaption></figure>

## Tech stack

<table><thead><tr><th width="284">Software / language</th><th>Recommended</th><th>Minimum version</th></tr></thead><tbody><tr><td>Java</td><td>11</td><td>11</td></tr><tr><td>Go</td><td>1.25.0</td><td>1.25.0</td></tr><tr><td>Linux </td><td>24.04 LTS</td><td>22.04 LTS</td></tr><tr><td>Docker</td><td>29.8.1</td><td>25.0.0</td></tr><tr><td>PostgreSQL</td><td>18.6</td><td>14</td></tr><tr><td>Redis</td><td>8.8.3</td><td>7.4.9</td></tr><tr><td>Elasticsearch</td><td>6.8.23</td><td>6.8.23</td></tr><tr><td>Keycloak</td><td>14.0.0</td><td>14.0.0</td></tr><tr><td>MinIO</td><td>RELEASE.2025-10-15T17-29-55Z</td><td>RELEASE.2025-10-15T17-29-55Z</td></tr><tr><td>Kafka (Zookeeper)</td><td>7.9.6</td><td>7.9.6</td></tr><tr><td>nginx</td><td>1.30.4</td><td>1.30.0</td></tr><tr><td>Angular</td><td>10</td><td>10</td></tr><tr><td>Kubernetes</td><td>1.37.0</td><td>1.35.0</td></tr><tr><td>Helm</td><td>4.2.4</td><td>4.0.0</td></tr><tr><td>Docker Compose</td><td>5.5.1</td><td>2.0.0</td></tr></tbody></table>

## Stock frontend interface

Angular 10

## Deployment

* **Local machine:** Docker is recommended.
* **Development:** A single VM with Docker will work. See [Getting started](broken://pages/ZnkzbsrphUupNhUbjFau) for setup steps.
* **Production:** Kubernetes is recommended. See the typical requirements below.

## Typical production requirements

<table><thead><tr><th width="220">Component</th><th width="100">Nodes</th><th>Specification</th></tr></thead><tbody><tr><td>UI (backed by CDN)</td><td>1 (small)</td><td>2 core, 4 GB RAM minimum</td></tr><tr><td>Kubernetes cluster</td><td>3</td><td>4 core, 8 GB RAM, 200 GB storage</td></tr><tr><td>PostgreSQL</td><td>2</td><td>4 core, 8 GB RAM, 500 GB storage</td></tr><tr><td>Elasticsearch (if needed)</td><td>1</td><td>4 core, 8 GB RAM, 200 GB storage</td></tr><tr><td>Load balancer</td><td>—</td><td>Based on cloud provider</td></tr></tbody></table>


# Schema

This Section describes about CRUD operations on schema and how to publish the schema.\
Following are the APIs which enables the operations on Schema


# Create Schema

## Request

## Create a Schema

<mark style="color:green;">`POST`</mark> `/api/v1/Schema`

#### Headers

| Name                                           | Type   | Description                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                          |
| authorization                                  | String | Set to `Bearer {access-token}` . The token should be a admin token |

#### Request Body

| Name                                     | Type   | Description        |
| ---------------------------------------- | ------ | ------------------ |
| name<mark style="color:red;">\*</mark>   | string | schema name        |
| schema<mark style="color:red;">\*</mark> | string | json schema        |
| status                                   | String | DRAFT \| PUBLISHED |

{% tabs %}
{% tab title="200: OK Success Response of entity Created" %}

```javascript
{
    "id": "sunbird-rc.registry.create",
    "ver": "1.0",
    "ets": 1669113026569,
    "params": {
        "resmsgid": "",
        "msgid": "7b15f6ee-eb5b-4a13-ba79-f70b3ab54fc3",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK",
    "result": {
        "Schema": {
            "osid": "1-1a2f15e7-6c54-40e9-a689-68628a3d69df"
        }
    }
}
```

{% endtab %}
{% endtabs %}

Sample Schema Request Payload

```json
{
  "name": "{schema-name}",
  "schema": "{   \"$schema\": \"http://json-schema.org/draft-07/schema\",   \"type\": \"object\",   \"properties\": {      \"Place\": {         \"$ref\": \"#/definitions/Place\"      }   },   \"required\": [      \"Place\"   ],   \"title\": \"Place\",   \"definitions\": {      \"Place\": {         \"$id\": \"#/properties/Place\",         \"type\": \"object\",         \"title\": \"The Place Schema\",         \"required\": [            \"name\",            \"city\"],         \"properties\": {            \"name\": {               \"type\": \"string\"            },            \"city\": {               \"type\": \"string\"            }},   \"_osConfig\": {      \"privateFields\": [         \"name\"      ],      \"signedFields\": [],      \"roles\": [         \"anonymous\"      ],      \"ownershipAttributes\": [],      \"attestationPolicies\": [         {            \"name\": \"schemaAttestation\",            \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\",            \"type\": \"MANUAL\",            \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\",            \"attestationProperties\": {}         }      ],      \"credentialTemplate\": {         \"@context\": [            \"https://www.w3.org/2018/credentials/v1\",            \"{someUrlForTemplate}\"         ],         \"type\": [            \"VerifiableCredential\",            \"{TypeOfCertificate}\"         ],         \"issuer\": \"{issuerName}\",         \"issuanceDate\": \"{issuanceDate}\",         \"credentialSubject\": {            \"type\": \"Place\",            \"name\": \"{name}\"},         \"evidence\": {            \"type\": \"{SomeType}\"}},      \"certificateTemplates\": {        \"html\": \"{templateUrl}\"      }   }}}}"
}
```

Important Fields in Response Body

| Field                  | Type     | Description                                                                                     |
| ---------------------- | -------- | ----------------------------------------------------------------------------------------------- |
| `result.{Schema}.osid` | `string` | The ID of the created schema in the registry, used for retrieval and modification of the entity |

### Usage

#### cURL

```shell
curl --location --request POST '{registry-url}/api/v1/Schema' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "name": "{schema-name}",
  "schema": "{   \"$schema\": \"http://json-schema.org/draft-07/schema\",   \"type\": \"object\",   \"properties\": {      \"Place\": {         \"$ref\": \"#/definitions/Place\"      }   },   \"required\": [      \"Place\"   ],   \"title\": \"Place\",   \"definitions\": {      \"Place\": {         \"$id\": \"#/properties/Place\",         \"type\": \"object\",         \"title\": \"The Place Schema\",         \"required\": [            \"name\",            \"city\"],         \"properties\": {            \"name\": {               \"type\": \"string\"            },            \"city\": {               \"type\": \"string\"            }},   \"_osConfig\": {      \"privateFields\": [         \"name\"      ],      \"signedFields\": [],      \"roles\": [         \"anonymous\"      ],      \"ownershipAttributes\": [],      \"attestationPolicies\": [         {            \"name\": \"schemaAttestation\",            \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\",            \"type\": \"MANUAL\",            \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\",            \"attestationProperties\": {}         }      ],      \"credentialTemplate\": {         \"@context\": [            \"https://www.w3.org/2018/credentials/v1\",            \"{someUrlForTemplate}\"         ],         \"type\": [            \"VerifiableCredential\",            \"{TypeOfCertificate}\"         ],         \"issuer\": \"{issuerName}\",         \"issuanceDate\": \"{issuanceDate}\",         \"credentialSubject\": {            \"type\": \"Place\",            \"name\": \"{name}\"},         \"evidence\": {            \"type\": \"{SomeType}\"}},      \"certificateTemplates\": {        \"html\": \"{templateUrl}\"      }   }}}}"
}'
```

#### HTTPie

```
printf '{
  "name": "{schema-name}",
  "schema": "{   \"$schema\": \"http://json-schema.org/draft-07/schema\",   \"type\": \"object\",   \"properties\": {      \"Place\": {         \"$ref\": \"#/definitions/Place\"      }   },   \"required\": [      \"Place\"   ],   \"title\": \"Place\",   \"definitions\": {      \"Place\": {         \"$id\": \"#/properties/Place\",         \"type\": \"object\",         \"title\": \"The Place Schema\",         \"required\": [            \"name\",            \"city\"],         \"properties\": {            \"name\": {               \"type\": \"string\"            },            \"city\": {               \"type\": \"string\"            }},   \"_osConfig\": {      \"privateFields\": [         \"name\"      ],      \"signedFields\": [],      \"roles\": [         \"anonymous\"      ],      \"ownershipAttributes\": [],      \"attestationPolicies\": [         {            \"name\": \"schemaAttestation\",            \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\",            \"type\": \"MANUAL\",            \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\",            \"attestationProperties\": {}         }      ],      \"credentialTemplate\": {         \"@context\": [            \"https://www.w3.org/2018/credentials/v1\",            \"{someUrlForTemplate}\"         ],         \"type\": [            \"VerifiableCredential\",            \"{TypeOfCertificate}\"         ],         \"issuer\": \"{issuerName}\",         \"issuanceDate\": \"{issuanceDate}\",         \"credentialSubject\": {            \"type\": \"Place\",            \"name\": \"{name}\"},         \"evidence\": {            \"type\": \"{SomeType}\"}},      \"certificateTemplates\": {        \"html\": \"{templateUrl}\"      }   }}}}"
}'| http  POST '{registry-url}/api/v1/Schema' \
 Authorization:'Bearer {access-token}' \
 Content-Type:'application/json'
```

`{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


# Get Schema

## Request

## Fetch a Schema

<mark style="color:blue;">`GET`</mark> `/api/v1/Schema/{id}`

#### Path Parameters

| Name                                 | Type   | Description                |
| ------------------------------------ | ------ | -------------------------- |
| id<mark style="color:red;">\*</mark> | String | ID of Schema to be fetched |

#### Headers

| Name                                           | Type   | Description                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                          |
| authorization                                  | String | Set to `Bearer {access-token}` . The token should be a admin token |

{% tabs %}
{% tab title="200: OK Success Response" %}

```javascript
{
    "schema": "...",
    "osUpdatedAt": "2022-11-22T10:30:27.602Z",
    "osCreatedAt": "2022-11-22T10:30:27.602Z",
    "osUpdatedBy": "0eaf6099-9591-42bb-ac5a-21bbc2b47493",
    "name": "schema",
    "osCreatedBy": "0eaf6099-9591-42bb-ac5a-21bbc2b47493",
    "osid": "1-1a2f15e7-6c54-40e9-a689-68628a3d69df",
    "osOwner": [
        "0eaf6099-9591-42bb-ac5a-21bbc2b47493"
    ],
    "status": "{schemaStatus}"
}
```

{% endtab %}
{% endtabs %}

### Usage

#### cURL

```shell
curl --location --request GET '{registry-url}/api/v1/Schema/{id}' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json'
```

#### HTTPie

```
http  GET '{registry-url}/api/v1/Schema/{id}' \
 Authorization:'Bearer {access-token}' \
 Content-Type:'application/json'
```

`{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


# Update Schema

## Request

## Create a Schema

<mark style="color:orange;">`PUT`</mark> `/api/v1/Schema/{id}`

#### Path Parameters

| Name                                 | Type   | Description                            |
| ------------------------------------ | ------ | -------------------------------------- |
| id<mark style="color:red;">\*</mark> | String | id of the schema that is to be updated |

#### Headers

| Name                                           | Type   | Description                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                          |
| authorization                                  | String | Set to `Bearer {access-token}` . The token should be a admin token |

#### Request Body

| Name                                  | Type | Description       |
| ------------------------------------- | ---- | ----------------- |
| ...<mark style="color:red;">\*</mark> |      | The entity's data |

{% tabs %}
{% tab title="200: OK Success Response of Updated Schema" %}

```javascript
{
    "id": "sunbird-rc.registry.update",
    "ver": "1.0",
    "ets": 1669117705369,
    "params": {
        "resmsgid": "",
        "msgid": "2ff44354-bb9a-4dce-93ba-053f97587df6",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

Sample Schema Request Payload

```json
{
  "schema": "{   \"$schema\": \"http://json-schema.org/draft-07/schema\",   \"type\": \"object\",   \"properties\": {      \"Place\": {         \"$ref\": \"#/definitions/Place\"      }   },   \"required\": [      \"Place\"   ],   \"title\": \"Place\",   \"definitions\": {      \"Place\": {         \"$id\": \"#/properties/Place\",         \"type\": \"object\",         \"title\": \"The Place Schema\",         \"required\": [            \"name\",            \"city\"],         \"properties\": {            \"name\": {               \"type\": \"string\"            },            \"city\": {               \"type\": \"string\"            }},   \"_osConfig\": {      \"privateFields\": [         \"name\"      ],      \"signedFields\": [],      \"roles\": [         \"anonymous\"      ],      \"ownershipAttributes\": [],      \"attestationPolicies\": [         {            \"name\": \"schemaAttestation\",            \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\",            \"type\": \"MANUAL\",            \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\",            \"attestationProperties\": {}         }      ],      \"credentialTemplate\": {         \"@context\": [            \"https://www.w3.org/2018/credentials/v1\",            \"{someUrlForTemplate}\"         ],         \"type\": [            \"VerifiableCredential\",            \"{TypeOfCertificate}\"         ],         \"issuer\": \"{issuerName}\",         \"issuanceDate\": \"{issuanceDate}\",         \"credentialSubject\": {            \"type\": \"Place\",            \"name\": \"{name}\"},         \"evidence\": {            \"type\": \"{SomeType}\"}},      \"certificateTemplates\": {        \"html\": \"{templateUrl}\"      }   }}}}"
}
```

### Usage

#### cURL

```shell
curl --location --request PUT '{registry-url}/api/v1/Schema/{id}' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "schema": "{   \"$schema\": \"http://json-schema.org/draft-07/schema\",   \"type\": \"object\",   \"properties\": {      \"Place\": {         \"$ref\": \"#/definitions/Place\"      }   },   \"required\": [      \"Place\"   ],   \"title\": \"Place\",   \"definitions\": {      \"Place\": {         \"$id\": \"#/properties/Place\",         \"type\": \"object\",         \"title\": \"The Place Schema\",         \"required\": [            \"name\",            \"city\"],         \"properties\": {            \"name\": {               \"type\": \"string\"            },            \"city\": {               \"type\": \"string\"            }},   \"_osConfig\": {      \"privateFields\": [         \"name\"      ],      \"signedFields\": [],      \"roles\": [         \"anonymous\"      ],      \"ownershipAttributes\": [],      \"attestationPolicies\": [         {            \"name\": \"schemaAttestation\",            \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\",            \"type\": \"MANUAL\",            \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\",            \"attestationProperties\": {}         }      ],      \"credentialTemplate\": {         \"@context\": [            \"https://www.w3.org/2018/credentials/v1\",            \"{someUrlForTemplate}\"         ],         \"type\": [            \"VerifiableCredential\",            \"{TypeOfCertificate}\"         ],         \"issuer\": \"{issuerName}\",         \"issuanceDate\": \"{issuanceDate}\",         \"credentialSubject\": {            \"type\": \"Place\",            \"name\": \"{name}\"},         \"evidence\": {            \"type\": \"{SomeType}\"}},      \"certificateTemplates\": {        \"html\": \"{templateUrl}\"      }   }}}}"
}'
```

#### HTTPie

```
printf '{
  "schema": "{   \"$schema\": \"http://json-schema.org/draft-07/schema\",   \"type\": \"object\",   \"properties\": {      \"Place\": {         \"$ref\": \"#/definitions/Place\"      }   },   \"required\": [      \"Place\"   ],   \"title\": \"Place\",   \"definitions\": {      \"Place\": {         \"$id\": \"#/properties/Place\",         \"type\": \"object\",         \"title\": \"The Place Schema\",         \"required\": [            \"name\",            \"city\"],         \"properties\": {            \"name\": {               \"type\": \"string\"            },            \"city\": {               \"type\": \"string\"            }},   \"_osConfig\": {      \"privateFields\": [         \"name\"      ],      \"signedFields\": [],      \"roles\": [         \"anonymous\"      ],      \"ownershipAttributes\": [],      \"attestationPolicies\": [         {            \"name\": \"schemaAttestation\",            \"conditions\": \"(ATTESTOR#$.[*]#.contains('board-cbse'))\",            \"type\": \"MANUAL\",            \"attestorPlugin\": \"did:internal:ClaimPluginActor?entity=board-cbse\",            \"attestationProperties\": {}         }      ],      \"credentialTemplate\": {         \"@context\": [            \"https://www.w3.org/2018/credentials/v1\",            \"{someUrlForTemplate}\"         ],         \"type\": [            \"VerifiableCredential\",            \"{TypeOfCertificate}\"         ],         \"issuer\": \"{issuerName}\",         \"issuanceDate\": \"{issuanceDate}\",         \"credentialSubject\": {            \"type\": \"Place\",            \"name\": \"{name}\"},         \"evidence\": {            \"type\": \"{SomeType}\"}},      \"certificateTemplates\": {        \"html\": \"{templateUrl}\"      }   }}}}"
}'| http  PUT '{registry-url}/api/v1/Schema' \
 Authorization:'Bearer {access-token}' \
 Content-Type:'application/json'
```

`{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


# Delete Schema

## Request

## Delete a Schema

<mark style="color:red;">`DELETE`</mark> `/api/v1/Schema/{id}`

#### Path Parameters

| Name                                 | Type   | Description                |
| ------------------------------------ | ------ | -------------------------- |
| id<mark style="color:red;">\*</mark> | String | ID of Schema to be fetched |

#### Headers

| Name                                           | Type   | Description                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                          |
| authorization                                  | String | Set to `Bearer {access-token}` . The token should be a admin token |

{% tabs %}
{% tab title="200: OK Success Response" %}

```javascript
{
    "schema": "...",
    "osUpdatedAt": "2022-11-22T10:30:27.602Z",
    "osCreatedAt": "2022-11-22T10:30:27.602Z",
    "osUpdatedBy": "0eaf6099-9591-42bb-ac5a-21bbc2b47493",
    "name": "schema",
    "osCreatedBy": "0eaf6099-9591-42bb-ac5a-21bbc2b47493",
    "osid": "1-1a2f15e7-6c54-40e9-a689-68628a3d69df",
    "osOwner": [
        "0eaf6099-9591-42bb-ac5a-21bbc2b47493"
    ],
    "status": "{schemaStatus}"
}
```

{% endtab %}
{% endtabs %}

### Usage

#### cURL

```shell
curl --location --request DELETE '{registry-url}/api/v1/Schema/{id}' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json'
```

#### HTTPie

```
http  DELETE '{registry-url}/api/v1/Schema/{id}' \
 Authorization:'Bearer {access-token}' \
 Content-Type:'application/json'
```

`{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


# Publish A Schema

## Request

## Publish a Schema

<mark style="color:orange;">`PUT`</mark> `/api/v1/Schema/{id}`

#### Path Parameters

| Name                                 | Type   | Description                              |
| ------------------------------------ | ------ | ---------------------------------------- |
| id<mark style="color:red;">\*</mark> | String | id of the schema that is to be published |

#### Headers

| Name                                           | Type   | Description                                                        |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                          |
| authorization                                  | String | Set to `Bearer {access-token}` . The token should be a admin token |

#### Request Body

| Name                                     | Type | Description |
| ---------------------------------------- | ---- | ----------- |
| status<mark style="color:red;">\*</mark> |      | PUBLISHED   |

{% tabs %}
{% tab title="200: OK Success Response of Published Schema" %}

```javascript
{
    "id": "sunbird-rc.registry.update",
    "ver": "1.0",
    "ets": 1669117705369,
    "params": {
        "resmsgid": "",
        "msgid": "2ff44354-bb9a-4dce-93ba-053f97587df6",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

Sample Schema Request Payload

```json
{
  "status": "PUBLISHED"
}
```

### Usage

#### cURL

```shell
curl --location --request PUT '{registry-url}/api/v1/Schema/{id}' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
  "status": "PUBLISHED"
}'
```

#### HTTPie

```
printf '{
  "status": "PUBLISHED"
}'| http  PUT '{registry-url}/api/v1/Schema' \
 Authorization:'Bearer {access-token}' \
 Content-Type:'application/json'
```

`{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


# Registry


# Using The APIs

The following guide walks you through the different Registry APIs using the example of a student-teacher registry.

## Inviting An Entity

We can create entities in the registry using the [Invite Entity API Endpoint](https://github.com/Sunbird-RC/community/blob/v2.0.0/developer-documentation/broken-reference/README.md).

To create a `Teacher` entity named Pranav Agate who teaches Math at UP Public School, we would make the following API call:

**cURL**

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

**HTTPie**

```
echo '{
	"name": "Pranav Agate",
	"phoneNumber": "1234567890",
	"email": "pranav@upps.in",
	"subject": "Math",
	"school": "UP Public School"
}' | http post \
	'http://localhost:8081/api/v1/Teacher/invite' \
	'content-type: application/json'
```

This will store the entity in the registry and return the following object:

```json
{
	"id": "open-saber.registry.invite",
	"ver": "1.0",
	"ets": 1634198998956,
	"params": {
		"resmsgid": "",
		"msgid": "3ee6a76f-d6c8-4262-a7ee-ddbe66fcb127",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK",
	"result": { "Teacher": { "osid": "1-9d6099fc-2c01-4714-bceb-55ff28c482f9" } }
}
```

Important variables in the response body:

| Field                       | In   | Type     | Description                                                                                    |
| --------------------------- | ---- | -------- | ---------------------------------------------------------------------------------------------- |
| `result.{entity-type}.osid` | body | `string` | The ID of the create entity in the registry, used for retrieval and modification of the entity |

## Requesting Access To An Entity's Data

A client application can request access to an entity's data through an OAuth 2.0 flow by creating a scope in the registry that maps (via the `User Property` mapper) the scope to give the client permission to access the data.

To go through the consent flow, we must first decide which scope to request. In this case, we will be requesting the `openid` scope to get access to all the public fields of the entity. Then, we must construct a URL to request the entity to grant us access to their data as follows:

> The following example has been indented and split into multiple lines for readability only.

```
# Keycloak's consent endpoint
http://localhost:8080/auth/realms/sunbird-rc/protocol/openid-connect/auth?
 scope=openid& # The space separated list of scopes we want the entity to grant us access to
 response_type=code& # Return an authorization code once the entity grants access
 redirect_uri=*& # Send the code to this URL
 client_id=registry-frontend # The client requesting access to the entity's data
```

Here is what the URL looks like when it's url-encoded:

`http://localhost:8080/auth/realms/sunbird-rc/protocol/openid-connect/auth?scope=openid&response_type=code&redirect_uri=*&client_id=registry-frontend`

To go through the consent flow, click on the URL and login as an entity. In this case, we can login as the `Teacher` entity we created in the [Inviting An Entity section](#inviting-an-entity) - enter `1234567890` as the username and `test` as the password.

> Here, `registry-frontend` is the preconfigured client we use to make requests to keycloak and `test` is the default password for all entities.

Once you have authenticated yourself as the `Teacher`, you will see a consent screen, asking you to grant access to `Registry Frontend`. Click `YES` to grant access to the client and continue with the consent flow.

Once you click `YES`, it will redirect you to `http://localhost:8080/auth/*`. You will see an error page, as we have not setup a frontend application to parse the response and request an access token automatically. For this example (and to gain a better understanding of how the consent flow works), we will parse keycloak's response manually.

Notice that the URL query parameters contain two variables: `session_state` and `code`. The `code` parameter is of most importance here - it is a one-time code that will allow us to retrieve an access token with access to the entity's data. Copy the value of the `code` parameter (everything after `code=` in the URL). To retrieve an access token, we make the following request:

**cURL**

```
curl --location \
	--request POST \
	--header 'content-type: application/x-www-form-urlencoded' \
	--data 'client_id=registry-frontend' \
	--data 'code={code}' \
	--data 'redirect_uri=*' \
	--data 'grant_type=authorization_code' \
	'http://localhost:8080/auth/realms/sunbird-rc/protocol/openid-connect/token'
```

**HTTPie**

```
http --form post \
	'http://localhost:8080/auth/realms/sunbird-rc/protocol/openid-connect/token' \
	'content-type: application/x-www-form-urlencoded' \
	'client_id=registry-frontend' \
	'code={code}' \
	'redirect_uri=*' \
	'grant_type=authorization_code'
```

> If you get a `invalid_grant: Code not valid` error, just go through the consent flow again. The `code` expires quickly, so try to make the request for the access token as soon as you get redirected to the redirect URL!

This API call should return a JSON object as follows:

```json
{
	"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...2cSSaBKuB58I2OYDGw",
	"expires_in": 300,
	"not-before-policy": 0,
	"refresh_expires_in": 1800,
	"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...9HulwVv12bBDUdU_nidZXo",
	"scope": "openid email profile",
	"session_state": "300f8a46-e430-4fd6-92aa-a2d337d7343e",
	"token_type": "Bearer"
}
```

Important variables in the response body:

| Field          | In   | Type     | Description                                                                    |
| -------------- | ---- | -------- | ------------------------------------------------------------------------------ |
| `access_token` | body | `string` | Access token used to retrieve/update entity                                    |
| `expires_in`   | body | `number` | Number of seconds before the access token will be declared invalid             |
| `token_type`   | body | `string` | Should be `Bearer`, else we have gotten the wrong token                        |
| `scope`        | body | `string` | This should contain `openid`, and this means we successfully got user consent! |

Once we have the access token, we can start retrieving and modifying entity data.

## Authenticating As An Entity

We can authenticate as entities using the [Authenticate As Entity API Endpoint](https://rc.sunbird.org/registry/api-reference/registry/authenticating-as-an-entity). **This step is only required if consent is turned off for the frontend client.**

So to authenticate as the `Teacher` entity we just created, we would make the following API call:

**cURL**

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

**HTTPie**

```
http --form post \
	'http://localhost:8080/auth/realms/sunbird-rc/protocol/openid-connect/token' \
	'content-type: application/x-www-form-urlencoded' \
	'client_id=registry-frontend' \
	'username=1234567890' \
	'password=test' \
	'grant_type=password'
```

> Here, `registry-frontend` is the preconfigured client we use to make requests to keycloak and `test` is the default password for all entities.

This API call should return a JSON object as follows:

```json
{
	"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...2cSSaBKuB58I2OYDGw",
	"expires_in": 300,
	"not-before-policy": 0,
	"refresh_expires_in": 1800,
	"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...9HulwVv12bBDUdU_nidZXo",
	"scope": "email profile",
	"session_state": "300f8a46-e430-4fd6-92aa-a2d337d7343e",
	"token_type": "Bearer"
}
```

Important variables in the response body:

| Field          | In   | Type     | Description                                                        |
| -------------- | ---- | -------- | ------------------------------------------------------------------ |
| `access_token` | body | `string` | Access token used to retrieve/update entity                        |
| `expires_in`   | body | `number` | Number of seconds before the access token will be declared invalid |
| `token_type`   | body | `string` | Should be `Bearer`, else we have gotten the wrong token            |
| `scope`        | body | `string` | Using this token, what information we can access about the entity  |

## Retrieving An Entity

We can retrieve entities in the registry using the [Retrieve Entity API Endpoint](https://github.com/Sunbird-RC/community/blob/v2.0.0/developer-documentation/broken-reference/README.md).

So to retrieve the entity we created earlier, we would make the following request:

**cURL**

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

**HTTPie**

```
http get \
	'http://localhost:8081/api/v1/Teacher/{id}' \
	'authorization: bearer {access-token}'
```

> Replace the `{id}` above with the entity's `osid` you saved from the create entity request. Replace the `{access-token}` with the `Teacher` entity's access token from the consent/authentication step.

This will return the entity's JSON representation as follows:

```json
{
	"phoneNumber": "1234567890",
	"school": "UP Public School",
	"subject": "Math",
	"name": "Pranav Agate",
	"osid": "{id}",
	"osOwner": ["{owner-id}"],
	"_osState/school": "DRAFT"
}
```

Important variables in the response body:

| Field              | In   | Type     | Description                                                                                                                                                                                                                            |
| ------------------ | ---- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `osOwner`          | body | `string` | User ID of the entity in Keycloak.                                                                                                                                                                                                     |
| `_osState/{field}` | body | `string` | State of an attestable field. Can be `DRAFT` (when it has not been sent for attestation), `ATTESTATION_REQUESTED` (when sent for attestation), `PUBLISHED` (when successfully attested) and `REJECTED` (when rejected by the attestor) |

## Updating An Entity

We can update entities in the registry using the [Update Entity API Endpoint](https://github.com/Sunbird-RC/community/blob/v2.0.0/developer-documentation/broken-reference/README.md).

So to update the subject our `Teacher` entity Pranav Agate teaches to `Biology`, we would make the following API call:

**cURL**

```
curl --location \
	--request 'PUT' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '{
		"name": "Pranav Agate",
		"phoneNumber": "1234567890",
		"email": "pranav@upps.in",
		"subject": "Biology",
		"school": "UP Public School"
	}' \
	'http://localhost:8081/api/v1/Teacher/{id}'
```

**HTTPie**

```
echo '{
	"name": "Pranav Agate",
	"phoneNumber": "1234567890",
	"email": "pranav@upps.in",
	"subject": "Biology",
	"school": "UP Public School"
}' | http put \
	'http://localhost:8081/api/v1/Teacher/{id}' \
	'content-type: application/json' \
	'authorization: bearer {access-token}'
```

> Replace the `{id}` above with the entity's `osid` you saved from the create entity request. Replace the `{access-token}` with the `Teacher` entity's access token from the consent/authentication step.

> We need to send the whole entity and not just the updated fields because that is how RESTful APIs work. A PUT call should replace the existing record in the database with the new object as-is. To know more about this, take a look at the accepted answer on [this SO question](https://stackoverflow.com/questions/28459418/use-of-put-vs-patch-methods-in-rest-api-real-life-scenarios).

This will update the entity in the registry and return the following object:

```json
{
	"id": "open-saber.registry.update",
	"ver": "1.0",
	"ets": 1634371946769,
	"params": {
		"resmsgid": "",
		"msgid": "d51e6e6a-027d-4a42-84bb-2ce00e31d993",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK"
}
```

## Deleting An Entity

We can delete entities in the registry using the [Delete Entity API Endpoint](https://github.com/Sunbird-RC/community/blob/v2.0.0/developer-documentation/broken-reference/README.md).

So to delete the subject our `Teacher` entity, we would make the following API call:

**cURL**

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

**HTTPie**

```
http DELETE \
	'http://localhost:8081/api/v1/Teacher/{id}' \
	'content-type: application/json' \
	'authorization: bearer {access-token}'
```

> Replace the `{id}` above with the entity's `osid` you saved from the create entity request. Replace the `{access-token}` with the `Teacher` entity's access token from the consent/authentication step.

This will delete the entity in the registry and return a blank HTTP 200 response.

## Making A Claim

To make a claim, we can use the [Claim API Endpoint](https://github.com/Sunbird-RC/community/blob/v2.0.0/developer-documentation/broken-reference/README.md).

First, let us create a `Student` entity named Prashant Joshi who also goes to UP Public School:

**cURL**

```
curl --location \
	--request 'POST' \
	--header 'content-type: application/json' \
	--data-raw '{
		"name": "Prashant Joshi",
		"phoneNumber": "9876543210",
		"email": "prashant@upps.in",
		"school": "UP Public School"
	}' \
	'http://localhost:8081/api/v1/Student/invite'
```

**HTTPie**

```
echo '{
	"name": "Prashant Joshi",
	"phoneNumber": "9876543210",
	"email": "prashant@upps.in",
	"school": "UP Public School"
}' | http post \
	'http://localhost:8081/api/v1/Student/invite' \
	'content-type: application/json'
```

Next, we can get an access token for Prashant by either making a POST request to the authentication server (see the [Authenticating As An Entity section](#authenticating-as-an-entity) to know how to do that) OR by requesting entity consent to access their data (see the [Requesting Access To An Entity's Data section](#requesting-access-to-an-entitys-data) to know how to do that). The default registry instance setup by the CLI has consent enabled, so we will follow the consent flow to retrieve an access token.

Then, we can send the claim (that Prashant is a student at UP Public School) for attestation by making the following request:

```
curl --location \
	--request 'PUT' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '"UP Public School"' \
	'http://localhost:8081/api/v1/Student/{id}/school?send=true'
```

**HTTPie**

```
echo '"UP Public School"' | http put \
	'http://localhost:8081/api/v1/Student/{id}/school' \
	'content-type: application/json' \
	'authorization: bearer {access-token}' \
	'send==true'
```

> Replace the `{id}` above with the entity's `osid` you saved from the create entity request. Replace the `{access-token}` with the `Student` entity's access token from the consent/authentication step.

This will send the claim for attestation and return the following object:

```json
{
	"id": "open-saber.registry.update",
	"ver": "1.0",
	"ets": 1634371946769,
	"params": {
		"resmsgid": "",
		"msgid": "ksi38Dsl-8dIw-492j-6vlS-84KRe0Csop35",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK"
}
```

If you retrieve the `Student` entity by following the [Retrieving An Entity section](#retrieving-an-entity), you will get the following object in response:

```json
{
	"email": "prashant@upps.in",
	"name": "Prashant Joshi",
	"phoneNumber": "9876543210",
	"school": "UP Public School",
	"osid": "{id}",
	"osOwner": ["{owner-id}"],
	"_osClaimId/school": "{claim-id}",
	"_osState/school": "ATTESTATION_REQUESTED"
}
```

Important variables in the response body:

| Field                | In   | Type     | Description                                                                                                                                                                                                                            |
| -------------------- | ---- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `osOwner`            | body | `string` | User ID of the entity in Keycloak.                                                                                                                                                                                                     |
| `_osState/{field}`   | body | `string` | State of an attestable field. Can be `DRAFT` (when it has not been sent for attestation), `ATTESTATION_REQUESTED` (when sent for attestation), `PUBLISHED` (when successfully attested) and `REJECTED` (when rejected by the attestor) |
| `_osClaimId/{field}` | body | `string` | ID of the claim made on a field, required when attesting the claim.                                                                                                                                                                    |

## Attesting/Reject A Claim

We can attest/reject an entity's claim using the [Attest Claim API Endpoint](https://github.com/Sunbird-RC/community/blob/v2.0.0/api/attesting-a-calim.md).

So to attest the claim we made in the previous section (that Prashant is a student at UP Public School), we make the following request:

**cURL**

```
curl --location \
	--request 'POST' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '{
		"action": "GRANT_CLAIM"
	}' \
	'http://localhost:8081/api/v1/Teacher/claims/{claim-id}/attest'
```

**HTTPie**

```
echo '{
	"action": "GRANT_CLAIM"
}' | http post \
	'http://localhost:8081/api/v1/Teacher/claims/{claim-id}/attest' \
	'content-type: application/json' \
	'authorization: bearer {access-token}'
```

> Replace the `{claim-id}` above with the `_osClaimId/school` you saved from the make a claim request. Replace the `{access-token}` with the `Teacher` entity's access token from the consent/authentication step. Replace `GRANT_CLAIM` with `REJECT_CLAIM` to reject the claim instead.

This will attest/reject the claim and return a blank HTTP 200 response.


# Create An Entity

To create an entity, we need to make the following HTTP request

## Request

## Create a record for entity-type

<mark style="color:green;">`POST`</mark> `/api/v1/{entity-type}`

#### Path Parameters

| Name                                          | Type   | Description                  |
| --------------------------------------------- | ------ | ---------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to create |

#### Query Parameters

| Name        | Type   | Description                                                                                                                                                          |
| ----------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| mode        | String | Query parameter whose value can be `async` if creating an entity should be asynchronously handled                                                                    |
| callbackUrl | String | Query parameter whose value will be a `web-hook url`. The webook will be called once the entity is created in the registry. This is applicable only for `async mode` |

#### Headers

| Name                                           | Type   | Description                                                                                        |
| ---------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------- |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                          |
| authorization                                  | String | Set to `Bearer {access-token}` if `roles` in schema config is not anonymous else this can be empty |

#### Request Body

| Name                                  | Type | Description       |
| ------------------------------------- | ---- | ----------------- |
| ...<mark style="color:red;">\*</mark> |      | The entity's data |

{% tabs %}
{% tab title="200: OK Success Response of entity Created" %}

```javascript
{
	"id": "sunbird-rc.registry.create",
	"ver": "1.0",
	"ets": 1634198998956,
	"params": {
		"resmsgid": "",
		"msgid": "3ee6a76f-d6c8-4262-a7ee-ddbe66fcb127",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK",
	"result": { "{entityName}": { "osid": "1-9d6099fc-2c01-4714-bceb-55ff28c482f9" } }
}
```

{% endtab %}
{% endtabs %}

Sample Request Body for Teacher as Entity-Type

```json
{
 "name": "Sunbird",
 "school": "UP Public School",
 "phoneNumber": "1234567890",
 "subject": "Math"
}
```

Important Fields in Response Body

<table><thead><tr><th width="261.3333333333333">Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>result.{entity-type}.osid</code></td><td><code>string</code></td><td>The ID of the create entity in the registry, used for retrieval and modification of the entity</td></tr></tbody></table>

### Usage

So to create a `Teacher` entity named Pranav Agate who teaches Math at UP Public School, we would make the following API call:

#### cURL

```shell
curl --location \
	--request 'POST' \
	--header 'content-type: application/json' \
	--data-raw '{
		{
            "name": "Pranav Agate",
            "school": "UP Public School",
            "subject": "Math",
            "contact": "1234567890"
        }
	}' \
	'{registry-url}/api/v1/{entity-type}/'
```

#### HTTPie

```shell
printf '{
            "name": "Pranav Agate",
            "school": "UP Public School",
            "subject": "Math",
            "contact": "1234567890"
        }' | http post \
	'{registry-url}/api/v1/{entity-type}' \
	'content-type: application/json'
```

`{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


# Invite An Entity

To invite an entity, we need to make the following HTTP request

## Invite an Entity

<mark style="color:green;">`POST`</mark> `/api/v1/{entity-type}/invite`

#### Path Parameters

| Name                                          | Type   | Description                  |
| --------------------------------------------- | ------ | ---------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to create |

#### Headers

| Name                                           | Type   | Description                                                                                              |
| ---------------------------------------------- | ------ | -------------------------------------------------------------------------------------------------------- |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                                |
| authorization                                  | String | Set to `Bearer {access-token}` if `inviteRoles` in schema config is not anonymous else this can be empty |

#### Request Body

| Name                                  | Type   | Description       |
| ------------------------------------- | ------ | ----------------- |
| ...<mark style="color:red;">\*</mark> | Object | The entity's data |

{% tabs %}
{% tab title="200: OK Success response of entity invited" %}

```json
{
	"id": "sunbird-rc.registry.invite",
	"ver": "1.0",
	"ets": 1634198998956,
	"params": {
		"resmsgid": "",
		"msgid": "3ee6a76f-d6c8-4262-a7ee-ddbe66fcb127",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK",
	"result": { "Teacher": { "osid": "1-9d6099fc-2c01-4714-bceb-55ff28c482f9" } }
}
```

{% endtab %}
{% endtabs %}

Important Fields in Response Body

| Field                       | Type     | Description                                                                                    |
| --------------------------- | -------- | ---------------------------------------------------------------------------------------------- |
| `result.{entity-type}.osid` | `string` | The ID of the create entity in the registry, used for retrieval and modification of the entity |

## Usage

So to create a `Teacher` entity named Pranav Agate who teaches Math at UP Public School, we would make the following API call:

### cURL

```
curl --location \
	--request 'POST' \
	--header 'content-type: application/json' \
	--data-raw '{
		"phoneNumber": "1234567890",
		"school": "UP Public School",
		"subject": "Math",
		"name": "Pranav Agate",
	}' \
	'{registry-url}/api/v1/Teacher/invite'
```

### HTTPie

```
printf '{
    "name": "Pranav Agate",
    "teaches": "Math",
    "school": "UP Public School"
}'| http POST '{registry-url}/api/v1/Teacher/invite' \
 Content-Type:'application/json'
```

> `{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.

#### Note: Invite API doesn't validate the required parameters. Invite API is designed to be used to invite another actor to the system with minimal information, hence required validations will not be applied. Instead, use [create an entity API](https://rc.sunbird.org/registry/api-reference/registry/create-an-entity).


# Generate token

We can authenticate with the registry as a particular entity to perform operations like retrieving, searching, updating and attesting.

## Request

To authenticate as an entity, we need to make the following request:

<mark style="color:green;">`POST`</mark> `http:/keycloak-url/auth/realms/{realm}/protocol/openid-connect/token`

#### Headers

| Name                                           | Type   | Description                                |
| ---------------------------------------------- | ------ | ------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/x-www-form-urlencoded` |

#### Request Body

| Name                                          | Type   | Description                                                                                       |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| grant\_type<mark style="color:red;">\*</mark> | String | Set to `password`                                                                                 |
| client\_id<mark style="color:red;">\*</mark>  | String | Set to `registry-frontend`                                                                        |
| username<mark style="color:red;">\*</mark>    | String | The `_osConfig.ownershipAttributes.userId` of the entity according to the schema                  |
| password<mark style="color:red;">\*</mark>    | String | Set to `abcd@123` (default password, specified in registry's application.yml/docker compose file) |

{% tabs %}
{% tab title="200: OK " %}

```json
{
	"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...2cSSaBKuB58I2OYDGw",
	"expires_in": 300,
	"not-before-policy": 0,
	"refresh_expires_in": 1800,
	"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...9HulwVv12bBDUdU_nidZXo",
	"scope": "email profile",
	"session_state": "300f8a46-e430-4fd6-92aa-a2d337d7343e",
	"token_type": "Bearer"
}
```

{% endtab %}
{% endtabs %}

Important variables in the response body:

| Field          | In   | Type     | Description                                                        |
| -------------- | ---- | -------- | ------------------------------------------------------------------ |
| `access_token` | body | `string` | Access token used to retrieve/update entity                        |
| `expires_in`   | body | `number` | Number of seconds before the access token will be declared invalid |
| `token_type`   | body | `string` | Should be `Bearer`, else we have gotten the wrong token            |
| `scope`        | body | `string` | Using this token, what information we can access about the entity  |

## Usage

### cURL

```
curl --location \
	--request POST \
	--header 'content-type: application/x-www-form-urlencoded' \
	--data 'client_id=registry-frontend' \
	--data 'username={username}' \
	--data 'password=test' \
	--data 'grant_type=password' \
	'{keycloak-url}/auth/realms/{realm}/protocol/openid-connect/token'
```

### HTTPie

```
http --form post \
	'{keycloak-url}/auth/realms/{realm}/protocol/openid-connect/token' \
	'content-type: application/x-www-form-urlencoded' \
	'client_id=registry-frontend' \
	'username={username}' \
	'password=test' \
	'grant_type=password'
```

> `{keycloak-url}` is usually <http://localhost:8080>, and `{realm}` is usually `sunbird-rc`.
>
> The `{keycloak-url}` is usually `localhost:{port}`. The port can be found under the `keycloak` section in the `docker-compose.yml` file. The `{realm}` can be found at the top of the `realm-export.json` file used to configure keycloak.


# Generate admin token

## Pre-requisites

#### Steps to create an admin role

* Goto keycloak admin page, Ex: \<domain>/auth/
* The default admin credentials will be (admin / admin). Update the default admin password for security reasons.
* Goto roles section and add a `admin` role if not present

You can create a new user or update the existing user with the above role. A [client](#steps-to-create-a-client-with-an-admin-role) can also be used if you have a backend service that will call the registry APIs.

#### Steps to create a user and attach an admin role

* Goto keycloak admin page, Ex: \<domain>/auth/
* Goto `users` section and click on `Add user` button.
* Fill in the required information and click on `Save` button
* Goto `Credential` section and provide the password for the user
* Once the user is created goto `Role Mappings` section
* Select `admin` role from the `Available Roles` and click on `Add selected`

**Use the below API to generate the token for the above user**

## Request

To authenticate as an entity, we need to make the following request:

## Generate token API &#x20;

<mark style="color:green;">`POST`</mark> `http:/keycloak-url/auth/realms/{realm}/protocol/openid-connect/token`

#### Headers

| Name                                           | Type   | Description                                |
| ---------------------------------------------- | ------ | ------------------------------------------ |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/x-www-form-urlencoded` |

#### Request Body

| Name                                          | Type   | Description                                                                                       |
| --------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------- |
| grant\_type<mark style="color:red;">\*</mark> | String | Set to `password`                                                                                 |
| client\_id<mark style="color:red;">\*</mark>  | String | Set to `registry-frontend`                                                                        |
| username<mark style="color:red;">\*</mark>    | String | The `_osConfig.ownershipAttributes.userId` of the entity according to the schema                  |
| password<mark style="color:red;">\*</mark>    | String | Set to `abcd@123` (default password, specified in registry's application.yml/docker compose file) |

{% tabs %}
{% tab title="200: OK " %}

```json
{
	"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...2cSSaBKuB58I2OYDGw",
	"expires_in": 300,
	"not-before-policy": 0,
	"refresh_expires_in": 1800,
	"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...9HulwVv12bBDUdU_nidZXo",
	"scope": "email profile",
	"session_state": "300f8a46-e430-4fd6-92aa-a2d337d7343e",
	"token_type": "Bearer"
}
```

{% endtab %}
{% endtabs %}

Important variables in the response body:

| Field          | In   | Type     | Description                                                        |
| -------------- | ---- | -------- | ------------------------------------------------------------------ |
| `access_token` | body | `string` | Access token used to retrieve/update entity                        |
| `expires_in`   | body | `number` | Number of seconds before the access token will be declared invalid |
| `token_type`   | body | `string` | Should be `Bearer`, else we have gotten the wrong token            |
| `scope`        | body | `string` | Using this token, what information we can access about the entity  |

## Usage

### cURL

```
curl --location \
	--request POST \
	--header 'content-type: application/x-www-form-urlencoded' \
	--data 'client_id=registry-frontend' \
	--data 'username={username}' \
	--data 'password=test' \
	--data 'grant_type=password' \
	'{keycloak-url}/auth/realms/{realm}/protocol/openid-connect/token'
```

### HTTPie

```
http --form post \
	'{keycloak-url}/auth/realms/{realm}/protocol/openid-connect/token' \
	'content-type: application/x-www-form-urlencoded' \
	'client_id=registry-frontend' \
	'username={username}' \
	'password=test' \
	'grant_type=password'
```

> `{keycloak-url}` is usually <http://localhost:8080>, and `{realm}` is usually `sunbird-rc`.
>
> The `{keycloak-url}` is usually `localhost:{port}`. The port can be found under the `keycloak` section in the `docker-compose.yml` file. The `{realm}` can be found at the top of the `realm-export.json` file used to configure keycloak.

#### Steps to create a client with an admin role

* Goto keycloak admin page
* Goto `clients` section and click on `Add` button
* Give a new client id and click on the save button
* Update the `access type` to `confidential`.
* Turn on `Service Accounts Enabled` button.
* Add a `Valid Redirect Url` Ex: <http://localhost:8081/auth>
* And click on the save button
* Goto `Service Account Roles` tab
* Select `admin` role from the `Available Roles` and click on `Add selected`
* Goto `Credentials` section and click on `Regenerate secret` and copy the value

**Use the below API to get the token for the above client created**

## Generate token api

<mark style="color:green;">`POST`</mark> `http:/keycloak-url/auth/realms/{realm}/protocol/openid-connect/token`

#### Headers

| Name                                           | Type   | Description                       |
| ---------------------------------------------- | ------ | --------------------------------- |
| Content-Type<mark style="color:red;">\*</mark> | String | application/x-www-form-urlencoded |

#### Request Body

| Name                                             | Type   | Description                                                 |
| ------------------------------------------------ | ------ | ----------------------------------------------------------- |
| grant\_type<mark style="color:red;">\*</mark>    |        | client\_credentials                                         |
| client\_id<mark style="color:red;">\*</mark>     | String | Use the client name that was used above                     |
| client\_secret<mark style="color:red;">\*</mark> | String | Use the client secret that was generated in the above steps |

{% tabs %}
{% tab title="200: OK " %}

```json
{
	"access_token": "eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...2cSSaBKuB58I2OYDGw",
	"expires_in": 300,
	"not-before-policy": 0,
	"refresh_expires_in": 1800,
	"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCIgOiAiSldUIiwia2lk...9HulwVv12bBDUdU_nidZXo",
	"scope": "email profile",
	"session_state": "300f8a46-e430-4fd6-92aa-a2d337d7343e",
	"token_type": "Bearer"
}
```

{% endtab %}
{% endtabs %}


# Get An Entity

To get an entity created by the owner, we need to make the following HTTP request

<mark style="color:blue;">`GET`</mark> `/api/v1/{entity-type}`

#### Path Parameters

| Name                                          | Type   | Description                    |
| --------------------------------------------- | ------ | ------------------------------ |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to retrieve |

#### Query Parameters

Use search query parameter for pagination and filters

| Name   | Type                       | Description                                                                                                                                                                                                                            |
| ------ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| search | base64 encoded data string | <p>Sets the query for searching and pagination of the data.<br>example: <br><code>eyJvZmZzZXQiOjIsImxpbWl0IjoyLCJmaWx0ZXJzIjp7fSwiZW50aXR5VHlwZSI6WyJJbnN1cmFuY2UiXX0=</code> contains { "offset": 2, "limit": 2, "filters": { } }</p> |

#### Headers

| Name                                            | Type   | Description                                                           |
| ----------------------------------------------- | ------ | --------------------------------------------------------------------- |
| authorization<mark style="color:red;">\*</mark> | String | Set to `Bearer {access-token}` A valid token of the owner is required |
| viewTemplateId                                  | String | File name of view templates configured                                |

{% tabs %}
{% tab title="200: OK Response when content-type is application/json" %}
{% code overflow="wrap" %}

```javascript
{
	"totalCount": 1,
	"nextPage": "<registry-url>/api/v1/Student?search=<base64 encoded search payload>"
	"prevPage": "<registry-url>/api/v1/Student?search=<base64 encoded search payload>"
	"data": [{
		"phoneNumber": "1234567890",
		"school": "UP Public School",
		"subject": "Math",
		"name": "Pranav Agate",
		"osid": "{id}",
		"osOwner": ["{owner-id}"],
		"_osState/school": "DRAFT"
	}]
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


# Get An Entity By Id

To get an entity, we need to make the following HTTP request

<mark style="color:blue;">`GET`</mark> `/api/v1/{entity-type}/id`

#### Path Parameters

| Name                                          | Type   | Description                      |
| --------------------------------------------- | ------ | -------------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to retrieve   |
| id<mark style="color:red;">\*</mark>          | String | The ID of the entity to retrieve |

#### Headers

| Name                                            | Type   | Description                                                                                                                                                                  |
| ----------------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| authorization<mark style="color:red;">\*</mark> | String | Set to `Bearer {access-token}` if roles in schema is not anonymous. Else authorization can be empty                                                                          |
| content-type<mark style="color:red;">\*</mark>  | String | Set to `application/json` to retrieve in json. Other allowed values include `application/vc+ld+json`, `application/ld+json`, `application/pdf`, `image/svg+xml`, `text/html` |
| template-key                                    | String | `template-key` is an optional header, it can be used for `pdf/html/svg` content type. It should be one of the keys mentioned in certificateTemplates in the schema config.   |
| template                                        | String | `template` is an optional header where we can pass the URL of the external template directly in the API. To use this `enable_external_templates` ENV needs to be enabled     |
| viewTemplateId                                  | String | File name of view templates configured                                                                                                                                       |

{% tabs %}
{% tab title="200: OK Response when content-type is application/json" %}

```javascript
{
	"phoneNumber": "1234567890",
	"school": "UP Public School",
	"subject": "Math",
	"name": "Pranav Agate",
	"osid": "{id}",
	"osOwner": ["{owner-id}"],
	"_osState/school": "DRAFT"
}
```

{% endtab %}
{% endtabs %}

Important variables in the response body:

| Field              | Type   | Description                                                                                                                                                                                                                            |
| ------------------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `_osState/{field}` | String | State of an attestable field. Can be `DRAFT` (when it has not been sent for attestation), `ATTESTATION_REQUESTED` (when sent for attestation), `PUBLISHED` (when successfully attested) and `REJECTED` (when rejected by the attestor) |
| \_osOwner          | String | User ID of the entity in Keycloak.                                                                                                                                                                                                     |


# Update An Entity

To update an entity, we need to make the following HTTP request

## Updating an Entity

<mark style="color:orange;">`PUT`</mark> `/api/v1/{entity-type}/{id}`

#### Path Parameters

| Name                                          | Type   | Description                  |
| --------------------------------------------- | ------ | ---------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to modify |
| id<mark style="color:red;">\*</mark>          | String | The ID of entity to modify   |

#### Headers

| Name                                           | Type   | Description                                                                               |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| authorization                                  | String | Set to Bearer {access-token} if roles in schema is not anonymous. Else token can be empty |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                 |

#### Request Body

| Name                                  | Type   | Description       |
| ------------------------------------- | ------ | ----------------- |
| ...<mark style="color:red;">\*</mark> | String | The entity's data |

{% tabs %}
{% tab title="200: OK Updated Entity Success Response" %}

```javascript
{
	"id": "sunbird-rc.registry.update",
	"ver": "1.0",
	"ets": 1634371946769,
	"params": {
		"resmsgid": "",
		"msgid": "d51e6e6a-027d-4a42-84bb-2ce00e31d993",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

## Usage

### cURL

```
curl --location \
	--request 'PUT' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '{
		"phoneNumber": "1234567891",
		"school": "UP Public School",
		"subject": "Math",
		"name": "Pranav Agate",
	}' \
	'{registry-url}/api/v1/{entity-type}/{id}'
```

### HTTPie

```
printf '{
	"phoneNumber": "1234567891",
	"school": "UP Public School",
	"subject": "Math",
	"name": "Pranav Agate",
}' | http put \
	'{registry-url}/api/v1/{entity-type}/{id}' \
	'content-type: application/json' \
	'authorization: bearer {access-token}'
```

> `{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.


# Create A Property Of An Entity

To add property to an existing entity, we need to make the following HTTP request

## Create a property in already existing entity

<mark style="color:green;">`POST`</mark> `/api/v1/{entity-type}/{id}/{entity-property}`

#### Path Parameters

| Name                                              | Type   | Description                                                  |
| ------------------------------------------------- | ------ | ------------------------------------------------------------ |
| entity-type<mark style="color:red;">\*</mark>     | String | Type of entity to update                                     |
| id<mark style="color:red;">\*</mark>              | String | id of the entity to update                                   |
| entity-property<mark style="color:red;">\*</mark> | String | entity Property which to be added in already existing entity |

#### Headers

| Name                                           | Type   | Description                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------- |
| authorization                                  | String | Set to `Bearer {access-token}` if roles in Schema is not anonymous. Else token can be empty |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                   |

#### Request Body

| Name                                  | Type   | Description            |
| ------------------------------------- | ------ | ---------------------- |
| ...<mark style="color:red;">\*</mark> | Object | Property to be updated |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "id": "sunbird-rc.registry.update",
    "ver": "1.0",
    "ets": 1669113170690,
    "params": {
        "resmsgid": "",
        "msgid": "85057df5-d4d6-4e7b-8bb1-a774f689e9c8",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

## Usage

### cURL

```
curl --location \
	--request 'POST' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '{
		"city": "Ahmedabad"
	}' \
	'{registry-url}/api/v1/{entity-type}/{id}/{entity-property}'
```

### HTTPie

```
printf '{
		"city": "Ahmedabad"
	}' | http POST \
	'{registry-url}/api/v1/{entity-type}/{id}/{entity-property}' \
	'content-type: application/json' \
	'authorization: Bearer {access-token}'
```

> `{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.


# Update A Property Of An Entity

To update the property of an existing entity, we need to make the following HTTP request

## Update a property which is already added to entity

<mark style="color:orange;">`PUT`</mark> `/api/v1/{entity-type}/{id}/{entity-property}/{property-id}`

#### Path Parameters

| Name                                              | Type   | Description                                                                        |
| ------------------------------------------------- | ------ | ---------------------------------------------------------------------------------- |
| entity-type<mark style="color:red;">\*</mark>     | String | Type of entity to update                                                           |
| id<mark style="color:red;">\*</mark>              | String | id of the entity to update                                                         |
| entity-property<mark style="color:red;">\*</mark> | String | entity Property which to be updated in already existing entity                     |
| property-id<mark style="color:red;">\*</mark>     | String | entity property osid which is to be updated in already existing property in entity |

#### Headers

| Name                                           | Type   | Description                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------- |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                   |
| authorization                                  | String | Set to `Bearer {access-token}` if roles in Schema is not anonymous. Else token can be empty |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "id": "sunbird-rc.registry.update",
    "ver": "1.0",
    "ets": 1669113253859,
    "params": {
        "resmsgid": "",
        "msgid": "129c291e-f089-4052-811f-025330c9b239",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

## Usage

### cURL

```
curl --location \
	--request 'POST' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '{
		"city": "Surat"
	}' \
	'{registry-url}/api/v1/{entity-type}/{id}/{entity-property}/{property-id}'
```

### HTTPie

```
printf '{
		"city": "Surat"
	}' | http POST \
	'/api/v1/{entity-type}/{id}/{entity-property}/{property-id}' \
	'content-type: application/json' \
	'authorization: Bearer {access-token}'
```

> `{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.


# Revoke a Credential

To revoke an existing VC (Verifiable Credential) or an entity, we need to make the following HTTP request

## This revokes an existing  verifiable credential

<mark style="color:green;">`POST`</mark> `/api/v1/{entity-type}/{id}/revoke`

The API revokes a verifiable credential by updating the signature data attached to it. This is done by updating the *\_osSignedData* field in the corresponding entity table to an *Empty String*. and storing the signedData in the **RevokedCredential** Registry.

#### Path Parameters

| Name                                          | Type   | Description                |
| --------------------------------------------- | ------ | -------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | Type of entity to update   |
| id<mark style="color:red;">\*</mark>          | String | id of the entity to revoke |

#### Headers

| Name                                           | Type   | Description                                                                                 |
| ---------------------------------------------- | ------ | ------------------------------------------------------------------------------------------- |
| authorization                                  | String | Set to `Bearer {access-token}` if roles in Schema is not anonymous. Else token can be empty |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                   |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
|      | String |             |

{% tabs %}
{% tab title="200: OK Entity is Succesfully revoked" %}

```json
{
    "id": "sunbird-rc.utils.revoke",
    "ver": "1.0",
    "ets": 1687421017075,
    "params": {
        "resmsgid": "",
        "msgid": "bbd1e0b7-aab4-4e91-988b-c832e9031bef",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK"
}
```

{% endtab %}

{% tab title="401: Unauthorized Issue in the token authentication - unauthorised" %}

{% endtab %}

{% tab title="500: Internal Server Error Credential is already revoked " %}

```json
revoked response: {
    "id": "sunbird-rc.utils.revoke",
    "ver": "1.0",
    "ets": 1687421091703,
    "params": {
        "resmsgid": "",
        "msgid": "70047a46-a0f1-453a-b6cf-c1cfe8e1a544",
        "err": "",
        "status": "UNSUCCESSFUL",
        "errmsg": "Credential is already revoked"
    },
    "responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

## Usage

### cURL

```
curl --location \
	--request POST \
	--header 'Content-Type: application/json' \
	--header 'Accept: application/json' \
	'{registry-url}/api/v1/{entity-type}/{id}/revoke' \


```

### HTTPie

```
http POST \
	'{registry_url}/api/v1/{entity-type}/{id}/revoke' \
	'content-type: application/json' \
	'authorization: Bearer {access-token}'
	
```

> `{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.


# Delete An Entity

To soft delete an entity, we need to make the following HTTP request

## Deleting an Entity

<mark style="color:red;">`DELETE`</mark> `/api/v1/{entity-type}/{id}`

#### Path Parameters

| Name                                          | Type   | Description                  |
| --------------------------------------------- | ------ | ---------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to modify |
| entity-id<mark style="color:red;">\*</mark>   | String | The ID of entity to modify   |

#### Headers

| Name                                           | Type   | Description                                                                               |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                 |
| authorization                                  | String | Set to Bearer {access-token} if roles in Schema is not anonymous. Else token can be empty |

{% tabs %}
{% tab title="200: OK Entity Deleted Success Response" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Usage

**cURL**

```
curl --location \
	 --request 'DELETE' \
	 --header 'content-type: application/json' \
	 --header 'authorization: Bearer {access-token}' \
	 '{registry-url}/api/v1/Teacher/{id}'
```

**HTTPie**

```
http DELETE \
	'{registry_url}/api/v1/Teacher/{id}' \
	'content-type: application/json' \
	'authorization: Bearer {access-token}'
```

> `{registry-url}` is usually <http://localhost:{port}>. The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.


# Attestation API

Attestation APIs allow us to raise an attestation for certain fields. These attestation will be sent to certain entity who then can approve/reject. This attested entity can then retrieve a document in **`VC/PDF/HTML/SVG`** format\
In the following subpages, we will see APIs that will help us in achieving the same.




---

[Next Page](https://rc.sunbird.org/llms-full.txt/1)

