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

# Create Transaction Request (Cash Out)

> Create a new transaction request from one of your accounts. This does not perform an on-chain/bank transfer. You may provide a `webhookUrl` to receive status updates.

## 📝 Required Fields

- `accountId`: Your account ID to debit from
- `toCBU` or `toCVU`: Recipient bank CBU/CVU (22 digits)
- `amount`: Positive decimal number
- Optional `webhookUrl`: URL to receive status updates

## 🔍 Validation Rules

- Account must belong to the authenticated user
- CBU must be a valid 22-digit number
- Optional `externalID` must be unique per account if provided




## OpenAPI

````yaml /api-reference/openapi.pt-BR.yaml post /transactions
openapi: 3.1.0
info:
  title: HG.Cash API
  description: >
    # 🚀 API de transações HG.Cash


    API REST moderna para usuários criarem transações de saída a partir de suas
    contas.


    ## 🧾 Como funciona


    - A HG.Cash atribui contas ao seu usuário

    - Quando essas contas têm movimentação (entrada ou saída), a HG.Cash
    notifica o seu backend usando a URL de webhook configurada no painel

    - **Assinatura de webhooks (HMAC)**: Nas configurações da conta é possível
    gerar um segredo de assinatura. Quando configurado, cada POST de webhook
    inclui o cabeçalho `X-HG-Webhook-Signature: sha256=<hex>` com HMAC-SHA256 do
    corpo JSON usando o seu segredo. Verifique no seu endpoint para garantir
    autenticidade.

    - Para criar saques é necessário chamar o endpoint **Cash Out**: **Criar
    solicitação de transação** (`POST /transactions`)


    ## 📊 Primeiros passos


    1. **Gere seu token de API** na página de configurações da conta

    2. **Teste os endpoints** com a documentação interativa

    3. **Implemente** nos seus serviços de backend (nunca exponha tokens no
    frontend)

    4. **Monitore** a integração e trate erros adequadamente


    ## 🔐 Autenticação


    Esta API usa autenticação **Bearer Token**. Inclua o token de API do usuário
    no cabeçalho Authorization, por exemplo `Authorization: Bearer
    cash_your_token_here`.


    ## ⚠️ Segurança


    - Não compartilhe nem exponha o token de autenticação da API

    - Armazene tokens apenas em servidores backend seguros

    - Todas as chamadas devem ser feitas a partir de backends seguros

    - Se o token for comprometido, entre em contato com os administradores
    imediatamente
  version: 1.0.0
  contact:
    name: HG.Cash API Support
    email: api-support@hg.cash
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
servers:
  - url: https://hg.cash/api/v1
    description: Servidor de produção
  - url: http://dev.hg.cash/api/v1
    description: Servidor de desenvolvimento
security:
  - bearerAuth: []
tags:
  - name: Transactions
    description: >-
      Transaction Management - Create and manage transactions in the HG.Cash
      system. All transaction endpoints require authentication.
  - name: Accounts
    description: >-
      Accounts - Retrieve account information and balances for the authenticated
      user. All account endpoints require authentication.
  - name: Reference Data
    description: >-
      Reference Data - Get reference data like transaction statuses and types.
      These endpoints require authentication.
  - name: Webhooks
    description: Webhooks - Event notifications sent to your HTTP endpoint.
  - name: Brazil
    description: Brasil — Criar e consultar transações PIX (BRL).
  - name: Chile
    description: Chile — Checkout hospedado e payouts bancários (CLP).
  - name: Bolivia
    description: Bolívia — Cash-in com QR e payouts ACH (BOB).
  - name: Checkouts
    description: Sessões de checkout hospedado para AR, BR, CL e BO
paths:
  /transactions:
    post:
      tags:
        - Transactions
      summary: Create Transaction Request (Cash Out)
      description: >
        Create a new transaction request from one of your accounts. This does
        not perform an on-chain/bank transfer. You may provide a `webhookUrl` to
        receive status updates.


        ## 📝 Required Fields


        - `accountId`: Your account ID to debit from

        - `toCBU` or `toCVU`: Recipient bank CBU/CVU (22 digits)

        - `amount`: Positive decimal number

        - Optional `webhookUrl`: URL to receive status updates


        ## 🔍 Validation Rules


        - Account must belong to the authenticated user

        - CBU must be a valid 22-digit number

        - Optional `externalID` must be unique per account if provided
      operationId: createTransactionRequest
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Transaction'
            examples:
              basic_request_cbu:
                summary: Basic request
                description: Minimal required fields for an outbound transfer request
                value:
                  accountId: 550e8400-e29b-41d4-a716-446655440123
                  toCBU: '1100015400000000000021'
                  amount: 15000.5
              basic_request_cvu:
                summary: Basic request with CVU
                description: Minimal required fields using CVU destination
                value:
                  accountId: 550e8400-e29b-41d4-a716-446655440123
                  toCVU: '0000003100012345678901'
                  amount: 15000.5
              complete_request:
                summary: Complete request with webhook
                description: >-
                  Outbound transfer request with optional metadata and webhook
                  URL for status updates
                value:
                  accountId: 550e8400-e29b-41d4-a716-446655440123
                  toCBU: '1100015400000000000021'
                  amount: 25000
                  toName: María García
                  toCUIT: 27987654321
                  concept: Payment for consulting services
                  externalDate: '2024-06-19T10:30:00Z'
                  coelsaCode: COELSA123456
                  data:
                    reference: REF-001
                    category: services
                    client_id: CLIENT-789
                  webhookUrl: https://client.example.com/webhooks/transaction-request
      responses:
        '201':
          description: Transaction request created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TransactionRequestResponse'
              examples:
                success:
                  summary: Successful Creation
                  value:
                    id: 789e0123-e89b-12d3-a456-426614174999
                    externalID: REQ-2024-001234
                    createdAt: '2024-06-19T10:30:00Z'
                    status: PENDING
        '400':
          description: Bad Request - Invalid data provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                validation_error:
                  summary: Validation Error
                  value:
                    error: Validation failed
                    message: The provided data is invalid
                    details:
                      amount: Amount must be positive
                      currency: Currency must be 3 letters
        '401':
          description: Unauthorized - Invalid or missing token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                missing_token:
                  summary: Missing Token
                  value:
                    error: Authentication required
                    message: Bearer token is required
                invalid_token:
                  summary: Invalid Token
                  value:
                    error: Invalid token
                    message: The provided token is invalid or expired
        '403':
          description: Forbidden - Account does not belong to the authenticated user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden_account:
                  summary: Account access denied
                  value:
                    error: You do not have access to this account
        '404':
          description: Not Found
        '409':
          description: Conflict - Request cannot be created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                duplicate_external_id:
                  summary: Duplicate External ID
                  value:
                    error: >-
                      Transaction request with this external ID already exists
                      for this account
                    code: DUPLICATE_EXTERNAL_ID
                    message: The provided externalID already exists for this account
                insufficient_net_balance:
                  summary: Insufficient Net Balance
                  description: >-
                    Rejected because net balance (balance - pending fees) is
                    lower than the requested amount
                  value:
                    error: Insufficient net balance
                    code: INSUFFICIENT_NET_BALANCE
                    message: >-
                      Net available balance (balance - pending fees) is not
                      enough to cover the requested amount
                    details:
                      accountId: 550e8400-e29b-41d4-a716-446655440123
                      currency: ARS
                      amount: 15000.5
                      balance: 12000
                      pendingFees: 2000
                      netBalance: 10000
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                server_error:
                  summary: Server Error
                  value:
                    error: Internal server error
                    message: An unexpected error occurred
components:
  schemas:
    Transaction:
      type: object
      description: Outbound transaction creation request by a user
      required:
        - accountId
        - amount
      properties:
        accountId:
          type: string
          format: uuid
          description: ID of the user's account to send funds from
          example: 550e8400-e29b-41d4-a716-446655440123
        fromName:
          type: string
          description: Name of the transaction sender
          example: Juan Pérez
          maxLength: 255
        toName:
          type: string
          description: Name of the transaction recipient
          example: María García
          maxLength: 255
        fromCBU:
          type: number
          description: CBU (bank account number) of the sender
          example: 170001540000000020000
        toCBU:
          type: string
          description: Recipient CBU (22 digits). Provide either toCBU or toCVU.
          example: '1100015400000000000021'
        toCVU:
          type: string
          description: Recipient CVU (22 digits). Provide either toCBU or toCVU.
          example: '0000003100012345678901'
        amount:
          type: number
          format: decimal
          description: Transaction amount (must be positive)
          example: 15000.5
        fromCUIT:
          type: number
          description: CUIT/CUIL of the sender
          example: 20123456789
        toCUIT:
          type: number
          description: CUIT/CUIL of the recipient
          example: 27987654321
        concept:
          type: string
          description: Transaction concept or description
          example: Payment for services
          maxLength: 500
        externalDate:
          type: string
          format: date-time
          description: Transaction date in your system (ISO 8601 format)
          example: '2024-06-19T10:30:00Z'
        coelsaCode:
          type: string
          description: Coelsa transaction code
          example: COELSA123456
          maxLength: 100
        data:
          type: object
          description: Additional JSON data for the transaction
          example:
            reference: REF-001
            category: services
            metadata:
              source: mobile_app
              version: 1.2.3
        webhookUrl:
          type: string
          format: uri
          description: Optional webhook URL to receive status updates for this request
          example: https://client.example.com/webhooks/transaction-request
    TransactionRequestResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Internal transaction request ID
          example: 789e0123-e89b-12d3-a456-426614174999
        externalID:
          type: string
          example: REQ-2024-001234
        createdAt:
          type: string
          format: date-time
          example: '2024-06-19T10:30:00Z'
        status:
          type: string
          enum:
            - PENDING
            - AWAITING_REVIEW
            - PROCESSING
            - DONE
            - ERROR
            - CANCELLED
          example: PENDING
    ErrorResponse:
      type: object
      description: Error payload returned by the API.
      additionalProperties: true
      required:
        - error
      properties:
        error:
          type: string
          example: Invalid request
        code:
          type: string
          description: Machine-readable error code (when available)
          example: INSUFFICIENT_NET_BALANCE
        message:
          type: string
          example: The provided data is invalid
        details:
          type: object
          description: Additional error details
          example:
            field: amount
            code: INVALID_VALUE
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        User API authentication token with format `cash_<64-char-hex>`. Sample
        value
        `cash_16cdc3b6f83c72d9d2680adca4f430962981f6bf32613a129dded0aa060387d2`.

````