> 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

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
