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

# Getting Started

> Quickly get setup using the TrustStack DID service.

The `did` module is used to manage decentralized identifiers (DIDs) via the TrustStack platform.

# Installation

With `@truststack/sdk` installed and configured, or alternatively, just the `@truststack/did` package.

<CodeGroup>
  ```bash npm theme={null}
  npm install @truststack/sdk
  # or
  npm install @truststack/did
  ```

  ```bash yarn theme={null}
  yarn add @truststack/sdk
  # or
  yarn add @truststack/did
  ```

  ```bash pnpm theme={null}
  pnpm add @truststack/sdk
  # or
  pnpm add @truststack/did
  ```
</CodeGroup>

# Issuing a DID

DIDs against issued against and scoped to an [organization](/documentation/organizations). A single `organization` can have multiple DIDs issued so long as a unique name is provided.

```typescript theme={null}
import {DidClient} from "@truststack/did";

const client = new DidClient();

const did = await client.createDid(
  {
    name: "acme-farms",
  },
  {
    organizationId: "ACME-FARMS-ID",
  }
);

console.log(did);
```

This generates a `did:web` DID scoped to the `organization` and `name` provided. The response returned is below.

```json Response theme={null}
{
  "id": "94A78270-56AB-4EFA-8EE0-B6A3D3D009B2",
  "did": "did:web:trustdid.dev:o:<ORG_ID>:acme-farms",
  "alias": "did:web:trustdid.dev:o:<ORG_ID>:acme-farms",
  "name": "acme-farms",
  "createdAt": "2024-03-20T10:30:00Z",
  "updatedAt": "2024-03-20T10:30:00Z"
}
```

## DID Structure

The DID is constructed as follows:

```
did:web:trustdid.dev:o:<ORG_ID>:<NAME>
```

Where `<ORG_ID>` is the `organizationId` and `<NAME>` is the `name` provided to the `createDid` method.

# Deleting a DID

DIDs can be deleted by calling the `deleteDid` method.

```typescript theme={null}
import {DidClient} from "@truststack/did";

const client = new DidClient();

// Unique ID of the DID to delete
await client.deleteDid("94A78270-56AB-4EFA-8EE0-B6A3D3D009B2");
```
