> For the complete documentation index, see [llms.txt](https://docs.tokenbot.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokenbot.com/home/api-docs/graphql-api/mutations.md).

# Mutations

## Authentication

### `register`

```graphql
mutation {
  register(email: "user@example.com", password: "securePass123!", recaptcha_token: "token") {
    success
    message
  }
}
```

### `login`

```graphql
mutation {
  login(email: "user@example.com", password: "pass", recaptcha_token: "token") {
    ... on AuthPayload {
      access_token
      refresh_token
      requires_2fa
      user { id email }
    }
    ... on Login2FAPendingPayload {
      user_id
      message
    }
  }
}
```

> `AuthPayload` returns snake\_case `access_token` / `refresh_token` (there is no `id_token`).

### `verify_2fa_code`

```graphql
mutation {
  verify_2fa_code(user_id: "user_123", token: "123456") {
    access_token
    refresh_token
  }
}
```

### `refresh_token`

```graphql
mutation {
  refresh_token(token: "refresh_token_here") {
    access_token
    refresh_token
  }
}
```

### `logout` / `logout_all`

```graphql
mutation { logout(token: "refresh_token") }
mutation { logout_all }
```

### OAuth

```graphql
mutation { google_auth(token: "google_oauth_token") { ... on AuthPayload { access_token } } }
mutation { x_auth(token: "twitter_oauth_token") { ... on AuthPayload { access_token } } }
mutation { apple_auth(token: "apple_id_token") { ... on AuthPayload { access_token } } }
mutation { telegram_auth(token: "telegram_auth_token") { ... on AuthPayload { access_token } } }
```

### Email Verification

```graphql
mutation { verify_email(token: "verification_token") { access_token } }
```

### Password Recovery

```graphql
mutation { forgot_password(email: "user@example.com", recaptcha_token: "token") { success message } }
mutation { reset_password(token: "reset_token", password: "newPass123!") { success message } }
```

### 2FA Management

```graphql
mutation { generate_2fa { secret qr_code } }
mutation { enable_2fa(token: "123456") }
mutation { disable_2fa }
```

## User

### `change_email`

```graphql
mutation { change_email(new_email: "new@example.com") { success message } }
```

### `confirm_email_change`

```graphql
mutation { confirm_email_change(token: "token") { success message } }
```

### `change_password`

```graphql
mutation { change_password(current_password: "old", new_password: "new") { success message } }
```

## Organizations

```graphql
mutation { createOrganization(input: { name: "My Org", description: "..." }) { id name } }
mutation { updateOrganization(id: "org_123", input: { name: "Updated" }) { id name } }
mutation { deleteOrganization(id: "org_123") }
mutation { inviteUserToOrganization(organization_id: "org_123", email: "user@example.com", role: "member") }
mutation { removeUserFromOrganization(organization_id: "org_123", user_id: "user_456") }
```

## Exchange Accounts

```graphql
mutation {
  createExchangeAccount(input: {
    exchange_name: "binance"
    account_name: "My Binance"
    trading_type: "spot"
    api_key: "..."
    api_secret: "..."
  }) { id exchange_name is_active }
}
```

```graphql
mutation { deleteExchangeAccount(id: "exc_123") }
mutation { syncExchangeBalance(id: "exc_123") { id balance last_sync_at } }
mutation { test_exchange_account(account: { exchange_name: "binance", api_key: "...", api_secret: "..." }) { success error } }
```

## Strategies

```graphql
mutation {
  create_strategy(strategy: {
    exchange_account_id: "exc_123"
    name: "BTC Momentum"
    risk_level: 3
  }) { success data { id name } }
}
```

```graphql
mutation { update_strategy(strategy: { id: "str_123", name: "Updated" }) { success data { id } } }
mutation { delete_strategy(id: "str_123") { success } }
mutation { link_copiers(strategy_id: "str_123", copier_ids: ["cop_456"]) { success linked_count } }
```

## Copiers

```graphql
mutation {
  create_copier(copier: {
    exchange_account_id: "exc_456"
    strategy_id: "str_123"
    name: "My Copier"
  }) { success data { id name } }
}
```

```graphql
mutation { update_copier(copier: { id: "cop_123", name: "Updated" }) { success } }
mutation { delete_copier(id: "cop_123") { success } }
mutation { toggleCopierStatus(id: "cop_123") { id is_active } }
```

## Trades

```graphql
mutation {
  createTrade(input: {
    exchange_account_id: "exc_123"
    trade_pair_id: "tp_btcusdt"
    type: "LIMIT"
    side: "BUY"
    price: 50000
    amount: 0.1
  }) { id status }
}
```

```graphql
mutation { cancelTrade(id: "trd_123") { id status } }
```

## Notifications

```graphql
mutation { markNotificationAsRead(id: "notif_123") { id } }
mutation { markAllNotificationsAsRead }
mutation { deleteNotification(id: "notif_123") }
```

## Settings

```graphql
mutation { updateUserSetting(key: "theme", value: "dark") { key value } }
mutation { deleteUserSetting(key: "theme") }
```

## Rewards & Withdrawals

```graphql
mutation { claimReward(reward_id: "rwd_123") { id } }
mutation { createWithdraw(input: { amount: 100, wallet_address: "0x..." }) { id } }
mutation { cancelWithdraw(id: "wd_123") { id } }
```

## Onboarding

```graphql
mutation { completeOnboarding { success } }
mutation { resetOnboarding { success } }
mutation { trackOnboardingEvent(event: "exchange_connected", stepId: "step1") }
```

## Passkeys

```graphql
mutation { generatePasskeyRegistrationChallenge { success data { challenge rp { id name } } } }
mutation { registerPasskey(credential: "...", device_name: "MacBook") { success data { id device_name } } }
mutation { generatePasskeyLoginChallenge(email: "user@example.com") { success data { challenge rpId } } }
mutation { loginWithPasskey(credential: "...", recaptcha_token: "token") { access_token refresh_token } }
mutation { deletePasskey(id: "pk_123") { success } }
mutation { renamePasskey(id: "pk_123", device_name: "Work Laptop") { success } }
```

## Admin Mutations

```graphql
mutation { updateUserStatus(user_id: "user_123", is_active: false) { id is_active } }
mutation { grantSystemAdmin(user_id: "user_123") { id is_system_admin } }
mutation { revokeSystemAdmin(user_id: "user_123") { id is_system_admin } }
mutation { adminResetUserPassword(user_id: "user_123") { success temporary_password } }
mutation { adminChangeUserEmail(user_id: "user_123", new_email: "new@example.com") { success } }
mutation { adminResetUser2FA(user_id: "user_123") { success } }
mutation { adminDeactivateUser(user_id: "user_123", reason: "TOS violation") { success } }
mutation { adminReactivateUser(user_id: "user_123") { success } }
mutation { adminToggleSystemAdmin(user_id: "user_123", is_admin: true) { success } }
mutation { adminEnableApiKey(key_id: "key_123", type: "rest") { success } }
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tokenbot.com/home/api-docs/graphql-api/mutations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
