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

# Open a perp position

> Build unsigned versioned transaction(s) that open a perp position on the
chosen venue. One transaction per wallet in `wallet_addresses`.

**Idempotency:** identical `client_order_id` within 60s returns the
cached response (same tx) instead of rebuilding.

**Oracle freshness:** the build snapshots the Pyth oracle at request
time and fails fast (`503`) if the feed is missing or stale — the
server never signs a perp tx against a stale price band.

**Funding mint:** when `funding_mint` differs from the venue's native
input mint, the server attaches a Pyth-derived `SwapFunding` spec so
the on-chain ix performs the keeper-side Jupiter swap on increase.
Supported funding mints: USDC, USD1, wSOL, BTC, ETH.




## OpenAPI

````yaml openapi-spec/trading.yaml post /perp/sol/order
openapi: 3.0.3
info:
  title: Raze Trading API
  description: >
    Trading endpoints for Solana token swaps — quote, buy, sell, atomic

    round-trips and raw instructions. Perpetuals (Jupiter Perps + Phoenix) live

    here too.


    Quotes can also be **streamed**: `/swap/sol/quote/stream` is a WebSocket
    that

    pushes a fresh quote whenever the pools under your route move. It is not

    describable in OpenAPI — see

    [Streaming quotes](/api-reference/router/quote-stream).


    Write utilities (`/utils/sol/*` — launch, transfer, burn, consolidate, fees)

    moved to the History API on `https://api.raze.bot` (see `history.yaml`).


    Runs on port 8082.


    **Auth methods**: `Authorization: Bearer sk_...` header, `X-API-Key: sk_...`
    header, or `?apiKey=sk_...` query param.
  version: 2.1.0
servers:
  - url: https://router.raze.bot
    description: >-
      Raze global trading router — GeoDNS routes to the nearest region
      automatically
security: []
paths:
  /perp/sol/order:
    post:
      summary: Open a perp position
      description: |
        Build unsigned versioned transaction(s) that open a perp position on the
        chosen venue. One transaction per wallet in `wallet_addresses`.

        **Idempotency:** identical `client_order_id` within 60s returns the
        cached response (same tx) instead of rebuilding.

        **Oracle freshness:** the build snapshots the Pyth oracle at request
        time and fails fast (`503`) if the feed is missing or stale — the
        server never signs a perp tx against a stale price band.

        **Funding mint:** when `funding_mint` differs from the venue's native
        input mint, the server attaches a Pyth-derived `SwapFunding` spec so
        the on-chain ix performs the keeper-side Jupiter swap on increase.
        Supported funding mints: USDC, USD1, wSOL, BTC, ETH.
      operationId: perpOpenOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PerpOrderRequest'
            example:
              wallet_addresses:
                - 62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm
              market_id: jup:SOL-PERP
              side: long
              collateral_usdc_e6: 100000000
              leverage_bps: 50000
              slippage_bps: 50
              client_order_id: ui-2026-05-06-a1b2c3
      responses:
        '200':
          description: Transactions built
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PerpTxResponse'
        '400':
          description: >-
            Invalid request (bad wallet, market_id, funding_mint, or missing
            client_order_id)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Builder error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Oracle stale or missing — refusing to build
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
components:
  schemas:
    PerpOrderRequest:
      type: object
      required:
        - wallet_addresses
        - market_id
        - side
        - collateral_usdc_e6
        - leverage_bps
        - slippage_bps
        - client_order_id
      properties:
        wallet_addresses:
          type: array
          items:
            type: string
          minItems: 1
        market_id:
          type: string
          example: jup:SOL-PERP
        side:
          type: string
          enum:
            - long
            - short
        collateral_usdc_e6:
          type: integer
          format: int64
          description: |
            Collateral in USDC micros. Server converts to the venue's input-mint
            native units (lamports for SOL longs, USDC e6 for shorts) using the
            live oracle price.
        leverage_bps:
          type: integer
          example: 50000
        slippage_bps:
          type: integer
          example: 50
        client_order_id:
          type: string
          description: |
            Caller-supplied idempotency key. Identical IDs within the 60s
            window return the cached response (same tx) instead of rebuilding.
        funding_mint:
          type: string
          nullable: true
          description: >
            Optional funding mint. Omit (or set to the venue's native input
            mint)

            for the native-funding path. Pass a different supported mint

            (USDC, USD1, wSOL, BTC, ETH) to attach a Pyth-derived `SwapFunding`

            spec — the on-chain ix performs the keeper-side Jupiter swap on

            increase. Other mints return an error.
        limit_price_e6:
          type: integer
          format: int64
          nullable: true
          description: |
            **Phoenix only.** Place a resting LIMIT order at this USD e6 price
            instead of a market order. Jupiter exposes no user-callable limit
            path (`instantCreateLimitOrder` is keeper-gated), so sending this
            with a `jup:` market returns 400.
    PerpTxResponse:
      type: object
      properties:
        success:
          type: boolean
        data:
          type: array
          items:
            $ref: '#/components/schemas/PerpTx'
        error:
          type: string
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        error:
          type: string
        details:
          type: string
      required:
        - success
        - error
    PerpTx:
      type: object
      description: One unsigned transaction per wallet in the request.
      properties:
        wallet:
          type: string
        tx_b64:
          type: string
          description: Base64-encoded unsigned versioned transaction.
        status:
          type: string
          description: >-
            Builder-side hint (e.g. `created`, `funded_swap`,
            `phoenix-deposit`).
        position_request:
          type: string
          description: |
            `position_request` PDA this transaction creates or targets (Jupiter
            builds only). Lets a client cancel a stuck request without a History
            API round-trip. The PDA counter is derived deterministically from
            `client_order_id`, so the same request rebuilt on another edge lands
            on the same PDA — exactly-once on-chain.
        counter:
          type: integer
          format: int64
          description: PDA counter used to derive `position_request` (create paths only).
        position:
          type: string
          description: Position PDA the request acts on.
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    BearerAuth:
      type: http
      scheme: bearer

````