# Create an order

POST https://api.bb.no/v1/orders

Places a new order. If the endpoint returns with a 200 status, the order
 is successfully placed. If you're creating a market order, a trade is
 also created, and its ID is included in the response. Requests are not
 idempotent: after a timeout, check open orders before retrying.

## Authentication

x-bb-api-key: Public part of your API key. Starts with `bb/public/`.

x-bb-api-hmac: HMAC authentication for the API request, constructed using the corresponding secret value from your API key.

x-bb-api-nonce: Nonce value. Used to ensure correct ordering of all API requests, as well as prevent attackers from being able to replay old requests. Can be set to any value, but needs to increase for each request. Recommendation is to use the current Unix timestamp in milliseconds.

API-key permission: trading.

[API keys and signing](https://barebitcoin.no/developers/authentication/api-keys)

## Parameters

None.

## Request body

[NewOrderRequest](https://barebitcoin.no/developers/models/NewOrderRequest).

## Examples

### Signed API key

```sh
curl -X POST \
  https://api.bb.no/v1/orders \
  -H "Content-Type: application/json" \
  -H "x-bb-api-key: $BB_API_KEY" \
  -H "x-bb-api-nonce: $BB_NONCE" \
  -H "x-bb-api-hmac: $BB_HMAC" \
  -d '{
    "type": "ORDER_TYPE_MARKET",
    "direction": "DIRECTION_BUY",
    "amount": 100
  }'
```



## Responses

### 200

OK

Example:

```json
{
  "orderId": "or_01J9ZK4T7M2QXW8B3N5R6V1Y0C",
  "tradeId": "tr_01J9ZK4T7S8P2D6F4H0K3M5N7Q"
}
```

[NewOrderResponse](https://barebitcoin.no/developers/models/NewOrderResponse).

Source: https://barebitcoin.no/developers/api/orders/create-order


## Model: NewOrderRequest





### type

Type: string · enum.



Values: ORDER_TYPE_MARKET, ORDER_TYPE_LIMIT



### direction

Type: string · enum.



Values: DIRECTION_BUY, DIRECTION_SELL



### amount

Type: number · double.

Amount to spend. Must be positive. When buying, this is the amount in NOK.
 When selling, this is the amount in BTC.





### accountId

Type: string.

The bitcoin account to use for this order. Empty for default account.





### description

Type: string.

Free-form text description of the order. Can be used to correlate with
 your own systems.





### price

Type: number · double.

The price to buy or sell at. Only used for limit orders.





## Model: NewOrderResponse





### orderId

Type: string.

ID of the created order.





### tradeId

Type: string.

If this was a market order, the order resulted in a trade. Empty if not
 market order.



