---
title: "Get API key"
method: GET
path: "/api-keys/{keyId}"
tags: ["api-keys"]
---

# Get API key

`GET /api-keys/{keyId}`

Returns API key by ID. Requires admin role.

## Path parameters

- `keyId` string, required

## Response `200`

API key details

- APIKeyResponse — API key response
  - `apiKey` APIKey, required — API key information
    - `id` string, required — Unique identifier
    - `name` string, required — Human-readable name
    - `description` string — Purpose description
    - `role` 'admin' | 'manager' | 'developer' | 'operator' | 'viewer', required — User role determining access permissions. admin: full access including user management, manager: DAG CRUD and execution with audit log access, developer: DAG CRUD and execution, operator: DAG execution only, viewer: read-only
    - `workspaceAccess` WorkspaceAccess, required — Workspace access policy. all=true grants the top-level role in every workspace. all=false requires explicit workspace grants and a top-level viewer role.
      - `all` boolean, required — Whether this identity can access all workspaces
      - `grants` WorkspaceGrant[], required — Workspace-specific grants used when all=false — unresolved $ref
    - `allowedSurfaces` string[], required — Interfaces where this API key may be accepted
    - `attributionClass` 'user_owned' | 'service_account', required — Whether this key is owned by a user or represents a service account
    - `ownerUserId` string — Owner user ID when attributionClass is user_owned
    - `ownerUsername` string — Owner username when attributionClass is user_owned
    - `serviceAccountId` string — Service-account identifier when attributionClass is service_account
    - `serviceAccountName` string — Service-account display name when attributionClass is service_account
    - `migratedAsServiceAccount` boolean — True when a legacy key missing attributionClass was defaulted to service_account
    - `keyPrefix` string, required — First 8 characters for identification
    - `createdAt` string, date-time, required — Creation timestamp
    - `updatedAt` string, date-time, required — Last update timestamp
    - `createdBy` string, required — Creator user ID
    - `lastUsedAt` string, date-time, nullable — Last authentication timestamp

## Other responses

- `401` — Not authenticated
- `403` — Requires admin role
- `404` — Not found
- `default` — Error

---

[API](https://skmtc.net/dagucloud/apis/dagu.md) · [All operations](https://skmtc.net/dagucloud/apis/dagu/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/dagucloud/dagu/revisions/f8982f33e540/schema)
