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

# Replace a transaction split

> Replaces the children of an existing split. The previous children are destroyed, so anything set on them afterwards is not carried over.



## OpenAPI

````yaml /openapi.yaml patch /api/v1/transactions/{transaction_id}/split
openapi: 3.0.3
info:
  title: Sure API
  version: v1
  description: OpenAPI documentation generated from executable request specs.
servers:
  - url: https://app.sure.am
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
paths:
  /api/v1/transactions/{transaction_id}/split:
    parameters:
      - name: transaction_id
        in: path
        description: Transaction ID. A split child resolves to its parent.
        required: true
        schema:
          type: string
    patch:
      tags:
        - Transactions
      summary: Replace a transaction split
      description: >-
        Replaces the children of an existing split. The previous children are
        destroyed, so anything set on them afterwards is not carried over.
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SplitRequest'
      responses:
        '200':
          description: split replaced
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Split'
      security:
        - apiKeyAuth: []
components:
  schemas:
    SplitRequest:
      type: object
      required:
        - split
      properties:
        split:
          type: object
          required:
            - splits
          properties:
            splits:
              type: array
              minItems: 1
              description: >-
                Child transactions. Amounts must sum exactly to the parent
                amount.
              items:
                type: object
                required:
                  - amount
                properties:
                  name:
                    type: string
                    nullable: true
                    description: Defaults to the parent name when omitted
                  amount:
                    type: string
                    description: >-
                      Positive for expenses and negative for income, matching
                      the stored transaction amount. Inputs are rounded to four
                      decimal places before the sum is checked.
                  category_id:
                    type: string
                    nullable: true
                  excluded:
                    type: boolean
                    nullable: true
    Split:
      type: object
      required:
        - transaction_id
        - amount
        - amount_decimal
        - amount_cents
        - currency
        - children
      properties:
        transaction_id:
          type: string
        amount:
          type: string
          description: Formatted parent amount, rounded for display
        amount_decimal:
          type: string
          description: Exact stored amount; children must sum to this
        amount_cents:
          type: integer
          description: Absolute amount in minor units
        currency:
          type: string
        children:
          type: array
          items:
            $ref: '#/components/schemas/SplitChild'
    SplitChild:
      allOf:
        - $ref: '#/components/schemas/Transaction'
        - type: object
          required:
            - amount_decimal
            - excluded
          properties:
            amount_decimal:
              type: string
              description: Exact stored amount; send this back when replacing the split
            excluded:
              type: boolean
              description: Whether this child is excluded from totals
    Transaction:
      type: object
      required:
        - id
        - date
        - amount
        - currency
        - name
        - classification
        - account
        - tags
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        date:
          type: string
          format: date
        amount:
          type: string
        currency:
          type: string
        name:
          type: string
        notes:
          type: string
          nullable: true
        external_id:
          type: string
          nullable: true
        source:
          type: string
          nullable: true
        user_modified:
          type: boolean
        classification:
          type: string
        account:
          $ref: '#/components/schemas/Account'
        category:
          $ref: '#/components/schemas/Category'
          nullable: true
        merchant:
          $ref: '#/components/schemas/Merchant'
          nullable: true
        tags:
          type: array
          items:
            $ref: '#/components/schemas/Tag'
        transfer:
          $ref: '#/components/schemas/Transfer'
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    Account:
      type: object
      required:
        - id
        - name
        - account_type
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        account_type:
          type: string
          nullable: true
        status:
          type: string
    Category:
      type: object
      required:
        - id
        - name
        - color
        - icon
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        color:
          type: string
        icon:
          type: string
    Merchant:
      type: object
      required:
        - id
        - name
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
    Tag:
      type: object
      required:
        - id
        - name
        - color
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        color:
          type: string
    Transfer:
      type: object
      required:
        - id
        - amount
        - currency
      properties:
        id:
          type: string
          format: uuid
        amount:
          type: string
        currency:
          type: string
        other_account:
          $ref: '#/components/schemas/Account'
          nullable: true
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      name: X-Api-Key
      in: header
      description: API key for authentication. Generate one from your account settings.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.