Skip to main content

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.
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);

Example DID Document

{
  "@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.
ParameterTypeDescription
didstringThe 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
{
  "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

VariableDefaultDescription
ANIMA_DID_KEY_TYPEEd25519Default key type for new DIDs
ANIMA_DID_ROTATION_GRACE72hGrace period before old keys expire
ANIMA_DID_CACHE_TTL300DID document cache TTL in seconds

Next Steps