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

# Rollback transaction

> Cancels a bet and returns the stake to the player.

Credit and rollback are **mutually exclusive**: a given bet is settled by one or the other, never both.

**Important —** Like credit, rollback must not require a live player session and is retried for up to 3 days.

If you have already rolled back this `referenceTransactionId`, return `200 OK` with your stored result — see [Idempotency](/wallet/idempotency).



## OpenAPI

````yaml api-reference/callbacks.json POST /rollback
openapi: 3.1.0
info:
  title: Zero-Dash Wallet Callbacks
  version: 1.0.0
  summary: >-
    The wallet API that you implement and Zero-Dash calls to authorize players
    and move money.
  description: >-
    **You implement these five endpoints. Zero-Dash calls them.**


    This is the inverse direction of the [Customer
    API](/api-reference/customer/list-games): here Zero-Dash is the client and
    your platform is the server. Mount them under any base path you like — the
    full path you register is what gets signed.


    All endpoints must be RESTful, accept and return JSON, and be served over
    HTTPS with a valid TLS certificate.


    Before you write a line of code, read [Wallet
    integration](/wallet/overview), [Amounts and currencies](/wallet/amounts)
    and [Idempotency](/wallet/idempotency).


    **Tip —** Use the playground on these pages to fire signed requests at
    **your own** implementation: set the `host` server variable to your callback
    host.
  contact:
    name: Zero-Dash Integrations
    email: info@zerodash.studio
servers:
  - url: https://{host}
    description: >-
      Your wallet host. Point this at your own environment to test your
      implementation. If you mount the endpoints under a path prefix (for
      example /zerodash/v1), include it in the host value — the full registered
      path is what gets signed.
    variables:
      host:
        default: wallet.example-operator.com
        description: The host you register with Zero-Dash, including any path prefix.
security:
  - signature: []
    timestamp: []
tags:
  - name: Wallet
    description: Player authorization and the money movements of a game round.
  - name: Troubleshooting
    description: Endpoints Zero-Dash uses to reconcile state after a failure.
paths:
  /rollback:
    post:
      tags:
        - Wallet
      summary: Rollback transaction (revert)
      description: >-
        Cancels a bet and returns the stake to the player.


        Credit and rollback are **mutually exclusive**: a given bet is settled
        by one or the other, never both.


        **Important —** Like credit, rollback must not require a live player
        session and is retried for up to 3 days.


        If you have already rolled back this `referenceTransactionId`, return
        `200 OK` with your stored result — see
        [Idempotency](/wallet/idempotency).
      operationId: rollback
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RollbackRequest'
            example:
              playerId: acct_8f2c19
              transactionId: test-transaction-1115
              referenceTransactionId: test-transaction-1112
              gameId: lucky-duck
              gameRoundId: round-1234
              stake:
                amount: 1
                currency: USD
              reason: paid
      responses:
        '200':
          description: Bet reverted and the stake returned.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionResponse'
              example:
                operatorTransactionId: op-tx-55903
                balance:
                  amount: 96
                  currency: USD
                  updatedAt: '2026-01-29T14:05:29.678Z'
                createdAt: '2026-01-29T14:05:29.678Z'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          description: The bet transaction to revert was not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                message: transaction to revert not found
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    RollbackRequest:
      type: object
      required:
        - playerId
        - transactionId
        - referenceTransactionId
        - gameId
        - gameRoundId
        - stake
      properties:
        playerId:
          type: string
          description: Player account ID.
        transactionId:
          type: string
          description: >-
            Zero-Dash ID of this rollback transaction. Use it as your
            idempotency key.
        referenceTransactionId:
          type: string
          description: '`transactionId` of the bet to revert.'
        gameId:
          type: string
          description: Slug of the game the round belongs to.
          examples:
            - lucky-duck
        gameRoundId:
          type: string
          description: Same value as the debit being reverted.
          examples:
            - round-1234
        stake:
          $ref: '#/components/schemas/Amount'
          description: Stake of the original bet, to be returned to the player.
        reason:
          $ref: '#/components/schemas/Reason'
        freeRoundData:
          $ref: '#/components/schemas/FreeRoundData'
    TransactionResponse:
      type: object
      required:
        - operatorTransactionId
        - balance
      properties:
        operatorTransactionId:
          type: string
          description: >-
            Your internal transaction ID. Stored by Zero-Dash for
            troubleshooting only.
        balance:
          $ref: '#/components/schemas/Balance'
        createdAt:
          type: string
          format: date-time
          description: >-
            Transaction creation date (ISO-8601 UTC). Defaults to the time of
            processing when omitted.
    Error:
      type: object
      description: Error body. Use this shape wherever possible so failures are actionable.
      properties:
        message:
          type: string
          description: Human-readable explanation of the failure.
    Amount:
      type: object
      required:
        - amount
        - currency
      description: >-
        A monetary value as a **decimal**, never in minor units. Crypto is
        capped at 8 decimal places.
      properties:
        amount:
          oneOf:
            - type: number
            - type: string
          description: Decimal value, for example `12.45` USD or `0.00000123` BTC.
          examples:
            - 1
        currency:
          type: string
          description: ISO-4217 currency code.
          examples:
            - USD
    Reason:
      type: string
      description: >-
        Type of the bet. `paid` is real money; `freeround` is a free round —
        each free spin is a separate bet with its own debit call.
      enum:
        - paid
        - freeround
    FreeRoundData:
      type: object
      required:
        - campaign
        - value
      description: Present only when `reason` is `freeround`.
      properties:
        campaign:
          type: string
          description: Campaign code the free round belongs to.
          examples:
            - freeround-campaign-1
        value:
          $ref: '#/components/schemas/Amount'
          description: Nominal value of one free round, as configured on the campaign.
    Balance:
      type: object
      required:
        - amount
        - currency
      description: The player's balance **after** the operation was applied.
      properties:
        amount:
          oneOf:
            - type: number
            - type: string
          description: >-
            Most recent decimal balance, for example `12.45` USD or `0.00000123`
            BTC.
          examples:
            - 95
        currency:
          type: string
          description: ISO-4217 currency code.
          examples:
            - USD
        updatedAt:
          type: string
          format: date-time
          description: When the balance was last updated (ISO-8601 UTC).
  responses:
    BadRequest:
      description: Invalid request payload format. Include an explanation in the body.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: missing field gameRoundId
    Unauthorized:
      description: >-
        Signature mismatch, stale timestamp, or source IP outside the Zero-Dash
        allowlist.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: invalid signature
    InternalError:
      description: Internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            message: internal error
  securitySchemes:
    signature:
      type: apiKey
      in: header
      name: X-Zd-Signature
      description: >-
        Hex-encoded `HMAC-SHA512(apiPath|timestamp|data, secretKey)` computed by
        Zero-Dash. **Recompute it and compare before doing anything else.** See
        [Request signature](/security/signature).
    timestamp:
      type: apiKey
      in: header
      name: X-Zd-Timestamp
      description: >-
        Unix time in **milliseconds**, and the exact value that was signed.
        Reject requests older than 5 minutes.

````