> For the complete documentation index, see [llms.txt](https://docs.cheqd.io/product/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cheqd.io/product/sdk/credo/dids/update-did.md).

# Update a DID

Update a did:cheqd DID using the Credo Agent.

This guide walks you through how to **update an existing cheqd DID** using your configured **Credo Agent**. Updating a DID Document lets you add or modify keys, service endpoints, or other metadata associated with the DID.

## Prerequisites

Before you begin, make sure:

* ✅ Your Credo agent is already configured with cheqd support
* ✅ You have write access to the DID (i.e., the key used for DID creation or a controller key)
* ✅ You know the **DID you want to update** and its current document state

## How DID Updates Work

To update a `did:cheqd`, you must:

1. **Fetch the current DID Document**
2. **Modify** the relevant fields (e.g., add keys, update service endpoints)
3. **Submit the updated DID Document** using `agent.dids.update(...)`

### Example: Add a New Service and Verification Method

```ts
import { DidDocumentService } from '@credo-ts/core'

await agent.dids.update({
  did: 'did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411',

  // Used to authorize and derive additional keys, if needed
  secret: {
    verificationMethod: {
      id: 'key-2',
      type: 'JsonWebKey2020', // Can also be Ed25519VerificationKey2020, etc.
    },
  },

  didDocument: {
    id: 'did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411',
    controller: ['did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411'],

    verificationMethod: [
      {
        id: 'did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411#key-1',
        type: 'Ed25519VerificationKey2020',
        controller: 'did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411',
        publicKeyMultibase: 'z6MknkzLUEP5cxqqsaysNMWoh8NJRb3YsowTCj2D6yhwyEdj',
      },
    ],

    authentication: [
      'did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411#key-1',
    ],

    service: [
      new DidDocumentService({
        id: 'did:cheqd:testnet:b84817b8-43ee-4483-98c5-f03760816411#website',
        type: 'linkedDomains',
        serviceEndpoint: 'https://rand.in',
      }),
    ],
  },
})
```

***

### Parameters Reference

| Parameter     | Required | Description                                                                |
| ------------- | -------- | -------------------------------------------------------------------------- |
| `did`         | ✅        | The DID you want to update                                                 |
| `didDocument` | ✅        | The **complete** updated DID Document                                      |
| `secret`      | ⚠️       | Required only if you're referencing new keys not yet in the agent’s wallet |
| `options`     | ❌        | Optional advanced settings (e.g., method-specific configurations)          |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cheqd.io/product/sdk/credo/dids/update-did.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
