# VC Registration

A credential issuer can register a new VC with `vc_register` operation. In the request message, the credential issuer must specify the current public key (`"current_key"`) in a valid key series and the SHA-256 hash of the next public key (`"next_key_hash"`).  The request message is then encoded in Base64 and signed by the current private key. Once the VC is registered, the server will respond with the VC's unique CID.

Once the credential issuer obtains a CID from the IDIN server, the issuer can then generate and send a VC with that CID to the credential holder.

{% hint style="info" %}
The private key that is used to sign a `vc_register` request must be the same key that is used to sign the VC. This ensures the VC can be verified with `"current_key"` that is recorded in the IDIN blockchain.
{% endhint %}

## vc\_register

<mark style="color:green;">`POST`</mark> `https://test-network.finema.co/vc`

#### Request Body

| Name            | Type   | Description                                                                         |
| --------------- | ------ | ----------------------------------------------------------------------------------- |
| operation       | string | The method's name that is "vc\_register".                                           |
| did\_address    | string | The DID address.                                                                    |
| current\_key    | string | The current public key in the series. It is used to verify the request's signature. |
| next\_key\_hash | string | The SHA-256 hash of the next public key in the series.                              |
| nonce           | number | The request nonce.                                                                  |

{% tabs %}
{% tab title="200 The operation name, DID address and the CID for the added VC will be given as the response." %}

```
{
  "operation": "vc_register",
  "did_address": "did:idin:afb7ba88c76edbda55c344b70ae0cf0556d770ec256820d7185000de395391b5",
  "cid": "c118304cfcc011eaaca30242c0a83005"
}
```

{% endtab %}

{% tab title="422 " %}

```
{
    "errors": [
        {
           "status": 422,
            "title": "Invalid Attribute",
            "detail": "the server cannot process the request",
        }
    ]
}
```

{% endtab %}
{% endtabs %}

## Example Message and Request

```
{
    "current_key": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEt0akFcQq6zIZqzWWqGcMf1LHEsmM\njyroeekIUmVdFy315ldxcn2fPzPqyjJVolJRvoRaVoZZZjZCBzy4yASxqw==\n-----END PUBLIC KEY-----",
    "next_key_hash": "518b7e9e4fca365dff7b6f6d4509bbe2990037a88d7633ef0faaadeba35123ed",
    "operation": "vc_register",
    "did_address": "did:idin:afb7ba88c76edbda55c344b70ae0cf0556d770ec256820d7185000de395391b5",
    "nonce": 5
}
```

The above message can then be encoded in Base64 and signed with ECDSA to obtain the following HTTP request

```
{
    "message": "eyJjdXJyZW50X2tleSI6ICItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLVxuTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFdDBha0ZjUXE2eklacXpXV3FHY01mMUxIRXNtTVxuanlyb2Vla0lVbVZkRnkzMTVsZHhjbjJmUHpQcXlqSlZvbEpSdm9SYVZvWlpaalpDQnp5NHlBU3hxdz09XG4tLS0tLUVORCBQVUJMSUMgS0VZLS0tLS0iLCAibmV4dF9rZXlfaGFzaCI6ICI1MThiN2U5ZTRmY2EzNjVkZmY3YjZmNmQ0NTA5YmJlMjk5MDAzN2E4OGQ3NjMzZWYwZmFhYWRlYmEzNTEyM2VkIiwgIm9wZXJhdGlvbiI6ICJ2Y19yZWdpc3RlciIsICJkaWRfYWRkcmVzcyI6ICJkaWQ6aWRpbjphZmI3YmE4OGM3NmVkYmRhNTVjMzQ0YjcwYWUwY2YwNTU2ZDc3MGVjMjU2ODIwZDcxODUwMDBkZTM5NTM5MWI1IiwgIm5vbmNlIjogNX0=",
    "signature": "MEUCIFSbmMEUcyjSYwq4QOXWZewn+xS/Jih04DRGKwNKlkQnAiEAuH3Es1opQ3LTTYbwyTJylskbaZOl7vSAF9RFp2Qn3TI="
}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.finema.co/api-tutorials/vc-api/register-vc.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

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