---
title: "Get all API keys for a user"
method: GET
path: "/users/{id}/tokens"
tags: ["users"]
---

# Get all API keys for a user

`GET /users/{id}/tokens`

Gets all API keys for a user.
Only the calling user or admin can retrieve api-keys.
**Access policy**: authenticated

## Path parameters

- `id` integer, required

## Response `200`

Success

- PortainerAPIKey[]
  - `dateCreated` integer — Unix timestamp (UTC) when the API key was created
  - `description` string
  - `digest` string — Digest represents SHA256 hash of the raw API key
  - `id` integer
  - `lastUsed` integer — Unix timestamp (UTC) when the API key was last used
  - `prefix` string — API key identifier (7 char prefix)
  - `userId` integer

## Other responses

- `400` — Invalid request
- `403` — Permission denied
- `404` — User not found
- `500` — Server error

---

[API](https://skmtc.net/portainer/apis/portainerce-api.md) · [All operations](https://skmtc.net/portainer/apis/portainerce-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/portainer/portainerce-api/versions/ec51a8194ac0/schema)
