# Personal access tokens API

> The personal access tokens endpoints, each in TypeScript, Python, the CLI and curl.

The personal access tokens endpoints, each in TypeScript, Python, the CLI and curl.

## Set up

This takes a [personal access token](/docs/authentication/), not an API key. In the SDKs, pass it as `token`.

* TypeScript

  ```bash
  npm install @limitry/sdk
  export LIMITRY_TOKEN="<your personal access token>"
  ```

* Python

  ```bash
  pip install limitry
  export LIMITRY_TOKEN="<your personal access token>"
  ```

* CLI

  ```bash
  npm install -g @limitry/cli
  limitry login
  ```

* curl

  ```bash
  export LIMITRY_TOKEN="<your personal access token>"
  ```

## Get the current user

`GET /v1/user/me`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/personal-access-tokens/GET/user/me)

Returns the user the personal access token belongs to, and their workspace memberships.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  const limitry = createClient({ token: process.env.LIMITRY_TOKEN });
  const me = await limitry.user.me();
  console.log(me);
  ```

* Python

  ```python
  import os

  from limitry import Limitry

  limitry = Limitry(token=os.environ["LIMITRY_TOKEN"])
  me = limitry.user.me()
  print(me)
  ```

* CLI

  ```bash
  limitry user me
  ```

* curl

  ```bash
  curl -X GET "https://api.limitry.com/v1/user/me" \
    -H "Authorization: Bearer $LIMITRY_TOKEN"
  ```

**Returns:**

```json
{
  "id": "usr_4f8a2c1e-7b3d-4e9f-a6c5-2d1b0e9f8a7c",
  "name": "Casey Customer",
  "email": "casey@example.com",
  "workspaces": [
    {
      "id": "ws_9418b705-3720-48ca-b2bf-f726d1456684",
      "name": "Acme Inc.",
      "slug": "acme",
      "role": "owner"
    }
  ]
}
```

More about this endpoint

Use it as a smoke test for an integration (“who am I?”).

## Revoke the token making this request

`DELETE /v1/user/token`[ Try it in the API playground (opens in a new tab)](https://api.limitry.com/v1/docs#tag/personal-access-tokens/DELETE/user/token)

Revokes the personal access token that makes the request.

* TypeScript

  ```ts
  import { createClient } from "@limitry/sdk";

  const limitry = createClient({ token: process.env.LIMITRY_TOKEN });
  await limitry.user.revokeToken();
  ```

* Python

  ```python
  import os

  from limitry import Limitry

  limitry = Limitry(token=os.environ["LIMITRY_TOKEN"])
  limitry.user.revoke_token()
  ```

* CLI

  ```bash
  limitry user revoke-token --yes
  ```

* curl

  ```bash
  curl -X DELETE "https://api.limitry.com/v1/user/token" \
    -H "Authorization: Bearer $LIMITRY_TOKEN"
  ```

**Returns** nothing (`204`).

More about this endpoint

Use it to sign out from a script or the CLI (`logout`). The token stops working immediately. Your other tokens keep working.
