# Identity

This API suite is focused on managing Decentralized Identifiers (DIDs), allowing for their creation, retrieval, and management within an identity system.

## Retrieves a list of Decentralized Identifiers (DIDs)

<mark style="color:green;">`GET`</mark> `/api/v1/identity/dids`

An entity in the Identus system can have several identities (or DIDs). We can retrieve them all with thisa API call.

**Headers**

| Name          | Value                    |
| ------------- | ------------------------ |
| Content-Type  | `application/json`       |
| Authorization | `apikey = {Alice's key}` |

**Body**

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "data": [
        {
            "did": "did:prism:a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b",
            "status": "PUBLISHED"
        }
    ]
}
```

{% endtab %}

{% tab title="401" %}

```json
{
}
```

{% endtab %}
{% endtabs %}

## Retrieve information about a specific DID&#x20;

didRef can be a short-form or a long-form DID reference

<mark style="color:green;">`GET`</mark> `/api/v1/identity/dids/{didRef}`

**Headers**

| Name          | Value                    |
| ------------- | ------------------------ |
| Content-Type  | `application/json`       |
| Authorization | `apikey = {Alice's key}` |

**Body**

**Response**

{% tabs %}
{% tab title="200" %}

````json
```json
{
    "data": {
        "@context": "https://w3id.org/did-resolution/v1",
        "didDocument": {
            "@context": [
                "https://www.w3.org/ns/did/v1",
                "https://w3id.org/security/suites/jws-2020/v1"
            ],
            "id": "did:prism:a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b",
            "controller": "did:prism:a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b",
            "verificationMethod": [
                {
                    "id": "did:prism:a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b#key-1",
                    "type": "JsonWebKey2020",
                    "controller": "did:prism:a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b",
                    "publicKeyJwk": {
                        "crv": "secp256k1",
                        "x": "D0v51KIo8kFXhfw_BsU7qTeNtLFXGpKI5-Ql1XvsdqE",
                        "y": "zZHNvxuTKpqmcptp6dvXwB1pHLHvOHL2vpzSwGWSK3o",
                        "kty": "EC"
                    }
                }
            ],
            "authentication": [
                "did:prism:a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b#key-1"
            ],
            "assertionMethod": [],
            "keyAgreement": [],
            "capabilityInvocation": [],
            "capabilityDelegation": [],
            "service": []
        },
        "didDocumentMetadata": {
            "deactivated": false,
            "versionId": "a3ec71a39fb5bd87d198daca17975f63cf5b95677447e5775a9edaf4c5b0448b",
            "created": "2024-10-03T12:20:39Z",
            "updated": "2024-10-03T12:20:39Z"
        },
        "didResolutionMetadata": {
            "contentType": "application/ld+json; profile=https://w3id.org/did-resolution"
        }
    }
}
```
````

{% endtab %}

{% tab title="401" %}

```json
{
}
```

{% endtab %}
{% endtabs %}

## Create a new DID for a specific purpose

<mark style="color:green;">`POST`</mark> `/api/v1/identity/did`

Returns a JSON object with the created DID information, including a "longFormDid"

**Headers**

| Name          | Value                    |
| ------------- | ------------------------ |
| Content-Type  | `application/json`       |
| Authorization | `apikey = {Alice's key}` |

**Body**

| Name      | Type                        | Description                                                       |
| --------- | --------------------------- | ----------------------------------------------------------------- |
| `id`      | string                      | a short ID for the DID doc entry (eg: "key-2")                    |
| `purpose` | "authentication" or "issue" | purpose of the DID that will be created (if null, no DID created) |

**Response**

{% tabs %}
{% tab title="201" %}

```json
{
    "data": {
        "longDid": "did:prism:ca602ff65d8021bb4b77cbce6df6917e0b062d73f8c5fb7d0d6c3cded5874d88:CnoKeBI5CgVrZXktMhAESi4KCXNlY3AyNTZrMRIhAzr3b-JL0o2Bf_BIkN3EMtrz98De9ZHNVuMqDqACJ2g4EjsKB21hc3RlcjAQAUouCglzZWNwMjU2azESIQNvYKqeSymguB2PxKtRoTWlqUsODAkrOqaa0MXc9Sg7fA",
        "wasPublished": true
    }
}
```

{% endtab %}

{% tab title="401" %}

```json
{
}
```

{% endtab %}
{% endtabs %}

## Adds a purpose to an existing DID

<mark style="color:green;">`PATCH`</mark> `/api/v1/identity/did/{did}`

{did} is the short (published) DID to update

**Headers**

| Name          | Value                    |
| ------------- | ------------------------ |
| Content-Type  | `application/json`       |
| Authorization | `apikey = {Alice's key}` |

**Body**

| Name      | Type                        | Description                                      |
| --------- | --------------------------- | ------------------------------------------------ |
| `id`      | string                      | a short ID for the DID doc entry (eg: "issue-2") |
| `purpose` | "authentication" or "issue" | another purpose for the existing DID             |

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "data": {
        "longDid": "did:prism:ca602ff65d8021bb4b77cbce6df6917e0b062d73f8c5fb7d0d6c3cded5874d88:CnoKeBI5CgVrZXktMhAESi4KCXNlY3AyNTZrMRIhAzr3b-JL0o2Bf_BIkN3EMtrz98De9ZHNVuMqDqACJ2g4EjsKB21hc3RlcjAQAUouCglzZWNwMjU2azESIQNvYKqeSymguB2PxKtRoTWlqUsODAkrOqaa0MXc9Sg7fA",
        "wasPublished": true
    }
}
```

{% endtab %}

{% tab title="401" %}

```json
{
}
```

{% endtab %}
{% endtabs %}


---

# 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://incubiq.gitbook.io/opensourceais/identity-agent-lib/apis/identity.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.
