> For the complete documentation index, see [llms.txt](https://rc.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rc.sunbird.org/registry/api-reference/other-apis/sign-api.md).

# Sign API

## Sign the Payload without storing

<mark style="color:green;">`POST`</mark> `/utils/sign`

#### Headers

| Name                                            | Type   | Description                    |
| ----------------------------------------------- | ------ | ------------------------------ |
| authorization<mark style="color:red;">\*</mark> | String | Set to `Bearer {access-token}` |

#### Request Body

| Name                                  | Type   | Description                                                                                                            |
| ------------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------- |
| ...<mark style="color:red;">\*</mark> | Object | Json Object with data key and its value representing what needs to be signed and its credentialTemplate as another key |

{% tabs %}
{% tab title="200: OK Successfully generated signed credentials" %}

```javascript
{
    "id": "sunbird-rc.utils.sign",
    "ver": "1.0",
    "ets": 1669196000115,
    "params": {
        "resmsgid": "",
        "msgid": "f83bd8d6-cef5-43ff-be74-558e5f5121cc",
        "err": "",
        "status": "SUCCESSFUL",
        "errmsg": ""
    },
    "responseCode": "OK",
    "result": {
        "@context": [
            "https://www.w3.org/2018/credentials/v1",
            "{context_url}"
        ],
        "type": [
            "VerifiableCredential"
        ],
        "issuanceDate": "2021-08-27T10:57:57.237Z",
        "credentialSubject": {
            "type": "Beneficiary",
            "name": "Ade Hastuti"
        },
        "issuer": "did:web:openg2p",
        "proof": {
            "type": "RsaSignature2018",
            "created": "2022-11-23T09:33:24Z",
            "verificationMethod": "did:india",
            "proofPurpose": "assertionMethod",
            "jws": "eyJhbGciOiJQUzI1NiIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..WG0GIEQS6etth5CHzQfk73rtsGKuiQE3t_zYNKUuhPhTSECa34YWEOTLDDO2iUpufNO8DcLXLSme0XB2HVyS7E0j5sHOWHPDyJiCZRlIFO2cQl1dLCXO84p7KVuEat2AmgDBQjlMUFUQk3PhBhzRhQc0DP6EhGHcXlZMgizcwlN9japYcKuHGCXGj6VXkwoNKFcSAfvkUIaWLlPuy2pvYiNYqek-07PIVtBBQN0rWcGwe3MeHFvFkURwUK5adrnv9TKWv50AnopZSS750glIxFAXv5tfg71c_XQCwaTRa6FUGO-vCQgO8meN3yZ6EqS8oeu1jiRc5ohNGzbyOjQa3A"
        }
    }
}
```

{% endtab %}
{% endtabs %}

> Sample Request

```json
{
    "id": "sunbird-rc.utils.sign",
    "request": {
        "data": {
            "name": "Ade Hastuti",
            "date_of_birth": "2022-08-01",
            "gender": "Female"
        },
        "credentialTemplate": {
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "{context_url}"
            ],
            "type": [
                "VerifiableCredential"
            ],
            "issuanceDate": "2021-08-27T10:57:57.237Z",
            "credentialSubject": {
                "type": "Beneficiary",
                "name": "{{name}}",
            },
            "issuer": "did:web:openg2p"
        }
    }
}
```

### Usage

#### cURL

```shell
curl --location --request POST '{registry-url}/utils/sign' \
--header 'Authorization: Bearer {access-token}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "id": "sunbird-rc.utils.sign",
    "request": {
        "data": {
            "name": "Ade Hastuti",
            "date_of_birth": "2022-08-01",
            "gender": "Female"
        },
        "credentialTemplate": {
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "{context_url}"
            ],
            "type": [
                "VerifiableCredential"
            ],
            "issuanceDate": "2021-08-27T10:57:57.237Z",
            "credentialSubject": {
                "type": "Beneficiary",
                "name": "{{name}}",
            },
            "issuer": "did:web:openg2p"
        }
    }
}'
```

#### HTTPie

```shell
printf '{
    "id": "sunbird-rc.utils.sign",
    "request": {
        "data": {
            "name": "Ade Hastuti",
            "date_of_birth": "2022-08-01",
            "gender": "Female"
        },
        "credentialTemplate": {
            "@context": [
                "https://www.w3.org/2018/credentials/v1",
                "{context_url}"
            ],
            "type": [
                "VerifiableCredential"
            ],
            "issuanceDate": "2021-08-27T10:57:57.237Z",
            "credentialSubject": {
                "type": "Beneficiary",
                "name": "{{name}}",
            },
            "issuer": "did:web:openg2p"
        }
    }
}'| http POST '{registry-url}/utils/sign' \
 Authorization:'Bearer {access-token}' \
 Content-Type:'application/json'
```

> `{registry-url}` is usually [http://localhost:{port}](https://rc.sunbird.org/registry/api-reference/other-apis/http:/localhost:{port}). The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

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

```
GET https://rc.sunbird.org/registry/api-reference/other-apis/sign-api.md?ask=<question>&goal=<user_goal>
```

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

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
