# Control betting accounts

## POST /bookieaccount/control/

**Operation ID**: `send_command_to_bot_all`

Send a command to the bot for all sessions. This endpoint allows you to control all your bookie account bots simultaneously.

### Request Body

```json
{
  "command": "all_on"
}
```

#### Parameters

| Field     | Type   | Required | Description                                           |
| --------- | ------ | -------- | ----------------------------------------------------- |
| `command` | string | Yes      | Command name. Available commands: `all_on`, `all_off` |

### Available Commands

| Command   | Description                               |
| --------- | ----------------------------------------- |
| `all_on`  | Turn on all bots for all bookie accounts  |
| `all_off` | Turn off all bots for all bookie accounts |

### Response

#### Success Response (200)

```json
{
  "status": "success",
  "message": "Command 'all_on' sent to all bots successfully",
  "affected_accounts": 5,
  "results": [
    {
      "account_id": 123,
      "display_name": "TAB Main Account",
      "status": "success",
      "message": "Bot turned on successfully"
    },
    {
      "account_id": 124,
      "display_name": "WishBet Secondary",
      "status": "success", 
      "message": "Bot turned on successfully"
    },
    {
      "account_id": 125,
      "display_name": "Sportsbet Premium",
      "status": "failed",
      "message": "Bot already running"
    }
  ]
}
```

#### Error Responses

* **400 Bad Request** - Invalid command or request format
* **401 Invalid credentials** - Authentication token is invalid or missing
* **500 Internal server error** - Server encountered an error processing the request

### Usage

**Turn on all bots:**

```bash
curl -X POST "https://betmatic.app/api/bookieaccount/control/" \
  -H "Content-Type: application/json" \
  -H "Authorization: Token your_token" \
  -d '{
    "command": "all_on"
  }'
```

**Turn off all bots:**

```bash
curl -X POST "https://betmatic.app/api/bookieaccount/control/" \
  -H "Content-Type: application/json" \
  -H "Authorization: Token your_token" \
  -d '{
    "command": "all_off"
  }'
```

### Potential Use Cases

1. **Emergency Shutdown**: Quickly turn off all bots in case of issues or emergencies
2. **System Maintenance**: Turn off all bots before performing system maintenance
3. **Bulk Operations**: Efficiently manage all bots without individual account control
4. **Daily Operations**: Start all bots at the beginning of trading day
5. **Risk Management**: Quickly stop all automated betting during high-risk periods
6. **System Recovery**: Restart all bots after system issues or updates
7. **Scheduled Control**: Integrate with scheduling systems for automated bot management
8. **Compliance**: Ensure all bots are stopped during restricted periods

### Authentication

This endpoint requires authentication. Include your token in the Authorization header:

```
Authorization: Token your_token_here
```

### Important Notes

* **Bulk Operation**: This command affects ALL your bookie accounts simultaneously
* **Immediate Effect**: Commands take effect immediately across all accounts
* **Status Reporting**: The response includes individual results for each account
* **Error Handling**: Some accounts may succeed while others fail - check individual results
* **Bot Dependencies**: Ensure no critical betting operations are running before using `all_off`
* **Recovery Time**: Allow time for bots to fully start up after using `all_on`

### Best Practices

1. **Monitor Results**: Always check the response to ensure all accounts were affected as expected
2. **Gradual Rollout**: Consider controlling accounts individually for critical operations
3. **Backup Plans**: Have manual control procedures in case bulk commands fail
4. **Timing**: Use during low-activity periods to minimize impact on betting operations
