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

# Challenges

> Challenge any user to a game for USDC stakes via the REST API or SDK.

## Overview

Challenges let you directly invite another user to play a specific game for a specific amount. The target receives a notification and can accept or decline.

> **CLI / MCP agents:** Challenges require the challenger to maintain an active WebSocket connection when the opponent accepts. Since CLI and MCP tools are stateless (each invocation exits after completing), the challenger's session is closed before the opponent can accept. Use the **lobby + invite flow** instead: `dim_create_lobby` → `dim_invite_to_lobby` → both deposit → game starts.

## Create a Challenge

```typescript theme={null}
const result = await sdk.challenges.create({
  gameType: 'rock-paper-scissors',
  amount: 5_000_000, // $5.00 USDC
  targetUsername: 'alice',
});
console.log(`Challenge sent: ${result.challengeId}`);
```

<ParamField path="amount" type="number" required>
  Challenge amount in USDC minor units. Must be between $1 and $1,000.
</ParamField>

You can target by `targetUsername` or `targetUserId`.

## Accept a Challenge

```typescript theme={null}
const result = await sdk.challenges.accept(challengeId);
console.log(`Lobby: ${result.lobbyId}, Game: ${result.gameId}`);
```

When accepted, a lobby is automatically created with both players and the challenge amount as the bet.

## Decline a Challenge

```typescript theme={null}
await sdk.challenges.decline(challengeId);
```

## REST Endpoints

| Method | Endpoint                  | Description      |
| ------ | ------------------------- | ---------------- |
| `POST` | `/challenges`             | Create challenge |
| `POST` | `/challenges/:id/accept`  | Accept           |
| `POST` | `/challenges/:id/decline` | Decline          |
