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

# Create a TWAP or VWAP order



## OpenAPI

````yaml /openapi.yaml post /v1/twap-orders
openapi: 3.1.0
info:
  title: Funding Perpetuals API
  version: 1.0.0
  description: >-
    Programmatic access to Funding Perpetuals paper-trading challenge accounts.
    API trades use the same real order books and simulated execution engine as
    the web trading interface.
  contact:
    url: https://fundingperpetuals.com/support
servers:
  - url: https://developers.fundingperpetuals.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: General
  - name: Accounts
  - name: Markets
  - name: Positions
  - name: Orders
  - name: Fills
  - name: Strategy Orders
paths:
  /v1/twap-orders:
    post:
      tags:
        - Strategy Orders
      summary: Create a TWAP or VWAP order
      operationId: createTwapOrder
      parameters:
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTwapOrderRequest'
      responses:
        '200':
          description: Idempotent replay.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TwapOrderEnvelope'
        '201':
          description: Scheduled order created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TwapOrderEnvelope'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '422':
          $ref: '#/components/responses/TradeRejected'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: >-
        Unique printable key for this intended order. Reuse it only for an
        identical retry.
      schema:
        type: string
        minLength: 1
        maxLength: 128
  schemas:
    CreateTwapOrderRequest:
      type: object
      additionalProperties: false
      required:
        - account_id
        - market_id
        - side
        - size
        - expected_price
        - leverage
        - margin_mode
        - duration_minutes
      properties:
        account_id:
          type: string
        market_id:
          type: string
        strategy:
          type: string
          enum:
            - twap
            - vwap
          default: twap
        side:
          type: string
          enum:
            - buy
            - sell
        size:
          type: number
          exclusiveMinimum: 0
        expected_price:
          type: number
          exclusiveMinimum: 0
        leverage:
          type: number
          exclusiveMinimum: 0
        margin_mode:
          type: string
          enum:
            - cross
            - isolated
        duration_minutes:
          type: integer
          minimum: 5
          maximum: 1440
        slice_interval_seconds:
          type: integer
          minimum: 30
          maximum: 43200
          description: At most half the selected duration, with a global 12-hour ceiling.
        randomize:
          type: boolean
          default: false
        reduce_only:
          type: boolean
          default: false
        trigger_price:
          type: number
          exclusiveMinimum: 0
        max_price:
          type: number
          exclusiveMinimum: 0
        min_price:
          type: number
          exclusiveMinimum: 0
    TwapOrderEnvelope:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/TwapOrder'
    TwapOrder:
      type: object
      required:
        - id
        - account_id
        - market_id
        - strategy
        - side
        - total_size
        - filled_size
        - leverage
        - margin_mode
        - reduce_only
        - duration_minutes
        - slice_interval_seconds
        - status
        - started_at
        - end_at
      properties:
        id:
          type: string
        account_id:
          type: string
        market_id:
          type: string
        provider:
          type: string
        symbol:
          type: string
        coin:
          type: string
        strategy:
          type: string
          enum:
            - twap
            - vwap
        side:
          type: string
          enum:
            - buy
            - sell
        total_size:
          type: number
        filled_size:
          type: number
        size_decimals:
          type: integer
        average_price:
          type: number
        leverage:
          type: number
        margin_mode:
          type: string
          enum:
            - cross
            - isolated
        reduce_only:
          type: boolean
        duration_minutes:
          type: integer
        slice_interval_seconds:
          type: integer
        slice_count:
          type: integer
        slices_attempted:
          type: integer
        randomize:
          type: boolean
        trigger_price:
          type: number
        max_price:
          type: number
        min_price:
          type: number
        status:
          type: string
        current_child_order_id:
          type: string
        activated_at:
          type: number
        started_at:
          type: number
        end_at:
          type: number
        next_run_at:
          type: number
        canceled_at:
          type: number
        completed_at:
          type: number
        completion_reason:
          type: string
    ErrorEnvelope:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/Error'
    TradeRejectionEnvelope:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/TradeRejection'
    Error:
      type: object
      required:
        - code
        - message
        - request_id
      properties:
        code:
          type: string
        message:
          type: string
        request_id:
          type: string
          format: uuid
    TradeRejection:
      allOf:
        - $ref: '#/components/schemas/Error'
        - type: object
          properties:
            order_id:
              type: string
            rule_id:
              type: string
            details:
              type: object
              additionalProperties: true
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Unauthorized:
      description: Missing, invalid, or revoked API key.
      headers:
        WWW-Authenticate:
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    NotFound:
      description: Resource not found or not owned by the authenticated user.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    Conflict:
      description: The request conflicts with current state or an idempotency record.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
    TradeRejected:
      description: The trading engine rejected the requested operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/TradeRejectionEnvelope'
    RateLimited:
      description: A per-key, per-IP, or deployment request budget is exhausted.
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorEnvelope'
  headers:
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
        minimum: 1
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Funding Perpetuals API key
      description: API key beginning with `fp_live_`.

````