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

# Create vault with auto-invest

> **Advanced Function**: Creates a new DeFindex vault and automatically invests deposited funds.

    This endpoint creates a batched transaction that:
    1. Creates the vault with initial deposit
    2. Invests funds in specified strategies (rebalance)
    3. Changes manager to the final address

    All operations are atomic - either all succeed or all fail. This provides a seamless user experience for creating fully-invested vaults in a single transaction.



## OpenAPI

````yaml POST /factory/create-vault-auto-invest
openapi: 3.0.0
info:
  title: DeFindex API
  description: API documentation for DeFindex endpoints
  version: 1.0.0
  contact: {}
  x-logo:
    url: https://links.paltalabs.io/defindex-full.svg
    backgroundColor: '#0e0e0e'
    altText: DeFindex Logo
    href: https://defindex.io
servers: []
security: []
tags: []
paths:
  /factory/create-vault-auto-invest:
    post:
      tags:
        - Factory
      summary: Create vault with auto-invest
      description: >-
        **Advanced Function**: Creates a new DeFindex vault and automatically
        invests deposited funds.

            This endpoint creates a batched transaction that:
            1. Creates the vault with initial deposit
            2. Invests funds in specified strategies (rebalance)
            3. Changes manager to the final address

            All operations are atomic - either all succeed or all fail. This provides a seamless user experience for creating fully-invested vaults in a single transaction.
      operationId: FactoryController_createVaultAutoInvest
      parameters:
        - name: network
          required: true
          in: query
          description: Stellar network to execute the transaction on (testnet or mainnet)
          schema:
            enum:
              - testnet
              - mainnet
            type: string
      requestBody:
        required: true
        description: Auto-invest vault creation parameters
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateVaultAutoInvestDto'
            examples:
              Create vault with auto-invest:
                value:
                  caller: GBZXUKUYGXLASTLIXGIV2RJGWQHVRIS7AANR7AHXFPA67LNSAGO6WPPE
                  roles:
                    emergencyManager: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
                    rebalanceManager: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
                    feeReceiver: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
                    manager: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
                  name: Auto-Invest Test Vault
                  symbol: AITV
                  vaultFee: 10
                  upgradable: true
                  assets:
                    - address: CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC
                      symbol: XLM
                      amount: 200
                      strategies:
                        - address: >-
                            CCEE2VAGPXKVIZXTVIT4O5B7GCUDTZTJ5RIXBPJSZ7JWJCJ2TLK75WVW
                          name: xlm_hodl_strategy
                          amount: 100
                        - address: >-
                            CAHWRPKBPX4FNLXZOAD565IBSICQPL5QX37IDLGJYOPWX22WWKFWQUBA
                          name: xlm_juice_strategy
                          amount: 100
      responses:
        '201':
          description: Transaction XDR created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  xdr:
                    type: string
                    description: Transaction XDR to sign and submit
                  predictedVaultAddress:
                    type: string
                    description: >-
                      Predicted vault address from simulation (may differ from
                      actual)
                  warning:
                    type: string
                    description: Warning about address prediction reliability
                example:
                  xdr: AAAAAgAAAAA...
                  predictedVaultAddress: CCQ2BCKKDX7HSF5TULLRFRKS4RYIC5ZZGYYTBR3XFDLZ6MMZFRJNXIEA
                  warning: >-
                    The vault address is predicted from simulation. Actual
                    address may differ if network state changes.
        '400':
          description: Invalid parameters or strategy allocations
        '500':
          description: Failed to create transaction
components:
  schemas:
    CreateVaultAutoInvestDto:
      type: object
      properties:
        caller:
          type: string
          description: Caller address who will deposit and initially manage
          example: GBZXUKUYGXLASTLIXGIV2RJGWQHVRIS7AANR7AHXFPA67LNSAGO6WPPE
        roles:
          description: Vault roles configuration
          allOf:
            - $ref: '#/components/schemas/VaultRolesDto'
        name:
          type: string
          description: Vault name
          example: My Auto-Invest Vault
          minLength: 1
          maxLength: 32
        symbol:
          type: string
          description: Vault symbol
          example: MAIV
          minLength: 1
          maxLength: 10
        vaultFee:
          type: number
          description: Vault fee in basis points (0-10000, where 10000 = 100%)
          example: 10
          minimum: 0
          maximum: 10000
        upgradable:
          type: boolean
          description: Whether vault is upgradable
          example: true
        assets:
          description: Asset allocations with strategies (1-10 assets)
          minItems: 1
          maxItems: 10
          type: array
          items:
            $ref: '#/components/schemas/AssetAllocationDto'
      required:
        - caller
        - roles
        - name
        - symbol
        - vaultFee
        - upgradable
        - assets
    VaultRolesDto:
      type: object
      properties:
        emergencyManager:
          type: string
          description: Emergency manager address
          example: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
        rebalanceManager:
          type: string
          description: Rebalance manager address
          example: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
        feeReceiver:
          type: string
          description: Fee receiver address
          example: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
        manager:
          type: string
          description: Vault manager address
          example: GBAJGSZQRZDMHKU4DAS6FEJM7TYISAME5LNERKOT7XLMNFZ5IF5ROXOQ
      required:
        - emergencyManager
        - rebalanceManager
        - feeReceiver
        - manager
    AssetAllocationDto:
      type: object
      properties:
        address:
          type: string
          description: Asset contract address
          example: CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC
        symbol:
          type: string
          description: Asset symbol
          example: XLM
        amount:
          type: number
          description: >-
            Total amount to deposit for this asset (in stroops, must be a
            positive integer)
          example: 2000000000
          minimum: 1
        strategies:
          description: Strategies for this asset with allocation amounts (1-10 strategies)
          minItems: 1
          maxItems: 10
          type: array
          items:
            $ref: '#/components/schemas/StrategyAllocationDto'
      required:
        - address
        - symbol
        - amount
        - strategies
    StrategyAllocationDto:
      type: object
      properties:
        address:
          type: string
          description: Strategy contract address
          example: CCEE2VAGPXKVIZXTVIT4O5B7GCUDTZTJ5RIXBPJSZ7JWJCJ2TLK75WVW
        name:
          type: string
          description: Strategy name
          example: xlm_hodl_strategy
        amount:
          type: number
          description: >-
            Amount to invest in this strategy (in stroops, 0 or positive
            integer)
          example: 1000000000
          minimum: 0
      required:
        - address
        - name
        - amount

````

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