> For the complete documentation index, see [llms.txt](https://docs.empe.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.empe.io/develop/wallet-server/did-document-management.md).

# DID Document Management

The API lets you generate or import DIDs, list them, and serve did:web documents.

## Endpoints

* POST `/did/generate`
  * Body: `{ "methods": ["empe", "empe-testnet", "web"] }`
  * Generates DID documents for the selected methods and persists them for the authenticated user.
* POST `/did/import`
  * Body: `{ "methods": [...], "mnemonics": "<12+ words>" }`
  * Restores/creates DID documents for the selected methods from a mnemonic phrase.
* GET `/dids`
  * Returns all DID documents for the authenticated user (across supported methods).
* GET `/dids/:method`
  * Returns the DID document for a specific method. `:method` is one of `empe`, `empe-testnet`, `web`.
* GET `/did/user/:id/did.json` (public)
  * Serves the canonical `did.json` for did:web. See “did:web & Hosting”.

## Examples

Generate DIDs for testnet and web:

```
curl -X POST http://localhost:3000/did/generate \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"methods":["empe-testnet","web"]}'
```

Import from mnemonics:

```
curl -X POST http://localhost:3000/did/import \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"methods":["empe"],"mnemonics":"abandon ability ..."}'
```

List all documents:

```
curl -H 'Authorization: Bearer <token>' http://localhost:3000/dids
```

Get a single document:

```
curl -H 'Authorization: Bearer <token>' http://localhost:3000/dids/web
```

Public did:web document (no auth):

```
curl http://localhost:3000/did/user/<userId>/did.json
```

## Notes

* did:web creation uses `DID_WEB_DOMAIN`, optional `DID_WEB_JSON_PATH`, and optional `DID_WEB_PORT` from the environment.
* `userId` is taken from the JWT `sub` and is used when constructing did:web paths.
* Methods map:
  * `empe` → mainnet
  * `empe-testnet` → testnet
  * `web` → did:web


---

# 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.empe.io/develop/wallet-server/did-document-management.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.
