> For the complete documentation index, see [llms.txt](https://docs.finema.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.finema.co/api-tutorials/did-api/register-did.md).

# DID Registration

Every DID is associated with at least one key series. Apart from registering a new DID, every other type of request is associated with a DID address (`"did_address"`) and one of the DID's key series. The client specifies the attribute `"operation"` according to the name of the request method. The current public key (`"current_key"`) in the series and the SHA-256 hash of the next public key (`"next_key_hash"`) is part of the request message whereas the current private key is used to sign the Base64 encoded request message.

To register for a new DID, a client must specify a new key series when she registers for a new DID address with `did_register` operation. The client generates the first and second public-private key pairs in the new key series. In the request message, the client then specifies the first public key (`"current_key"`) and the SHA-256 hash of the second public key (`"next_key_hash"`).  The request message is then encoded in Base64 and signed by the first private key.

## did\_register

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

#### Request Body

| Name            | Type   | Description                                                                       |
| --------------- | ------ | --------------------------------------------------------------------------------- |
| operation       | string | The method's name that is "did\_register".                                        |
| current\_key    | string | The first 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.                            |

{% tabs %}
{% tab title="200 The operation name and DID address for the registered DID will be given as the response. The DID address is derived from the current public key ("current\_key")." %}

```
{
    "operation": "did_register",
    "did_address": "did:idin:afb7ba88c76edbda55c344b70ae0cf0556d770ec256820d7185000de395391b5"
 
}
```

{% endtab %}

{% tab title="422 " %}

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

{% endtab %}
{% endtabs %}

## Example Message and Request

```
{
    "operation": "did_register",
    "current_key": "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEWquJ9+BEBDQTA/xRmx5uAHOgKMue\nw1QoAGk+2mLVWGvFBW5D3BMPYOFtGM/tvubVjwY3tr9iRI+erSQUmFIvRg==\n-----END PUBLIC KEY-----",
    "next_key_hash": "2775f71ed2bef2f395acf8781d43d0f538bf693b7c62a5bc27ec46cc839d272c"
}
```

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

```
{
    "message": "eyJjdXJyZW50X2tleSI6ICItLS0tLUJFR0lOIFBVQkxJQyBLRVktLS0tLVxuTUZrd0V3WUhLb1pJemowQ0FRWUlLb1pJemowREFRY0RRZ0FFV3F1SjkrQkVCRFFUQS94Um14NXVBSE9nS011ZVxudzFRb0FHaysybUxWV0d2RkJXNUQzQk1QWU9GdEdNL3R2dWJWandZM3RyOWlSSStlclNRVW1GSXZSZz09XG4tLS0tLUVORCBQVUJMSUMgS0VZLS0tLS0iLCAibmV4dF9rZXlfaGFzaCI6ICIyNzc1ZjcxZWQyYmVmMmYzOTVhY2Y4NzgxZDQzZDBmNTM4YmY2OTNiN2M2MmE1YmMyN2VjNDZjYzgzOWQyNzJjIiwgIm9wZXJhdGlvbiI6ICJkaWRfcmVnaXN0ZXIifQ==",
    "signature": "MEUCIQCIP/oFaQ8HKyOVNb2UGGoecC7t8F9DqLPLTvptWb6Q/wIgddkJPlh938hmFU6H9GrojIFh6NFWK0TeUkPQEBqE0jI="
}
```
