# DID

Please [generate access token](https://docs.hypersign.id/hypersign-ssi/api-doc/authentication) before proceeding.  Once you generated the `access_token`, you can pass this token as *<mark style="background-color:yellow;">bearer authorization token</mark>* in the header for all APIs.&#x20;

{% hint style="info" %}
**Note:** Some of these APIs are on-chain APIs which means they need network fee to successfully execute, so make sure that your application wallet address has $hid tokens. Read [network fee](https://docs.hypersign.id/hypersign-developer-dashboard/developer-dashboard/network-fee) section for more details.
{% endhint %}

{% hint style="info" %}
Entity Studio SSI API base URL: <https://api.entity.hypersign.id>
{% endhint %}

There are 3 steps involved in DID creation:&#x20;

* **Generate a DID Document**: Generate the data structure of the DID document.
* **Sign a DID Document (optional)**: Sign the DID Document using verification method.&#x20;
* **Register a DID Document (optional)** : Registers the signed DID Document on the blockchain network.&#x20;

{% hint style="info" %}
**Note**: You can choose not to register a DID on blockchain, in that case, the DID is concidered as private DID. We support `Ed25519VerificationKey2020` for private DIDs. Kindly read difference between [private and public DID](https://docs.hypersign.id/core-concepts/decentralized-identifier-did/private-and-public-did) in this section.&#x20;
{% endhint %}

### Create a DID

Generates the a new DID  and DID Document.&#x20;

{% openapi src="<https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media&token=695305b2-cc3b-400b-9c46-54606891a2d7>" path="/api/v1/did/create" method="post" %}
[api-json.json](https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media\&token=695305b2-cc3b-400b-9c46-54606891a2d7)
{% endopenapi %}

### Request Body Parameters

* **Namespace:** DID name space. Possible value is `testnet` &#x20;

#### Optional Parameters

* **MethodSpecificId**: Custom Id string which you want to attach with the DID. Please read [did:hid method spec](https://docs.hypersign.id/concepts/decentralized-identifier-did/did-registry#syntax-of-did-hid-method) for details about possible format.
* **Options.keyTypes**: We support `Ed25519VerificationKey2020`, `EcdsaSecp256k1RecoveryMethod2020` verification method key types. So only these two are possible values. Read the full [specification here](https://docs.hypersign.id/core-concepts/specifications/supported-signature-algorithms).
* **Options.publicKey**: Please pass  the `options.publickey` property only for `Ed25519VerificationKey2020` verification method key type. For `EcdsaSecp256k1RecoveryMethod2020` , this property can be kept blank.  Its value would be publickey (in multi base format)
* **Options.walletAddress:** Please pass `options.walletAddress` for keyType `EcdsaSecp256k1RecoveryMethod2020`
* **Options.chainId:** ChainId in HEX format. For example for Etheruem main net, the chain id would be  `0x1`. This property is only required for keytype `EcdsaSecp256k1RecoveryMethod2020`&#x20;

{% hint style="info" %}
**Note**: If no optional parameters are provided then, did will be created of verification key method type `Ed25519VerificationKey2020`
{% endhint %}

{% hint style="info" %}
**Note:** If you want to create DID for blockchain wallet addresses like EVM wallets, Cosmos wallets, you should use keyType as . Read  `EcdsaSecp256k1RecoveryMethod2020`
{% endhint %}

### Register a DID

Registers a Signed DID Document in [DID registry](https://docs.hypersign.id/core-concepts/decentralized-identifier-did/did-registry). The Gas fee ([network fee](https://docs.hypersign.id/hypersign-developer-dashboard/developer-dashboard/network-fee)) for this DID registration will be done by applications' walletAddress.&#x20;

{% openapi src="<https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media&token=695305b2-cc3b-400b-9c46-54606891a2d7>" path="/api/v1/did/register" method="post" %}
[api-json.json](https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media\&token=695305b2-cc3b-400b-9c46-54606891a2d7)
{% endopenapi %}

#### Request Parameters

* **didDocument :**  DID documented generated using `/api1/v1/did/create` API
* **verificationMethodId** :  Verification Method id of referred verification method in the didDocument

**Optional Parameters**

* **clientSpec :** Wallet specifications which are used to sign the didDocument string. Use `eth-personalSign` for Metamask and `cosmos-ADR036` for Keplr wallet. Learn more about client specifications [here](https://docs.hypersign.id/core-concepts/specifications/client-specification).
* **signature:** If didDocument is signed using client wallets (Metamask or Keply) then pass the signature hex string.&#x20;

Note: Read how to use Metamask to create Hypersign DID.&#x20;

### Resolve a DID

Given a DID Id (example: `did:hid:testnet:0x123123123123`), this API will resolve the corresponding DID Document from the [DID registry](https://docs.hypersign.id/core-concepts/decentralized-identifier-did/did-registry) (or Hypersign Blockchain).&#x20;

{% openapi src="<https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media&token=695305b2-cc3b-400b-9c46-54606891a2d7>" path="/api/v1/did/resolve/{did}" method="get" %}
[api-json.json](https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media\&token=695305b2-cc3b-400b-9c46-54606891a2d7)
{% endopenapi %}

### Fetch all DIDs for your apps

{% openapi src="<https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media&token=695305b2-cc3b-400b-9c46-54606891a2d7>" path="/api/v1/did" method="get" %}
[api-json.json](https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media\&token=695305b2-cc3b-400b-9c46-54606891a2d7)
{% endopenapi %}

### Update a DID

Update a DIDDocument

{% openapi src="<https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media&token=695305b2-cc3b-400b-9c46-54606891a2d7>" path="/api/v1/did" method="patch" %}
[api-json.json](https://1497651738-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MOLDOibYYcG4PCSEDDL%2Fuploads%2FjYVydJufhHpdtxi9oslY%2Fapi-json.json?alt=media\&token=695305b2-cc3b-400b-9c46-54606891a2d7)
{% endopenapi %}

#### Request Parameters

* **didDocument :**  DID documented to be updated
* **verificationMethodId** :  Verification Method id of referred verification method in the didDocument
* **deactivate** : `true` is you want to deactivate this DID, `false` otherwise.&#x20;

**Optional Parameters**

* **clientSpec :** Wallet specifications which are used to sign the didDocument string. Use `eth-personalSign` for Metamask and `cosmos-ADR036` for Keplr wallet. Learn more about client specifications [here](https://docs.hypersign.id/core-concepts/specifications/client-specification).
* **signature:** If didDocument is signed using client wallets (Metamask or Keply) then pass the signature hex string.&#x20;

###
