> **Building with AI coding agents?** Install the authstack plugin with one command. This equips your agent with accurate Scalekit implementation patterns.
>
> **Recommended**:
> ```bash
> npx @scalekit-inc/cli setup
> ```
>
> Global:
> ```bash
> npm install -g @scalekit-inc/cli
> scalekit setup
> ```
>
> Supports Claude Code, Cursor, GitHub Copilot, Codex + skills for 40+ agents.
> Features: full-stack-auth, agent-auth, mcp-auth, modular-sso, modular-scim.
> [Full setup guide](https://docs.scalekit.com/dev-kit/build-with-ai/)

---

# Token helpers

Token helpers and verification
<div class="sdk-client-page">

Create and validate API tokens for programmatic access to Scalekit APIs in Java.

Use tokens for service access that is not a full end-user session. Create a token, store it securely, and validate it on incoming requests.

### create
<div class="sdk-method-section">
  
    

      Creates a new API token for an organization with custom options.

      
        The organization ID to scope the token to
      
      
        Optional user ID to scope the token to a specific user
      
      
        Optional custom claims key-value pairs
      
      
        Optional expiry timestamp
      
      
        Optional human-readable description
      
      
        The created resource.
      

```java wrap showLineNumbers=false

Map claims = new HashMap<>();
claims.put("environment", "production");

Timestamp expiry = Timestamp.newBuilder()
  .setSeconds(System.currentTimeMillis() / 1000 + 86400)
  .build();

scalekitClient.tokens().create("org_123", "user_123", claims, expiry, "Production access token");
```

    
  
</div>

### validate
<div class="sdk-method-section">
  
    

      Validates an API token and returns associated context.

      
        The opaque token string or token_id (apit_xxxxx)
      
      
        Verified claims or result.
      

```java wrap showLineNumbers=false
scalekitClient.tokens().validate("apit_xxxxx");
```

    
  
</div>

### invalidate
<div class="sdk-method-section">
  
    

      Invalidates (soft deletes) an API token.

      
        The opaque token string or token_id (apit_xxxxx)
      
      
        No return value
      

```java wrap showLineNumbers=false
scalekitClient.tokens().invalidate("apit_xxxxx");
```

    
  
</div>

### list
<div class="sdk-method-section">
  
    

      Lists API tokens for an organization and user with pagination.

      
        The organization ID to list tokens for
      
      
        The user ID to filter tokens for
      
      
        Page size (default 10, max 30)
      
      
        Pagination cursor for next page
      
      
        Paginated results.
      

```java wrap showLineNumbers=false
scalekitClient.tokens().list("org_123", "user_123", 20, "");
```

    
  
</div>

### update
<div class="sdk-method-section">
  
    

      Updates the custom claims and/or description of an existing API token.

      
        The opaque token string or token_id (apit_xxxxx)
      
      
        Claims to merge; set value to "" to remove a claim
      
      
        Replacement description; null leaves unchanged, empty.
      
      
        The updated resource.
      

```java wrap showLineNumbers=false

Map newClaims = new HashMap<>();
newClaims.put("environment", "staging");
newClaims.put("old_claim", "");  // Remove this claim

scalekitClient.tokens().update("apit_xxxxx", newClaims, "Updated description");
```

    
  
</div>

</div>


---

## More Scalekit documentation

| Resource | What it contains | When to use it |
|----------|-----------------|----------------|
| [/llms.txt](/llms.txt) | Structured index with routing hints per product area | Start here — find which documentation set covers your topic before loading full content |
| [/llms-full.txt](/llms-full.txt) | Complete documentation for all Scalekit products in one file | Use when you need exhaustive context across multiple products or when the topic spans several areas |
| [sitemap-0.xml](https://docs.scalekit.com/sitemap-0.xml) | Full URL list of every documentation page | Use to discover specific page URLs you can fetch for targeted, page-level answers |
