# DIDs

DID stands for Decentralized IDentifiers. DIDs are meant to be globally unique identifiers that allow their owner to prove cryptographic control over them. A DID identifies any subject (e.g., a person, organization, thing, data model, abstract entity, etc.) that the controller of the DID decides that it identifies.

In Truvera, Decentralized Identifiers (DIDs) are created using the UUID v4 standard. This involves selecting a unique 128-bit identifier, typically represented as a 36-character hexadecimal string, along with an initial public key. Users have the flexibility to add and remove public keys associated with their DID document as needed. Additionally, the system supports various operations such as updating, deactivating, and listing all existing DIDs.

For a detailed example of the DIDs workflow. Please refer [here](https://github.com/docknetwork/dock-api-js/blob/main/workflows/didFlow.js).

## Create DID

A DID, a public key, and a controller are required to create a new DID. The controller is both the owner of the public key and a DID. The DID can be created using an auto-generated keypair, and the controller will be the same as the DID unless otherwise specified. The DID and public key have no cryptographic relation.

It is important to have a public key types that is supported by Truvera, the supported type of public key is `ed25519.`

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids" method="post" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}

## Import DIDs

Import an already existing DID, possibly created in another platform, to take advantage of Truvera's advanced functions like ecosystems and monetized credentials.

## Import DIDs

> Import DIDs from JSON objects (\[DIDResolutionResponse]\(<https://www.w3.org/TR/did-resolution/>) or \[Universal Wallet]\(<https://w3c-ccg.github.io/universal-wallet-interop-spec/>) format). Supports both encrypted and plaintext wallet exports.

```json
{"openapi":"3.0.2","info":{"title":"Truvera API","version":"1"},"tags":[{"name":"dids","description":"Operations about DIDs"}],"servers":[{"url":"https://api-testnet.truvera.io","description":"Sandbox server (uses test data)"},{"url":"https://api.truvera.io","description":"Production server (uses live data)"}],"security":[{"bearerAuth":[]},{"accessToken":[]},{"nextAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"accessToken":{"type":"apiKey","in":"header","name":"DOCK-API-TOKEN"},"nextAuth":{"type":"apiKey","in":"header","name":"CERTS-TOKEN"}},"schemas":{"DID":{"description":"DID as fully qualified, typically. `did:cheqd:`","type":"string","minimum":32},"Error":{"description":"An API Error","type":"object","properties":{"status":{"type":"integer"},"type":{"type":"string"},"message":{"type":"string"}}}}},"paths":{"/dids/import":{"post":{"tags":["dids"],"summary":"Import DIDs","description":"Import DIDs from JSON objects ([DIDResolutionResponse](https://www.w3.org/TR/did-resolution/) or [Universal Wallet](https://w3c-ccg.github.io/universal-wallet-interop-spec/) format). Supports both encrypted and plaintext wallet exports.","requestBody":{"description":"Import data containing DIDs to import","required":true,"content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"description":"Import data - can be DIDResolutionResponse JSON-LD document, universal wallet export, or array of either","oneOf":[{"type":"string","description":"JSON string containing import data"},{"type":"object","description":"Single DID import object"},{"type":"array","description":"Array of DID import objects"}]},"password":{"type":"string","description":"Password for encrypted wallet imports","minLength":8}}}}}},"responses":{"200":{"description":"DIDs imported successfully","content":{"application/json":{"schema":{"type":"object","properties":{"imported":{"type":"integer","description":"Number of DIDs successfully imported"},"dids":{"type":"array","description":"Array of imported DID information","items":{"type":"object","properties":{"did":{"$ref":"#/components/schemas/DID"},"controller":{"$ref":"#/components/schemas/DID"},"keyCount":{"type":"integer","description":"Number of keys imported for this DID"},"profile":{"type":"object","description":"DID profile information if available","properties":{"name":{"type":"string"},"description":{"type":"string"}}}}}}}}}}},"400":{"description":"Invalid import data or missing required fields","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Payment required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"DID not found or cannot be resolved","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}
```

## List DIDs

Return a list of all DIDs that your user account controls as fully resolved DID documents.

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids" method="get" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}

## Return ecosystems that DID participates in <a href="#list-dids-parameters" id="list-dids-parameters"></a>

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids/{did}/ecosystems" method="get" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}

## Export DID

Exports the DID document and keys as an encrypted Universal Wallet JSON-LD document

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids/{did}/export" method="post" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}

## Get DID

When a DID is provided in the path, the API will attempt to resolve that DID into a [DID document](https://www.w3.org/TR/did-core/#dfn-did-documents). This document contains the public keys and more information relating to that DID, check [the identity foundation did configuration](https://identity.foundation/.well-known/resources/did-configuration/) document to learn more.

The API supports resolving many DID methods, some examples are:

* did:cheqd:f48d2ace-4947-4cb7-8550-1cef3d63e651 - resolves through the cheqd blockchain
* did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd- the public key is embedded in the DID

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids/{did}" method="get" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids/{did}/metadata" method="get" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}

## Delete DID <a href="#list-dids-parameters" id="list-dids-parameters"></a>

Deletes a DID and its metadata from the blockchain and our platform. This will also delete the associated keypair from the key management system meaning that you cannot sign messages or credentials with it after this operation. The DID will no longer be able to be resolved. This operation is not reversible.

{% openapi src="<https://swagger-api.truvera.io/openapi.yaml>" path="/dids/{did}" method="delete" %}
<https://swagger-api.truvera.io/openapi.yaml>
{% endopenapi %}


---

# 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.truvera.io/truvera-api/dids.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.
