---
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
        - `workspace` string, required — Workspace name. The reserved names all and default are not allowed.
        - `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
    - `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

## Changes

- **2026-05-24** (v1) `8a2d5d3e9608` — 4 warning
  - added the new `rate_limited` enum value to the `code` response property for the response status `401`
  - added the new `rate_limited` enum value to the `code` response property for the response status `403`
  - added the new `rate_limited` enum value to the `code` response property for the response status `404`
  - added the new `rate_limited` enum value to the `code` response property for the response status `default`
- **2026-05-22** (v1) `4a44e3b2d12a` — 7 info
  - added the optional property `apiKey/migratedAsServiceAccount` to the response with the `200` status
  - added the optional property `apiKey/ownerUserId` to the response with the `200` status
  - added the optional property `apiKey/ownerUsername` to the response with the `200` status
  - added the optional property `apiKey/serviceAccountId` to the response with the `200` status
  - …3 more
- **2026-04-30** (v1) `50e1d517afc1` — 2 breaking, 5 warning, 4 info
  - removed the required property `apiKey/allowedSurfaces` from the response with the `200` status
  - removed the required property `apiKey/attributionClass` from the response with the `200` status
  - removed the optional property `apiKey/migratedAsServiceAccount` from the response with the `200` status
  - removed the optional property `apiKey/ownerUserId` from the response with the `200` status
  - …7 more

[Change history](https://skmtc.dev/dagucloud/apis/dagu/changes/api-keys/:keyId/get.md)

---

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