# /api/instance-context/services (dashboard)

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

Source: https://docs.minds.sh/docs/api/platform/reference/dashboard--api-instance-context-services



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                        | GET                                                                            |
| Path                           | `/api/instance-context/services`                                               |
| 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]

Dashboard session cookie through @repo/auth/server. Some auth-summary routes can redirect to sign-in; inspect the status branches below.

## 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.

### GET [#get]

```typescript
export async function GET() {
  try {
    const session = await getSession();

    if (!session) {
      return NextResponse.json(
        { error: { code: 'UNAUTHENTICATED', message: 'Sign in at auth.l1fe.ai.' } },
        { status: 401 }
      );
    }

    const cookieStore = await cookies();
    const organizationContext = await loadMindsOrganizationContext({
      accessToken: session.accessToken,
      activeTenantId: cookieStore.get(ACTIVE_TENANT_COOKIE)?.value,
      tokenOrgId: session.user.orgId,
      tokenTenantId: session.user.tenantId,
    });

    if (!organizationContext.activeOrganizationId) {
      return NextResponse.json(
        { error: { code: 'NO_ORG', message: 'No organization selected' } },
        { status: 400 }
      );
    }

    return NextResponse.json(
      {
        tenants: organizationContext.tenantGroups,
        activeOrganizationId: organizationContext.activeOrganizationId,
      },
      {
        headers: {
          'Cache-Control': 'private, no-cache, no-store, must-revalidate',
        },
      }
    );
  } catch (error) {
    console.error('Failed to fetch services for instance context:', error);

    return NextResponse.json(
      {
        error: {
          code: 'FETCH_FAILED',
          message: error instanceof Error ? error.message : 'Failed to fetch services',
        },
      },
      { status: 500 }
    );
  }
}
```

Source: `minds-ui/apps/app/app/api/instance-context/services/route.ts:15`.

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

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

```typescript
NextResponse.json(
        { error: { code: 'UNAUTHENTICATED', message: 'Sign in at auth.l1fe.ai.' } },
        { status: 401 }
      )
```

Source: `minds-ui/apps/app/app/api/instance-context/services/route.ts:20`.

```typescript
NextResponse.json(
        { error: { code: 'NO_ORG', message: 'No organization selected' } },
        { status: 400 }
      )
```

Source: `minds-ui/apps/app/app/api/instance-context/services/route.ts:35`.

```typescript
NextResponse.json(
      {
        tenants: organizationContext.tenantGroups,
        activeOrganizationId: organizationContext.activeOrganizationId,
      },
      {
        headers: {
          'Cache-Control': 'private, no-cache, no-store, must-revalidate',
        },
      }
    )
```

Source: `minds-ui/apps/app/app/api/instance-context/services/route.ts:41`.

```typescript
NextResponse.json(
      {
        error: {
          code: 'FETCH_FAILED',
          message: error instanceof Error ? error.message : 'Failed to fetch services',
        },
      },
      { status: 500 }
    )
```

Source: `minds-ui/apps/app/app/api/instance-context/services/route.ts:55`.

## Service dependencies [#service-dependencies]

* `minds-ui/apps/app/lib/organizations.ts`

## 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/instance-context/services/route.ts`. SHA-256: `1e37e1cc3bd5bf75f699668d8d1566ffea843b3a4758a368d7aa7e0da13df669`.
