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

# Apply code

> Apply a WhiteBIT code to an account to receive the associated funds via the V4 API.



## OpenAPI

````yaml /openapi/private/main_api_v4.yaml POST /api/v4/main-account/codes/apply
openapi: 3.0.3
info:
  title: WhiteBIT Private HTTP API V4
  description: |
    WhiteBIT Private HTTP API V4 for Main balance changes.

    Base URL: https://whitebit.com

    All endpoints return time in Unix-time format.
    All endpoints return either a JSON object or array.
    For receiving responses from API calls please use http method POST.
  version: 4.0.0
  contact:
    name: WhiteBIT Support
    email: support@whitebit.com
    url: https://whitebit.com
servers:
  - url: https://whitebit.com
    description: WhiteBIT Global Server
  - url: https://whitebit.eu
    description: WhiteBIT EU Server
security:
  - ApiKeyAuth: []
    PayloadAuth: []
    SignatureAuth: []
tags:
  - name: Main Account
    description: Main account balance and operations
  - name: Deposit
    description: Cryptocurrency and fiat deposit operations
  - name: Withdraw
    description: Cryptocurrency and fiat withdrawal operations
  - name: Transfer
    description: Balance transfer operations
  - name: Codes
    description: WhiteBIT codes operations
  - name: Crypto Lending - Fixed
    description: Fixed crypto lending plans
  - name: Crypto Lending - Flex
    description: Flexible crypto lending plans
  - name: Fees
    description: Fee information
  - name: Sub-Account
    description: Sub-account management
  - name: Sub-Account API Keys
    description: Sub-account API key management
  - name: Mining Pool
    description: Mining pool operations
  - name: Credit Line
    description: Credit line information
  - name: JWT
    description: JWT token management
paths:
  /api/v4/main-account/codes/apply:
    post:
      tags:
        - Codes
      summary: Apply code
      description: >
        The endpoint applies [WhiteBIT code](/glossary#whitebit-codes).


        <Warning>

        Rate limit: 60 requests/1 sec.

        </Warning>


        <Note>

        The API does not cache the response.

        </Note>


        <Note>

        To avoid leaking whether a code exists, most failure modes — invalid
        format, expired,

        non-existent, or wrong passphrase — collapse to one generic rejection on
        field `code`.

        Only two cases are distinguishable at the API surface: a code that has
        already been

        applied, and a code created by the same account.

        </Note>
      operationId: applyCode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - code
                - request
                - nonce
              properties:
                code:
                  type: string
                  description: '[Code](/glossary#whitebit-codes) that will be applied.'
                  example: WBe11f4fce-2a53-4edc-b195-66b693bd77e3ETH
                passphrase:
                  type: string
                  maxLength: 25
                  description: >-
                    Should be provided if the [code](/glossary#whitebit-codes)
                    was created with passphrase. Max: 25 symbols.
                  example: some passphrase
                request:
                  type: string
                  description: Request signature
                  example: '{{request}}'
                nonce:
                  type: integer
                  description: Unique request identifier
                  example: 1594297865000
            example:
              code: WBe11f4fce-2a53-4edc-b195-66b693bd77e3ETH
              passphrase: some passphrase
              request: '{{request}}'
              nonce: 1594297865000
      responses:
        '201':
          description: All validations succeeded and creating transaction is started
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                  ticker:
                    type: string
                  amount:
                    type: string
                  external_id:
                    type: string
              example:
                message: Code was successfully applied
                ticker: ETH
                amount: '0.002'
                external_id: be08a482-5faf-11ed-9b6a-0242ac120002
        '400':
          description: Request validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missingCode:
                  summary: Missing code field
                  value:
                    code: 0
                    message: Validation failed
                    errors:
                      code:
                        - The code field is required.
                incorrectCode:
                  summary: Incorrect code or passphrase
                  value:
                    code: 0
                    message: Validation failed
                    errors:
                      code:
                        - Incorrect code or passphrase
                codeNotApplied:
                  summary: >-
                    Generic rejection (invalid format / expired / non-existent /
                    wrong passphrase)
                  value:
                    code: 0
                    message: Validation failed
                    errors:
                      code:
                        - Code not applied
                codeAlreadyApplied:
                  summary: Code has already been applied
                  value:
                    code: 0
                    message: Validation failed
                    errors:
                      code:
                        - Code already applied
                ownCode:
                  summary: Applying a code created by the same account
                  value:
                    code: 0
                    message: Validation failed
                    errors:
                      code:
                        - This code was created by you
        '422':
          description: >
            Inner validation failed. Returned with `code: 0`; the message is
            localized, so

            match on the condition rather than the exact string.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorInner'
              examples:
                kycRequired:
                  summary: KYC verification required to redeem
                  value:
                    code: 0
                    message: Inner validation failed
                    errors:
                      error:
                        - KYC required
                codesDisabled:
                  summary: WhiteBIT codes are disabled for this currency
                  value:
                    code: 0
                    message: Inner validation failed
                    errors:
                      code:
                        - Codes are disabled for this currency
components:
  schemas:
    Error:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
    ErrorInner:
      type: object
      properties:
        code:
          type: integer
        message:
          type: string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-TXC-APIKEY
      description: The public WhiteBIT API key.
    PayloadAuth:
      type: apiKey
      in: header
      name: X-TXC-PAYLOAD
      description: Base64-encoded JSON request body.
    SignatureAuth:
      type: apiKey
      in: header
      name: X-TXC-SIGNATURE
      description: >-
        HMAC-SHA512 signature of the payload, hex-encoded. Computed as
        hex(HMAC-SHA512(payload, api_secret)).

````