> **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/)

---

# API tokens

API tokens for service access
<div class="sdk-client-page">

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

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.

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

      Runs `CreateToken` and returns the result.

      
        Request context
      
      
        Organization ID.
      
      
        Optional request settings.
      
      
        The created resource.
      

```go wrap showLineNumbers=false
expiry := time.Now().Add(24 * time.Hour)
resp, err := scalekitClient.Token().CreateToken(ctx, "org_123", scalekit.CreateTokenOptions{
  UserId:       "usr_123",
  Description:  "Service account token",
  CustomClaims: map[string]string{
    "source": "service",
  },
  Expiry:       &expiry,
})
if err != nil {
  // handle
}
_ = resp.Token
```

    
  
</div>

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

      Runs `ValidateToken` and returns the result.

      
        Request context
      
      
        Token string.
      
      
        Verified claims or result.
      

```go wrap showLineNumbers=false
resp, err := scalekitClient.Token().ValidateToken(ctx, "api_token_here")
if err != nil {
  // token is invalid or expired
}
_ = resp.Token
```

    
  
</div>

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

      Runs `InvalidateToken` and returns the result.

      
        Request context
      
      
        Token string.
      
      
        error
      

```go wrap showLineNumbers=false
if err := scalekitClient.Token().InvalidateToken(ctx, "api_token_here"); err != nil {
  // handle
}
```

    
  
</div>

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

      Runs `ListTokens` and returns the result.

      
        Request context
      
      
        Organization ID.
      
      
        Optional request settings.
      
      
        Paginated results.
      

```go wrap showLineNumbers=false
tokens, err := scalekitClient.Token().ListTokens(ctx, "org_123", scalekit.ListTokensOptions{})
if err != nil {
  // handle
}
for _, token := range tokens.Tokens {
  _ = token
}

// Filter by user ID
userTokens, err := scalekitClient.Token().ListTokens(ctx, "org_123", scalekit.ListTokensOptions{
  UserId: "usr_123",
})
```

    
  
</div>

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

      Runs `UpdateToken` and returns the result.

      
        Request context
      
      
        Token string.
      
      
        Optional request settings.
      
      
        The updated resource.
      

    
  
</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 |
