> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cocartapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JWT Authentication

> These commands are strictly designed to help with your development.

## Clean up tokens

Cleans up expired JWT tokens.

```bash theme={"system"}
wp cocart jwt cleanup [--batch-size=<number>] [--force]
```

### Arguments

<ParamField path="batch-size" type="number">
  Number of users to process per batch (default: 100) (Optional)
</ParamField>

<ParamField path="force" type="bool">
  Force cleanup of all tokens (Optional)
</ParamField>

**Examples:**

```bash theme={"system"}
wp cocart jwt cleanup --batch-size=50
wp cocart jwt cleanup --force
```

## View token details

Displays details of a JWT token in a table.

```bash theme={"system"}
wp cocart jwt view <token>
```

### Arguments

<ParamField path="token" type="string" required>
  The JWT token to view
</ParamField>

**Example:**

```bash theme={"system"}
wp cocart jwt view eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOlwvXC9jb2NhcnRhcGkubG9jYWwiLCJpYXQiOjE3Mzk3NTEzNzIsIm5iZiI6MTczOTc1MTM3MiwiZXhwIjoxNzQwNjE1MzcyLCJkYXRhIjp7InVzZXIiOnsiaWQiOjEsInVzZXJuYW1lIjoic2ViYXN0aWVuIiwiaXAiOiIxMjcuMC4wLjEiLCJkZXZpY2UiOiJIVFRQX1hfVUNCUk9XU0VSX0RFVklDRV9VQSJ9LCJzZWNyZXRfa2V5IjoiYmFuYW5hIn19.aBuyRwAtvGb6SI4BB_MN4NYN01jqVZN4PPnd1jfW2UA
```

## Lists tokens

Lists all active JWT tokens.

```bash theme={"system"}
wp cocart jwt list [--page=<number>] [--per-page=<number>]
```

### Arguments

<ParamField path="page" type="number">
  Page number to display (default: 1)
</ParamField>

<ParamField path="per-page" type="number">
  Number of tokens to display per page (default: 20)
</ParamField>

**Example:**

```bash theme={"system"}
wp cocart jwt list --page=2 --per-page=10
```

## Create token

Generates a new JWT token for a user.

```bash theme={"system"}
wp cocart jwt create --user=<user> [--user-agent=<user-agent>]
```

### Arguments

<ParamField path="user" type="string" required>
  The user ID, email, or login to generate the token for
</ParamField>

<ParamField path="user-agent" type="string">
  The User Agent to override the server User Agent (optional)
</ParamField>

**Examples:**

```bash theme={"system"}
wp cocart jwt create --user=123
wp cocart jwt create --user=admin@example.com --user-agent="Custom User Agent"
```

## Destroy tokens

Destroys JWT tokens for a specific user.

```bash theme={"system"}
wp cocart jwt destroy <user> [--pat=<pat_id>] [--force]
```

### Arguments

<ParamField path="user" type="string" required>
  The user ID, email, or login to destroy tokens for
</ParamField>

<ParamField path="pat" type="string">
  Specific PAT token ID to destroy (optional)
</ParamField>

<ParamField path="force" type="bool">
  Force destroy without confirmation (optional)
</ParamField>

**Examples:**

```bash theme={"system"}
wp cocart jwt destroy 1
wp cocart jwt destroy admin@example.com --force
wp cocart jwt destroy username --pat=pat_abc123
```
