{
  "openapi": "3.1.0",
  "x-stoplight": {
    "id": "a4py3n5fh13nk"
  },
  "info": {
    "title": "Orders",
    "version": "3.0",
    "contact": {},
    "description": "Orders in TradingApi"
  },
  "servers": [
    {
      "url": "[ts-host]"
    }
  ],
  "tags": [
    {
      "name": "order"
    }
  ],
  "paths": {
    "/frontoffice/api/v3/orders": {
      "post": {
        "summary": "Create SPOT order",
        "tags": [
          "order"
        ],
        "operationId": "post-frontoffice-api-v4-orders",
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiCreateOrder.Response"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "order": {
                        "marketId": "spot.btc_usdt",
                        "marketDisplayName": "BTC/USDT",
                        "orderId": "65f1990aae5ec088da163949",
                        "orderType": "Market",
                        "side": "Buy",
                        "status": "Working",
                        "source": "Manual",
                        "timeInForce": "Ioc",
                        "commission": "0",
                        "requestedAmount": "0.001",
                        "remainingAmount": "0.001",
                        "requestedPrice": null,
                        "executionPrice": "0",
                        "createdAt": "2019-08-24T14:15:22Z",
                        "updatedAt": "2019-08-24T14:15:22Z",
                        "rejectDetails": "",
                        "cancellationDate": null,
                        "fillFactor": "0"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "Example 1": {
                    "value": {
                      "code": "TR0020",
                      "description": "OrderType is null or empty"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "description": "<p><b>Required operations:</b><br/>trading-ui</p>",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiCreateOrder.Request"
              },
              "examples": {
                "Example 1": {
                  "value": {
                    "order": {
                      "marketId": "btc_usdt",
                      "orderType": "Market",
                      "side": "Buy",
                      "requestedPrice": "0.002",
                      "requestedAmount": "0.002",
                      "timeInForce": "Gtc",
                      "cancellationDate": "2019-08-24T14:15:22Z"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "schema": {
              "type": "string"
            },
            "in": "header",
            "name": "accountId"
          }
        ]
      },
      "parameters": []
    }
  },
  "components": {
    "schemas": {
      "ApiCreateOrder.Request": {
        "title": "ApiCreateOrder.Request",
        "x-stoplight": {
          "id": "g2z7yzm3s0zb9"
        },
        "type": "object",
        "properties": {
          "order": {
            "$ref": "#/components/schemas/OrderRequestModel",
            "x-stoplight": {
              "id": "vlu04et6pe77e"
            }
          }
        },
        "required": [
          "order"
        ]
      },
      "ApiCreateOrder.Response": {
        "title": "ApiCreateOrder.Response",
        "x-stoplight": {
          "id": "w8nh5crkg16wx"
        },
        "type": "object",
        "properties": {
          "order": {
            "$ref": "#/components/schemas/ApiOrderResponseModel",
            "x-stoplight": {
              "id": "f3yzyqf42j5l7"
            }
          }
        },
        "examples": [
          {
            "order": {
              "marketId": "spot.btc_usdt",
              "marketDisplayName": "BTC/USDT",
              "orderId": "65f1990aae5ec088da163949",
              "orderType": "Market",
              "side": "Buy",
              "status": "Working",
              "source": "Manual",
              "timeInForce": "Ioc",
              "commission": "0",
              "requestedAmount": "0.001",
              "remainingAmount": "0.001",
              "requestedPrice": null,
              "executionPrice": "0",
              "createdAt": "2019-08-24T14:15:22Z",
              "updatedAt": "2019-08-24T14:15:22Z",
              "rejectDetails": "",
              "cancellationDate": null,
              "fillFactor": "0"
            }
          }
        ]
      },
      "OrderRequestModel": {
        "title": "OrderRequestModel",
        "x-stoplight": {
          "id": "pv1ifmez6j6sy"
        },
        "type": "object",
        "properties": {
          "marketId": {
            "type": "string",
            "x-stoplight": {
              "id": "fem2k0zk1x6th"
            },
            "pattern": "^(spot.){0,1}[a-z0-9]{1,15}_[a-z0-9]{1,15}$"
          },
          "orderType": {
            "$ref": "#/components/schemas/ApiOrderType",
            "x-stoplight": {
              "id": "vr9ahec8aphbr"
            }
          },
          "side": {
            "$ref": "#/components/schemas/ApiOrderSide",
            "x-stoplight": {
              "id": "uh6iqot715j3y"
            }
          },
          "requestedPrice": {
            "$ref": "#/components/schemas/StringDecimalNullable",
            "x-stoplight": {
              "id": "b4eq9c5ue09sl"
            }
          },
          "requestedAmount": {
            "$ref": "#/components/schemas/StringDecimal",
            "x-stoplight": {
              "id": "ifvnxdajhhyss"
            }
          },
          "timeInForce": {
            "$ref": "#/components/schemas/ApiOrderTimeInForce",
            "x-stoplight": {
              "id": "ir57okcwz275x"
            }
          },
          "cancellationDate": {
            "type": [
              "string",
              "null"
            ],
            "x-stoplight": {
              "id": "icgw311xtegwl"
            },
            "format": "date-time"
          }
        },
        "required": [
          "marketId",
          "orderType",
          "side",
          "requestedAmount",
          "timeInForce"
        ]
      },
      "ApiOrderResponseModel": {
        "title": "ApiOrderResponseModel",
        "x-stoplight": {
          "id": "xhlrn9ohsrp0x"
        },
        "type": "object",
        "examples": [
          {
            "marketId": "spot.btc_usdt",
            "marketDisplayName": "BTC/USDT",
            "orderId": "65f1990aae5ec088da163949",
            "orderType": "Market",
            "side": "Buy",
            "status": "Working",
            "source": "Manual",
            "timeInForce": "Ioc",
            "commission": "0",
            "requestedAmount": "0.001",
            "remainingAmount": "0.001",
            "requestedPrice": null,
            "executionPrice": "0",
            "createdAt": "2019-08-24T14:15:22Z",
            "updatedAt": "2019-08-24T14:15:22Z",
            "rejectDetails": "",
            "cancellationDate": null,
            "fillFactor": "0"
          }
        ],
        "properties": {
          "marketId": {
            "type": "string",
            "x-stoplight": {
              "id": "hc8585ll4vv6h"
            }
          },
          "marketDisplayName": {
            "type": "string",
            "x-stoplight": {
              "id": "j1dxmj9im1lf5"
            }
          },
          "orderId": {
            "type": "string",
            "x-stoplight": {
              "id": "22n9v0v1nsdte"
            }
          },
          "orderType": {
            "$ref": "#/components/schemas/ApiOrderType",
            "x-stoplight": {
              "id": "0fdgvnwhos3aw"
            }
          },
          "side": {
            "$ref": "#/components/schemas/ApiOrderSide",
            "x-stoplight": {
              "id": "vcx6adbmh2vh3"
            }
          },
          "status": {
            "$ref": "#/components/schemas/ApiOrderStatus",
            "x-stoplight": {
              "id": "cdkpm3tldnt1u"
            }
          },
          "source": {
            "$ref": "#/components/schemas/ApiOrderSource",
            "x-stoplight": {
              "id": "d5gzwto5t48ki"
            }
          },
          "timeInForce": {
            "$ref": "#/components/schemas/ApiOrderTimeInForce",
            "x-stoplight": {
              "id": "azx6qar8gxxq5"
            }
          },
          "commission": {
            "$ref": "#/components/schemas/StringDecimal",
            "x-stoplight": {
              "id": "lre9mgjklnllh"
            }
          },
          "requestedAmount": {
            "$ref": "#/components/schemas/StringDecimal",
            "x-stoplight": {
              "id": "aeq37ckntwfid"
            }
          },
          "remainingAmount": {
            "$ref": "#/components/schemas/StringDecimal",
            "x-stoplight": {
              "id": "yd2d65aie2vn5"
            }
          },
          "requestedPrice": {
            "$ref": "#/components/schemas/StringDecimalNullable",
            "x-stoplight": {
              "id": "rya5w0f1x5htw"
            }
          },
          "executionPrice": {
            "$ref": "#/components/schemas/StringDecimal",
            "x-stoplight": {
              "id": "ytlbrhqb9mg1e"
            }
          },
          "createdAt": {
            "type": "string",
            "x-stoplight": {
              "id": "0ujb8w5uwrk5r"
            },
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "x-stoplight": {
              "id": "3543x7u562i04"
            },
            "format": "date-time"
          },
          "rejectDetails": {
            "type": "string",
            "x-stoplight": {
              "id": "hzsw92n2p1aqr"
            }
          },
          "cancellationDate": {
            "type": [
              "string",
              "null"
            ],
            "x-stoplight": {
              "id": "2d97mtdb3blbn"
            },
            "format": "date-time"
          },
          "fillFactor": {
            "$ref": "#/components/schemas/StringDecimal",
            "x-stoplight": {
              "id": "dg2928n7jkeu1"
            }
          }
        }
      },
      "ApiOrderType": {
        "title": "ApiOrderType",
        "x-stoplight": {
          "id": "ama41z67eupvj"
        },
        "type": "string",
        "enum": [
          "Market",
          "Limit"
        ],
        "examples": []
      },
      "ApiOrderSide": {
        "title": "ApiOrderSide",
        "x-stoplight": {
          "id": "kk0pb41smqanc"
        },
        "type": "string",
        "enum": [
          "Buy",
          "Sell"
        ]
      },
      "ApiOrderStatus": {
        "title": "ApiOrderStatus",
        "x-stoplight": {
          "id": "eharbt9kdcp98"
        },
        "type": "string",
        "enum": [
          "Started",
          "Pending",
          "Working",
          "Completed",
          "Cancelled",
          "Expired",
          "Rejected"
        ]
      },
      "ApiOrderSource": {
        "title": "ApiOrderSource",
        "x-stoplight": {
          "id": "w511h7q6lx692"
        },
        "type": "string",
        "enum": [
          "Manual",
          "StopOrder",
          "FixApi"
        ]
      },
      "ApiOrderTimeInForce": {
        "title": "ApiOrderTimeInForce",
        "x-stoplight": {
          "id": "fubpbt6mz6ldx"
        },
        "type": "string",
        "enum": [
          "Gtc",
          "Ioc",
          "Fok",
          "Gtd",
          "Day"
        ]
      },
      "ErrorResponse": {
        "title": "ErrorResponse",
        "x-stoplight": {
          "id": "5er5hzwx2m94b"
        },
        "type": "object",
        "examples": [],
        "properties": {
          "code": {
            "type": "string",
            "x-stoplight": {
              "id": "enjwnyip98yuk"
            },
            "pattern": "^TR\\d{4}$"
          },
          "description": {
            "type": "string",
            "x-stoplight": {
              "id": "zn52g5ut0tzti"
            }
          }
        },
        "required": [
          "code"
        ]
      },
      "StringDecimal": {
        "title": "StringDecimal",
        "x-stoplight": {
          "id": "qjk2k8xpjwxgw"
        },
        "type": "string",
        "pattern": "^\\d+(\\.\\d+){0,1}",
        "examples": [
          "0.002",
          "10.015",
          "0.000001"
        ]
      },
      "StringDecimalNullable": {
        "title": "StringDecimalNullable",
        "x-stoplight": {
          "id": "e0aqo9bo7punf"
        },
        "type": [
          "string",
          "null"
        ],
        "pattern": "^\\d+(\\.\\d+){0,1}",
        "examples": [
          "0.002",
          "10.015",
          "0.000001",
          null
        ]
      }
    }
  }
}