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

# Create Order via WebSocket

> Create a new trading order via WebSocket API

Creates a new trading order via WebSocket API. Supports all order types available in the REST API including limit, market, stop-limit, trailing, ceiling, and iceberg orders.

## Request

<ParamField body="id" type="string" required>
  Unique request identifier for correlation
</ParamField>

<ParamField body="method" type="string" required>
  WebSocket API method. Must be `order.create`
</ParamField>

<ParamField body="params" type="object" required>
  Request parameters containing authentication and order details

  <Expandable title="Authentication">
    <ParamField body="params.api_token" type="string" required>
      API Token for authentication
    </ParamField>

    <ParamField body="params.timestamp" type="integer" required>
      Timestamp in milliseconds (UTC)
    </ParamField>

    <ParamField body="params.signature" type="string" required>
      HMAC SHA256 signature of the request
    </ParamField>
  </Expandable>

  <Expandable title="Order Parameters">
    <ParamField body="params.pair" type="string" required>
      Trading pair code (e.g., BTC\_BRL, ETH\_BRL)
    </ParamField>

    <ParamField body="params.side" type="string" required>
      Order side: `buy` or `sell`
    </ParamField>

    <ParamField body="params.type" type="string" required>
      Order type: `limit`, `market`, `stop_limit`, `trailing`, `ceiling`, or `iceberg`
    </ParamField>

    <ParamField body="params.amount" type="number" required>
      Order amount in base currency
    </ParamField>

    <ParamField body="params.price" type="number">
      Limit price (required for limit, stop\_limit, trailing, ceiling, and iceberg orders)
    </ParamField>

    <ParamField body="params.value" type="number">
      Order value in quote currency (required for market and ceiling orders)
    </ParamField>

    <ParamField body="params.stop_price" type="number">
      Stop price (required for stop\_limit orders)
    </ParamField>

    <ParamField body="params.distance" type="number">
      Distance from market price (required for trailing orders)
    </ParamField>

    <ParamField body="params.step_amount" type="number">
      Step amount (required for iceberg orders) (the ratio of amount to step\_amount must be less than or equal to 10)
    </ParamField>

    <ParamField body="params.external_id" type="string">
      Order external identifier (maximum of 36 chars) (optional)
    </ParamField>

    <ParamField body="params.post_only" type="boolean">
      If set to `true`, the order will be added directly to the order book without an initial match, provided the request is valid
    </ParamField>

    <ParamField body="params.expiration" type="number">
      If a valid timestamp is provided, the order will be created with an expiration date and time
    </ParamField>

    <ParamField body="params.immediate_or_cancel" type="boolean">
      If set to `true`, the order will not be added to the order book after the initial match, any remaining unfilled amount will result in the order being canceled
    </ParamField>

    <ParamField body="params.fill_or_kill" type="boolean">
      If set to `true`, the order will either be completely filled or canceled
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="id" type="string">
  Request identifier for correlation
</ResponseField>

<ResponseField name="status" type="integer">
  HTTP status code (200 for success)
</ResponseField>

<ResponseField name="result" type="object">
  Order details object

  <Expandable title="Order Result">
    <ResponseField name="id" type="string">
      Order identifier
    </ResponseField>

    <ResponseField name="status" type="string">
      Order status: `open`, `executed_partially`, `executed_completely`, or `canceled`
    </ResponseField>

    <ResponseField name="create_date" type="string">
      Order creation datetime (ISO 8601 format)
    </ResponseField>

    <ResponseField name="external_id" type="string">
      External order identifier
    </ResponseField>

    <ResponseField name="pair" type="string">
      Trading pair code
    </ResponseField>

    <ResponseField name="side" type="string">
      Order side: `buy` or `sell`
    </ResponseField>

    <ResponseField name="executed_amount" type="number">
      Amount that has been executed
    </ResponseField>

    <ResponseField name="remaining_amount" type="number">
      Amount remaining to be executed
    </ResponseField>

    <ResponseField name="remaining_value" type="number">
      Value remaining to be executed
    </ResponseField>

    <ResponseField name="requested_amount" type="number">
      Total amount requested
    </ResponseField>

    <ResponseField name="requested_value" type="number">
      Total value requested
    </ResponseField>
  </Expandable>
</ResponseField>

## Error Response

<ResponseField name="id" type="string">
  Request identifier for correlation
</ResponseField>

<ResponseField name="status" type="integer">
  HTTP error status code
</ResponseField>

<ResponseField name="result" type="null">
  Always null for error responses
</ResponseField>

<ResponseField name="error" type="object">
  Error details object

  <Expandable title="Error Details">
    <ResponseField name="error_code" type="integer">
      Error code (e.g., 40011 for insufficient funds)
    </ResponseField>

    <ResponseField name="message" type="string">
      Human-readable error message
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

<CodeGroup>
  ```json Limit Buy Order theme={null}
  {
    "id": "req-001",
    "method": "order.create",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "pair": "BTC_BRL",
      "side": "buy",
      "type": "limit",
      "amount": 0.001,
      "price": 100000,
      "external_id": "my-order-123"
    }
  }
  ```

  ```json Market Sell Order theme={null}
  {
    "id": "req-002",
    "method": "order.create",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "pair": "ETH_BRL",
      "side": "sell",
      "type": "market",
      "amount": 0.1,
      "value": 1000
    }
  }
  ```

  ```json Stop Limit Buy Order theme={null}
  {
    "id": "req-005",
    "method": "order.create",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "pair": "BTC_BRL",
      "side": "buy",
      "type": "stop_limit",
      "amount": 1,
      "price": 700000,
      "stop_price": 650000,
      "external_id": "stop-buy-202"
    }
  }
  ```

  ```json Trailing Buy Order theme={null}
  {
    "id": "req-007",
    "method": "order.create",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "pair": "BTC_BRL",
      "side": "buy",
      "type": "trailing",
      "amount": 1,
      "price": 700000,
      "distance": 5000,
      "external_id": "trailing-buy-404"
    }
  }
  ```

  ```json Ceiling Buy Order theme={null}
  {
    "id": "req-009",
    "method": "order.create",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "pair": "BTC_BRL",
      "side": "buy",
      "type": "ceiling",
      "value": 50000,
      "external_id": "ceiling-buy-606",
      "fill_or_kill": false
    }
  }
  ```

  ```json Iceberg Buy Order theme={null}
  {
    "id": "req-011",
    "method": "order.create",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "pair": "BTC_BRL",
      "side": "buy",
      "type": "iceberg",
      "amount": 10,
      "step_amount": 1,
      "price": 700000,
      "external_id": "iceberg-buy-808"
    }
  }
  ```
</CodeGroup>

## Success Response Example

```json theme={null}
{
  "id": "req-001",
  "status": 200,
  "result": {
    "id": "7155ED34-9EC4-4733-8B32-1E4319CB662F",
    "status": "open",
    "create_date": "2024-03-27T13:27:19.853Z",
    "external_id": "my-order-123",
    "pair": "BTC_BRL",
    "side": "buy",
    "executed_amount": 0,
    "remaining_amount": 0.001,
    "remaining_value": 100,
    "requested_amount": 0.001,
    "requested_value": 100
  }
}
```

## Error Response Example

```json theme={null}
{
  "id": "req-001",
  "status": 400,
  "result": null,
  "error": {
    "error_code": 40011,
    "message": "Insufficient funds."
  }
}
```

## Supported Order Types

### Limit Orders

Buy and sell orders with a specified price. Available parameters:

* `amount`, `price`
* Optional: `post_only`, `expiration`, `immediate_or_cancel`, `fill_or_kill`

### Market Orders

Buy and sell orders executed at current market price. Available parameters:

* `amount`, `value`
* Optional: `fill_or_kill`

### Stop Limit Orders

Buy and sell orders that trigger at a specified stop price and then execute at the limit price. Available parameters:

* `amount`, `price`, `stop_price`

### Trailing Orders

Buy and sell orders that follow the price at a specified distance. Available parameters:

* `amount`, `price`, `distance`

### Ceiling Orders

Buy and sell orders up to a specified value at any price. Available parameters:

* `value`
* Optional: `fill_or_kill`

### Iceberg Orders

Large orders that are split into smaller visible chunks. Available parameters:

* `amount`, `step_amount`, `price`
