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

# Update the conditions of an arbitrage auto-close order

> Replaces all conditions of a pending auto-close order and starts every count over. Only orders that have not started closing can be updated.



## OpenAPI

````yaml https://vooi-api-app.fly.dev/swagger/json patch /arbitrage-auto-close-orders/{id}
openapi: 3.1.0
info:
  title: VOOI API
  description: Unified perps API
  version: '1.0'
  contact: {}
servers:
  - url: https://perps-api.vooi.io
security: []
tags: []
paths:
  /arbitrage-auto-close-orders/{id}:
    patch:
      tags:
        - Arbitrage Auto-Close Orders
      summary: Update the conditions of an arbitrage auto-close order
      description: >-
        Replaces all conditions of a pending auto-close order and starts every
        count over. Only orders that have not started closing can be updated.
      operationId: ArbitrageAutoCloseOrderController_updateArbitrageAutoCloseOrder
      parameters:
        - name: id
          required: true
          in: path
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateArbitrageAutoCloseOrderBodyDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ArbitrageAutoCloseOrderDto'
        '409':
          description: >-
            The order has already started closing, or an update of it is still
            being saved
        '503':
          description: The arbitrage order service is unreachable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDTO'
      security:
        - bearer: []
components:
  schemas:
    UpdateArbitrageAutoCloseOrderBodyDto:
      type: object
      properties:
        conditions:
          minItems: 1
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  closeAt:
                    description: >-
                      When to close both positions, as an ISO 8601 timestamp in
                      the future.
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                  type:
                    type: string
                    description: Closes both positions at a fixed time.
                    enum:
                      - time
                required:
                  - closeAt
                  - type
                title: ArbitrageAutoCloseTimeCondition
              - type: object
                properties:
                  holdSeconds:
                    type: integer
                    minimum: 0
                    maximum: 2147483647
                    description: >-
                      How many seconds the count runs once the condition is met
                      (see mode), 0 to close as soon as it is met; any restart
                      of the service starts the count over.
                    example: 300
                  mode:
                    type: string
                    enum:
                      - doubleCheck
                      - hold
                    description: >-
                      How the count confirms the condition: hold (it must stay
                      met for holdSeconds in a row, any value that is not met
                      starts the count over) or doubleCheck (it is checked once
                      more when holdSeconds run out, whatever it did in between,
                      and closes only if it is still met).
                  operator:
                    type: string
                    enum:
                      - gte
                      - lte
                    description: >-
                      How the spread is compared with the threshold: gte (met
                      when the spread is at or above it) or lte (met when the
                      spread is at or below it).
                  threshold:
                    type: number
                    description: >-
                      Price spread to compare against, as a signed decimal
                      fraction ((short bid − long ask) / mid, the scanner
                      priceSpread for this pair); the close itself trades the
                      other side of both books, so it realizes roughly the
                      bid-ask of both markets less.
                    example: 0.001
                  type:
                    type: string
                    description: >-
                      Closes both positions when the live price spread of the
                      pair meets the threshold.
                    enum:
                      - priceSpread
                required:
                  - holdSeconds
                  - mode
                  - operator
                  - threshold
                  - type
                title: ArbitrageAutoClosePriceSpreadCondition
              - type: object
                properties:
                  holdSeconds:
                    type: integer
                    minimum: 0
                    maximum: 2147483647
                    description: >-
                      How many seconds the count runs once the condition is met
                      (see mode), 0 to close as soon as it is met; any restart
                      of the service starts the count over.
                    example: 300
                  mode:
                    type: string
                    enum:
                      - doubleCheck
                      - hold
                    description: >-
                      How the count confirms the condition: hold (it must stay
                      met for holdSeconds in a row, any value that is not met
                      starts the count over) or doubleCheck (it is checked once
                      more when holdSeconds run out, whatever it did in between,
                      and closes only if it is still met).
                  operator:
                    type: string
                    enum:
                      - gte
                      - lte
                    description: >-
                      How the spread is compared with the threshold: gte (met
                      when the spread is at or above it) or lte (met when the
                      spread is at or below it).
                  threshold:
                    type: number
                    description: >-
                      Hourly funding spread to compare against, as a signed
                      decimal fraction (short − long funding, the scanner
                      fundingSpread1h for this pair).
                    example: 0.00005
                  type:
                    type: string
                    description: >-
                      Closes both positions when the hourly funding spread of
                      the pair meets the threshold.
                    enum:
                      - fundingSpread
                required:
                  - holdSeconds
                  - mode
                  - operator
                  - threshold
                  - type
                title: ArbitrageAutoCloseFundingSpreadCondition
              - type: object
                properties:
                  holdSeconds:
                    type: integer
                    minimum: 0
                    maximum: 2147483647
                    description: >-
                      How many seconds the count runs once the condition is met
                      (see mode), 0 to close as soon as it is met; any restart
                      of the service starts the count over.
                    example: 300
                  mode:
                    type: string
                    enum:
                      - doubleCheck
                      - hold
                    description: >-
                      How the count confirms the condition: hold (it must stay
                      met for holdSeconds in a row, any value that is not met
                      starts the count over) or doubleCheck (it is checked once
                      more when holdSeconds run out, whatever it did in between,
                      and closes only if it is still met).
                  type:
                    type: string
                    description: >-
                      Closes both positions when the hourly funding spread
                      (short − long funding) turns negative, so the pair starts
                      paying funding.
                    enum:
                      - fundingFlip
                required:
                  - holdSeconds
                  - mode
                  - type
                title: ArbitrageAutoCloseFundingFlipCondition
            description: >-
              A condition that closes the position when it is met: time (at a
              fixed time), priceSpread (price spread against a threshold),
              fundingSpread (hourly funding spread against a threshold) or
              fundingFlip (funding spread turns negative).
            type: object
          description: >-
            The conditions to watch from now on; they replace the ones the order
            was created with, and every condition starts counting again.
      required:
        - conditions
      title: UpdateArbitrageAutoCloseOrder
    ArbitrageAutoCloseOrderDto:
      type: object
      properties:
        conditions:
          type: array
          items:
            oneOf:
              - type: object
                properties:
                  closeAt:
                    description: When both positions get closed.
                    type: string
                    format: date-time
                    pattern: >-
                      ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                  type:
                    type: string
                    description: Closes both positions at a fixed time.
                    enum:
                      - time
                required:
                  - closeAt
                  - type
                title: ArbitrageAutoCloseTimeConditionResponse
              - type: object
                properties:
                  holdSeconds:
                    type: integer
                    minimum: 0
                    maximum: 2147483647
                    description: >-
                      How many seconds the count runs once the condition is met
                      (see mode), 0 to close as soon as it is met; any restart
                      of the service starts the count over.
                    example: 300
                  mode:
                    type: string
                    enum:
                      - doubleCheck
                      - hold
                    description: >-
                      How the count confirms the condition: hold (it must stay
                      met for holdSeconds in a row, any value that is not met
                      starts the count over) or doubleCheck (it is checked once
                      more when holdSeconds run out, whatever it did in between,
                      and closes only if it is still met).
                  operator:
                    type: string
                    enum:
                      - gte
                      - lte
                    description: >-
                      How the spread is compared with the threshold: gte (met
                      when the spread is at or above it) or lte (met when the
                      spread is at or below it).
                  threshold:
                    type: number
                    description: >-
                      Price spread to compare against, as a signed decimal
                      fraction ((short bid − long ask) / mid, the scanner
                      priceSpread for this pair); the close itself trades the
                      other side of both books, so it realizes roughly the
                      bid-ask of both markets less.
                    example: 0.001
                  type:
                    type: string
                    description: >-
                      Closes both positions when the live price spread of the
                      pair meets the threshold.
                    enum:
                      - priceSpread
                  metSince:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                      - type: 'null'
                    description: >-
                      When the current count started, null while there is none;
                      the condition is confirmed or checked again holdSeconds
                      after it.
                required:
                  - holdSeconds
                  - mode
                  - operator
                  - threshold
                  - type
                  - metSince
                title: ArbitrageAutoClosePriceSpreadConditionResponse
              - type: object
                properties:
                  holdSeconds:
                    type: integer
                    minimum: 0
                    maximum: 2147483647
                    description: >-
                      How many seconds the count runs once the condition is met
                      (see mode), 0 to close as soon as it is met; any restart
                      of the service starts the count over.
                    example: 300
                  mode:
                    type: string
                    enum:
                      - doubleCheck
                      - hold
                    description: >-
                      How the count confirms the condition: hold (it must stay
                      met for holdSeconds in a row, any value that is not met
                      starts the count over) or doubleCheck (it is checked once
                      more when holdSeconds run out, whatever it did in between,
                      and closes only if it is still met).
                  operator:
                    type: string
                    enum:
                      - gte
                      - lte
                    description: >-
                      How the spread is compared with the threshold: gte (met
                      when the spread is at or above it) or lte (met when the
                      spread is at or below it).
                  threshold:
                    type: number
                    description: >-
                      Hourly funding spread to compare against, as a signed
                      decimal fraction (short − long funding, the scanner
                      fundingSpread1h for this pair).
                    example: 0.00005
                  type:
                    type: string
                    description: >-
                      Closes both positions when the hourly funding spread of
                      the pair meets the threshold.
                    enum:
                      - fundingSpread
                  metSince:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                      - type: 'null'
                    description: >-
                      When the current count started, null while there is none;
                      the condition is confirmed or checked again holdSeconds
                      after it.
                required:
                  - holdSeconds
                  - mode
                  - operator
                  - threshold
                  - type
                  - metSince
                title: ArbitrageAutoCloseFundingSpreadConditionResponse
              - type: object
                properties:
                  holdSeconds:
                    type: integer
                    minimum: 0
                    maximum: 2147483647
                    description: >-
                      How many seconds the count runs once the condition is met
                      (see mode), 0 to close as soon as it is met; any restart
                      of the service starts the count over.
                    example: 300
                  mode:
                    type: string
                    enum:
                      - doubleCheck
                      - hold
                    description: >-
                      How the count confirms the condition: hold (it must stay
                      met for holdSeconds in a row, any value that is not met
                      starts the count over) or doubleCheck (it is checked once
                      more when holdSeconds run out, whatever it did in between,
                      and closes only if it is still met).
                  type:
                    type: string
                    description: >-
                      Closes both positions when the hourly funding spread
                      (short − long funding) turns negative, so the pair starts
                      paying funding.
                    enum:
                      - fundingFlip
                  metSince:
                    anyOf:
                      - type: string
                        format: date-time
                        pattern: >-
                          ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
                      - type: 'null'
                    description: >-
                      When the current count started, null while there is none;
                      the condition is confirmed or checked again holdSeconds
                      after it.
                required:
                  - holdSeconds
                  - mode
                  - type
                  - metSince
                title: ArbitrageAutoCloseFundingFlipConditionResponse
            description: >-
              A condition that closes the position when it is met, with its
              current progress.
            type: object
          description: >-
            Conditions being watched, any one of which closes the position; the
            first one met closes both legs.
        createdAt:
          description: When the auto-close order was accepted.
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
        error:
          description: Why the order failed, null otherwise.
          type:
            - string
            - 'null'
        executionStartedAt:
          anyOf:
            - type: string
              format: date-time
              pattern: >-
                ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
            - type: 'null'
          description: When closing started, null while the order is still waiting.
        firedConditionType:
          anyOf:
            - type: string
              enum:
                - fundingFlip
                - fundingSpread
                - priceSpread
                - time
            - type: 'null'
          description: >-
            Type of the condition that closed the position: time, priceSpread,
            fundingSpread or fundingFlip; null until one is met.
        id:
          type: string
          format: uuid
          pattern: >-
            ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
          description: Arbitrage auto-close order identifier.
          example: 019d5cbe-6980-7193-a80e-38a45eda36d8
        legs:
          type: object
          properties:
            long:
              type: object
              properties:
                clientOrderId:
                  description: >-
                    Identifier sent to the exchange with the closing order, null
                    until it is placed.
                  type:
                    - string
                    - 'null'
                error:
                  description: >-
                    Exchange error text when this leg failed to close, null
                    otherwise.
                  type:
                    - string
                    - 'null'
                exchange:
                  type: string
                  enum:
                    - aster
                    - binance
                    - bybit
                    - extended
                    - gate
                    - hyperliquid
                    - lighter
                    - mexc
                    - ondo
                    - robinhood
                  description: Perpetual exchange
                exchangeOrderId:
                  description: >-
                    Order identifier assigned by the exchange to the closing
                    order, null until it is placed. Stays null on Lighter, which
                    answers with a transaction hash instead.
                  type:
                    - string
                    - 'null'
                marketId:
                  type: string
                  description: Venue-specific market identifier.
                  example: ETHUSDT
                status:
                  type: string
                  enum:
                    - executed
                    - not_sent
                    - sent
                  description: >-
                    not_sent — no closing order has gone to the exchange yet.
                    sent — a closing order was sent and its outcome is still
                    unknown. executed — this leg is done, either because the
                    exchange accepted the closing order or because there was no
                    position left to close.
              required:
                - clientOrderId
                - error
                - exchange
                - exchangeOrderId
                - marketId
                - status
              title: ArbitrageAutoCloseOrderLeg
              description: The market whose long position gets closed.
            short:
              type: object
              properties:
                clientOrderId:
                  description: >-
                    Identifier sent to the exchange with the closing order, null
                    until it is placed.
                  type:
                    - string
                    - 'null'
                error:
                  description: >-
                    Exchange error text when this leg failed to close, null
                    otherwise.
                  type:
                    - string
                    - 'null'
                exchange:
                  type: string
                  enum:
                    - aster
                    - binance
                    - bybit
                    - extended
                    - gate
                    - hyperliquid
                    - lighter
                    - mexc
                    - ondo
                    - robinhood
                  description: Perpetual exchange
                exchangeOrderId:
                  description: >-
                    Order identifier assigned by the exchange to the closing
                    order, null until it is placed. Stays null on Lighter, which
                    answers with a transaction hash instead.
                  type:
                    - string
                    - 'null'
                marketId:
                  type: string
                  description: Venue-specific market identifier.
                  example: ETHUSDT
                status:
                  type: string
                  enum:
                    - executed
                    - not_sent
                    - sent
                  description: >-
                    not_sent — no closing order has gone to the exchange yet.
                    sent — a closing order was sent and its outcome is still
                    unknown. executed — this leg is done, either because the
                    exchange accepted the closing order or because there was no
                    position left to close.
              required:
                - clientOrderId
                - error
                - exchange
                - exchangeOrderId
                - marketId
                - status
              title: ArbitrageAutoCloseOrderLeg
              description: The market whose short position gets closed.
          required:
            - long
            - short
          title: ArbitrageAutoCloseOrderLegs
        status:
          type: string
          enum:
            - canceled
            - created
            - executed
            - executionStarted
            - failed
          description: >-
            created — watching the conditions, none has been met yet.
            executionStarted — a condition was met and both legs are being
            closed. executed — both markets were cleared, closing whatever
            position was open on each. canceled — canceled before any condition
            was met. failed — closing a leg was rejected, the worker was
            interrupted mid-close, or the close time passed while the service
            was down; the position may still be open.
          example: created
        unifiedSymbol:
          type: string
          description: >-
            Cross-exchange asset key — an alias (alias:1000bonk) when defined,
            otherwise the base symbol.
          example: ETH
        updatedAt:
          description: When the order last changed.
          type: string
          format: date-time
          pattern: >-
            ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$
      required:
        - conditions
        - createdAt
        - error
        - executionStartedAt
        - firedConditionType
        - id
        - legs
        - status
        - unifiedSymbol
        - updatedAt
      title: ArbitrageAutoCloseOrder
    ErrorResponseDTO:
      type: object
      properties:
        message:
          type: string
          example: 'Invalid order id: 123'
        statusCode:
          example: 503
          type: number
      required:
        - message
      title: ErrorResponse
  securitySchemes:
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````

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