> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useanima.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# DID Method (did:anima)

> Decentralized identifiers for AI agents using the did:anima method. Document structure, resolution, and lifecycle management.

# DID Method (did:anima)

Anima assigns every agent a globally unique decentralized identifier (DID) using the `did:anima` method. DIDs provide a self-sovereign identity foundation that agents can use across protocols and platforms.

## DID Format

Every agent DID follows the W3C DID specification:

```
did:anima:<agent-id>
```

For example: `did:anima:ag_8f3k2m9x1n4p7q6r`

## DID Document Structure

Each DID resolves to a DID Document containing the agent's public keys, service endpoints, and authentication methods.

<Tabs items={["Node.js", "Python", "Go"]}>
  <Tab value="Node.js">
    ```ts theme={null}
    import { Anima } from "@anima-labs/sdk";

    const anima = new Anima({ apiKey: "ak_..." });

    // Resolve a DID document
    const doc = await anima.identity.resolveDid("did:anima:ag_8f3k2m9x1n4p7q6r");
    console.log(doc);
    ```
  </Tab>

  <Tab value="Python">
    ```python theme={null}
    from anima import Anima

    anima = Anima(api_key="ak_...")

    doc = anima.identity.resolve_did("did:anima:ag_8f3k2m9x1n4p7q6r")
    print(doc)
    ```
  </Tab>

  <Tab value="Go">
    ```go theme={null}
    import "github.com/anima-labs-ai/go"

    client := anima.NewClient("ak_...")

    doc, err := client.Identity.ResolveDID(ctx, "did:anima:ag_8f3k2m9x1n4p7q6r")
    ```
  </Tab>
</Tabs>

### Example DID Document

```json theme={null}
{
  "@context": ["https://www.w3.org/ns/did/v1"],
  "id": "did:anima:ag_8f3k2m9x1n4p7q6r",
  "verificationMethod": [
    {
      "id": "did:anima:ag_8f3k2m9x1n4p7q6r#key-1",
      "type": "Ed25519VerificationKey2020",
      "controller": "did:anima:ag_8f3k2m9x1n4p7q6r",
      "publicKeyMultibase": "z6Mkf5rG..."
    }
  ],
  "authentication": ["did:anima:ag_8f3k2m9x1n4p7q6r#key-1"],
  "service": [
    {
      "id": "did:anima:ag_8f3k2m9x1n4p7q6r#email",
      "type": "AgentEmail",
      "serviceEndpoint": "mailto:agent@useanima.sh"
    },
    {
      "id": "did:anima:ag_8f3k2m9x1n4p7q6r#a2a",
      "type": "AgentToAgent",
      "serviceEndpoint": "https://api.useanima.sh/a2a/ag_8f3k2m9x1n4p7q6r"
    }
  ]
}
```

## API Reference

### Resolve DID

```
GET https://api.useanima.sh/api/identity/did/:did
```

Resolves a `did:anima` identifier to its DID Document.

| Parameter | Type   | Description                        |
| --------- | ------ | ---------------------------------- |
| `did`     | string | The full DID, e.g. `did:anima:...` |

### Create DID

DIDs are created automatically when an agent is provisioned. To explicitly create or rotate keys:

```
POST https://api.useanima.sh/api/identity/did
```

```json theme={null}
{
  "agentId": "ag_8f3k2m9x1n4p7q6r",
  "keyType": "Ed25519"
}
```

### Rotate Keys

```
POST https://api.useanima.sh/api/identity/did/:did/rotate
```

Rotates the agent's verification key. The previous key is added to the document's `keyAgreement` section for a configurable grace period.

## Configuration

| Variable                   | Default   | Description                         |
| -------------------------- | --------- | ----------------------------------- |
| `ANIMA_DID_KEY_TYPE`       | `Ed25519` | Default key type for new DIDs       |
| `ANIMA_DID_ROTATION_GRACE` | `72h`     | Grace period before old keys expire |
| `ANIMA_DID_CACHE_TTL`      | `300`     | DID document cache TTL in seconds   |

## Next Steps

* [Verifiable Credentials](/identity/verifiable-credentials) -- Issue and verify credentials for your agents
* [Agent Cards](/identity/agent-cards) -- Publish discoverable agent metadata
* [A2A Protocol](/a2a/overview) -- Agent-to-agent communication using DIDs
