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

# Build the unsigned manage/close transaction for a position



## OpenAPI

````yaml /api-reference/openapi.json post /v1/partner/manage/build
openapi: 3.1.0
info:
  title: Spiral Stake — Read API (v1)
  version: 0.1.0
  description: >-
    Read-only composition authority for Spiral Stake strategy data. Serves the
    frozen /strategies contract (agents + app) plus the full app read surface.
    All numbers are composed from warm cache; a stale/failed upstream serves
    last-good with a visible stale age.
servers:
  - url: https://api.spiralstake.xyz
    description: Production
  - url: http://localhost:8787
    description: Local
security: []
tags:
  - name: Public
    description: Open read endpoints — no key required.
  - name: Partner
    description: 'Keyed integration API — Authorization: Bearer <key>.'
paths:
  /v1/partner/manage/build:
    post:
      tags:
        - Partner
      summary: Build the unsigned manage/close transaction for a position
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - userAddress
                - id
                - action
              properties:
                userAddress:
                  type: string
                id:
                  type: integer
                  description: On-chain position index (from /positions).
                action:
                  type: string
                  enum:
                    - close
                    - increase_leverage
                    - add_collateral
                    - remove_collateral
                    - repay
                    - borrow
                amount:
                  type: string
                payToken:
                  type: string
                full:
                  type: boolean
                  description: 'repay only: clear the entire remaining debt.'
                desiredLtv:
                  type: string
                leverage:
                  type: number
                slippage:
                  type: number
                chainId:
                  type: integer
                  enum:
                    - 1
                    - 4663
      responses:
        '200':
          description: Unsigned tx bundle
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Unsigned transaction bundle. Non-custodial: sign approvals[]
                  first, then tx, from userAddress.
                properties:
                  chainId:
                    type: integer
                  action:
                    type: string
                    example: open_leverage
                  path:
                    type: string
                    enum:
                      - leverage
                      - swapAndLeverage
                      - reallocateAndLeverage
                      - reallocateSwapAndLeverage
                      - deleverage
                      - increaseLeverage
                      - supplyCollateral
                      - swapAndSupplyCollateral
                      - repay
                      - swapAndRepay
                      - withdrawCollateral
                      - borrow
                  approvals:
                    type: array
                    items:
                      type: object
                      properties:
                        to:
                          type: string
                        data:
                          type: string
                        value:
                          type: string
                      required:
                        - to
                        - data
                  tx:
                    type: object
                    properties:
                      to:
                        type: string
                      data:
                        type: string
                      value:
                        type: string
                    required:
                      - to
                      - data
                  meta:
                    type: object
                    properties:
                      positionPreview:
                        type: object
                        properties:
                          leverage:
                            type: string
                            example: '3.0'
                          requestedLtv:
                            type: string
                            example: '66.67'
                          effectiveLtv:
                            type: string
                            example: '66.73'
                          amountLeveragedCollateral:
                            type: string
                          expectedLeverageApy:
                            type: string
                            example: '5.64'
                          priceImpactPct:
                            type: string
                            example: '0.07'
                      amountFlashLoan:
                        type: string
                      minTokenOut:
                        type: string
                      slippage:
                        type: number
                      expiresAt:
                        type: string
                        format: date-time
                        description: >-
                          Swap calldata is time-sensitive (~60s); rebuild if it
                          lapses.
                      signingUrl:
                        type: string
                        description: >-
                          One-click link to review + sign in the user's own
                          wallet via the Spiral app.
                      instructions:
                        type: string
                required:
                  - chainId
                  - action
                  - path
                  - approvals
                  - tx
                  - meta
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      correlationId:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                      - correlationId
        '401':
          description: Missing/invalid API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      correlationId:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                      - correlationId
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      correlationId:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                      - correlationId
        '503':
          description: Transient (stale data / no route / RPC) — retry
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
                      correlationId:
                        type: string
                      details: {}
                    required:
                      - code
                      - message
                      - correlationId
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Partner API key: `Authorization: Bearer <key>`.'

````