# /api/hmr/generate (dashboard)

Source-derived dashboard endpoint contract, authentication, request validation, responses, and errors.

Source: https://docs.minds.sh/docs/api/platform/reference/dashboard--api-hmr-generate



This is the **dashboard** service route. Its origin and authentication are described in [Platform API overview](/docs/api/platform) and [Authentication](/docs/api/platform/authentication). A path shared by another service is a different endpoint.

| Property                       | Contract                                                                       |
| ------------------------------ | ------------------------------------------------------------------------------ |
| Methods                        | POST                                                                           |
| Path                           | `/api/hmr/generate`                                                            |
| Path parameters                | None                                                                           |
| Query parameters read in route | None read directly; schema validation below may define additional fields       |
| Headers read in route          | No additional direct header reads; authentication helpers may read credentials |

## Authentication and access [#authentication-and-access]

No explicit authentication check in this route module. Imported handlers or deployment middleware may impose additional controls; this inventory does not assert public deployment access.

## Request and response definitions [#request-and-response-definitions]

The following named definitions are imported or declared by this route. Optional markers, defaults, bounds, and enum values are shown exactly as implemented. A response type is a source contract, not an example populated with real account data.

### GeneratePayload [#generatepayload]

```typescript
type GeneratePayload = {
  userId: string;
  email: string;
  name?: string | null;
  publicKey?: string | null;
};
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:3`.

## Method behavior [#method-behavior]

The handler excerpt preserves field validation, response envelopes, cookie changes, and exception branches. Values returned by service helpers retain their named response type above; for passthrough routes, the upstream response is authoritative.

### POST [#post]

```typescript
POST = async (request: Request) => {
  try {
    const payload = (await request.json()) as GeneratePayload;

    if (!payload?.userId || !payload?.email) {
      return Response.json(
        { error: 'userId and email are required to generate an HMR DID' },
        { status: 400 },
      );
    }

    const controller = new AbortController();
    const timeout = setTimeout(() => controller.abort(), 5_000);

    const response = await fetch(`${HMR_BASE_URL}/generate`, {
      method: 'POST',
      headers: hmrHeaders(),
      body: JSON.stringify({
        user_id: payload.userId,
        email: payload.email,
        name: payload.name,
        public_key: payload.publicKey,
      }),
      signal: controller.signal,
    }).finally(() => clearTimeout(timeout));

    if (!response.ok) {
      const errorText = await response.text();
      return Response.json(
        {
          error: `HMR Genesis service rejected the request (${response.status}): ${errorText || 'unknown error'}`,
        },
        { status: response.status },
      );
    }

    const data = await response.json();
    return Response.json(data);
  } catch (error) {
    const message =
      error instanceof Error && error.name === 'AbortError'
        ? 'Timed out talking to the HMR Genesis service'
        : error instanceof Error
          ? error.message
          : 'Unexpected error generating HMR DID';

    return Response.json({ error: message }, { status: 500 });
  }
}
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:24`.

## Response and error branches [#response-and-error-branches]

Literal HTTP statuses in the route: 400, 500. Shared management error classes are defined in [Errors and responses](/docs/api/platform/errors).

```typescript
request.json()
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:26`.

```typescript
Response.json(
        { error: 'userId and email are required to generate an HMR DID' },
        { status: 400 },
      )
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:29`.

```typescript
Response.json(
        {
          error: `HMR Genesis service rejected the request (${response.status}): ${errorText || 'unknown error'}`,
        },
        { status: response.status },
      )
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:52`.

```typescript
response.json()
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:60`.

```typescript
Response.json(data)
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:61`.

```typescript
Response.json({ error: message }, { status: 500 })
```

Source: `minds-ui/apps/app/app/api/hmr/generate/route.ts:70`.

## Evidence [#evidence]

Generated from the local source snapshot on 2026-09-12. This page documents implemented code and does not certify a deployed service, permissions configuration, or successful provider operation.

Source file: `minds-ui/apps/app/app/api/hmr/generate/route.ts`. SHA-256: `06a365681d71ab16419c8fdc84221b07c3614b2438c2a86c7fd52b725757fefd`.
