---
id: get-tokens
title: "List all Tokens"
description: "Returns a list of all tokens for a user"
sidebar_label: "List all Tokens"
hide_title: true
hide_table_of_contents: true
api: {"description":"Returns a list of all tokens for a user","tags":["Tokens"],"operationId":"getTokens","security":[{"BearerAuth":[]},{"TokenAuth":[]}],"parameters":[{"in":"path","name":"userId","required":true,"schema":{"type":"string"},"description":"The unique identifier of a user"}],"responses":{"200":{"description":"A JSON Array of PersonalAccessTokens","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"id":{"description":"ID of a token","type":"string"},"name":{"description":"Name of the token","type":"string"},"expiration_date":{"description":"Date the token expires","type":"string","format":"date-time"},"created_by":{"description":"User ID of the user who created the token","type":"string"},"created_at":{"description":"Date the token was created","type":"string","format":"date-time"},"last_used":{"description":"Date the token was last used","type":"string","format":"date-time"}},"required":["id","name","expiration_date","created_by","created_at"],"title":"PersonalAccessToken"}}}}},"400":{"description":"Bad Request","content":{}},"401":{"description":"Requires authentication","content":{}},"403":{"description":"Forbidden","content":{}},"500":{"description":"Internal Server Error","content":{}}},"method":"get","path":"/api/users/{userId}/tokens","servers":[{"url":"https://netbird.io","description":"Default server"}],"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"TokenAuth":{"type":"apiKey","in":"header","name":"Authorization","description":"Prefix the value with \\\"Token\\\" to indicate the custom authorization type"}},"info":{"title":"NetBird REST API","description":"API to manipulate groups, rules, policies and retrieve information about peers and users","version":"0.0.1"},"postman":{"name":"List all Tokens","description":{"content":"Returns a list of all tokens for a user","type":"text/plain"},"url":{"path":["api","users",":userId","tokens"],"host":["{{baseUrl}}"],"query":[],"variable":[{"disabled":false,"description":{"content":"(Required) The unique identifier of a user","type":"text/plain"},"type":"any","value":"","key":"userId"}]},"header":[{"key":"Accept","value":"application/json"}],"method":"GET","auth":{"type":"bearer","bearer":[{"type":"any","value":"<Bearer Token>","key":"token"}]}}}
sidebar_class_name: "get api-method"
info_path: api/netbird-rest-api
custom_edit_url: null
---

import ApiTabs from "@theme/ApiTabs";
import MimeTabs from "@theme/MimeTabs";
import ParamsItem from "@theme/ParamsItem";
import ResponseSamples from "@theme/ResponseSamples";
import SchemaItem from "@theme/SchemaItem";
import SchemaTabs from "@theme/SchemaTabs";
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
import TabItem from "@theme/TabItem";

## List all Tokens



Returns a list of all tokens for a user

<details style={{"marginBottom":"1rem"}} data-collapsed={false} open={true}><summary style={{}}><strong>Path Parameters</strong></summary><div><ul><ParamsItem className={"paramsItem"} param={{"in":"path","name":"userId","required":true,"schema":{"type":"string"},"description":"The unique identifier of a user"}}></ParamsItem></ul></div></details><div><ApiTabs><TabItem label={"200"} value={"200"}><div>

A JSON Array of PersonalAccessTokens

</div><div><MimeTabs schemaType={"response"}><TabItem label={"application/json"} value={"application/json"}><SchemaTabs><TabItem label={"Schema"} value={"Schema"}><details style={{}} data-collapsed={false} open={true}><summary style={{"textAlign":"left"}}><strong>Schema</strong></summary><div style={{"textAlign":"left","marginLeft":"1rem"}}></div><ul style={{"marginLeft":"1rem"}}><li><div style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem","paddingBottom":".5rem"}}>Array [</div></li><SchemaItem collapsible={false} name={"id"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"ID of a token","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"name"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"Name of the token","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"expiration_date"} required={true} schemaName={"date-time"} qualifierMessage={undefined} schema={{"description":"Date the token expires","type":"string","format":"date-time"}}></SchemaItem><SchemaItem collapsible={false} name={"created_by"} required={true} schemaName={"string"} qualifierMessage={undefined} schema={{"description":"User ID of the user who created the token","type":"string"}}></SchemaItem><SchemaItem collapsible={false} name={"created_at"} required={true} schemaName={"date-time"} qualifierMessage={undefined} schema={{"description":"Date the token was created","type":"string","format":"date-time"}}></SchemaItem><SchemaItem collapsible={false} name={"last_used"} required={false} schemaName={"date-time"} qualifierMessage={undefined} schema={{"description":"Date the token was last used","type":"string","format":"date-time"}}></SchemaItem><li><div style={{"fontSize":"var(--ifm-code-font-size)","opacity":"0.6","marginLeft":"-.5rem"}}>]</div></li></ul></details></TabItem><TabItem label={"Example (from schema)"} value={"Example (from schema)"}><ResponseSamples responseExample={"[\n  {\n    \"id\": \"string\",\n    \"name\": \"string\",\n    \"expiration_date\": \"2023-04-26T12:12:56.620Z\",\n    \"created_by\": \"string\",\n    \"created_at\": \"2023-04-26T12:12:56.620Z\",\n    \"last_used\": \"2023-04-26T12:12:56.620Z\"\n  }\n]"} language={"json"}></ResponseSamples></TabItem></SchemaTabs></TabItem></MimeTabs></div></TabItem><TabItem label={"400"} value={"400"}><div>

Bad Request

</div><div></div></TabItem><TabItem label={"401"} value={"401"}><div>

Requires authentication

</div><div></div></TabItem><TabItem label={"403"} value={"403"}><div>

Forbidden

</div><div></div></TabItem><TabItem label={"500"} value={"500"}><div>

Internal Server Error

</div><div></div></TabItem></ApiTabs></div>
      