# Create an order

`POST /sigmafi/orders` · Lithos client API · SigmaFi Bonds · requires the `api_key` header

Source: https://lithosprotocol.org/docs/api/create-sf-order

Lock collateral in an order asking to borrow ERG or one token, repaid by a fixed height or a number of blocks after a lender fills it. Do not send `batchingFee` on creation: the lender chooses and funds the reserve when filling. Cancel it with `POST /sigmafi/orders/{boxId}/cancel` while it is unfilled.

## Request body

`SFOrderRequest`, application/json.

- `collateralNanoErgs` (string, required)
- `collateralTokens` (SFTokenAmount[])
  - `tokenId` (string, required)
  - `amount` (string, required): Base units.
- `principalNanoErgs` (string)
- `principalToken` (SFTokenAmount)
- `repayment` (string, required)
- `maturityHeight` (integer · int64): At least 3 blocks above the current height.
- `durationBlocks` (integer · int64)
- `batchingFee` (string): Rejected on order creation. The lender selects this reserve in SFFillRequest instead.
- `liquidation` (string)

## Responses

### 200: The transaction was sent; `outcome` says whether the node accepted it.

`SFResult`

- `txId` (string, required)
- `outcome` (string, required, one of accepted, rejected, uncertain)
- `boxId` (string): The output that matters: the new order or bond, the vault box a repayment or liquidation pays, or the first box a cancel or claim returns to this wallet.
- `assetId` (string): The bond asset a fill minted.
- `warnings` (string[]): What to know about the sent transaction: vault boxes a claim left locked for good, or a repayment sent with two blocks or fewer left to be mined in.

### 400: A malformed field, or terms no contract or shipped client accepts.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### 403: Missing or wrong api_key.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### 422: Valid, but not possible now: the box's terms are refused, maturity has passed or not come, the wallet cannot cover it, or no wallet box can authorize a cancel.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

### 503: Node, wallet or transaction engine unavailable, or the request ran out of time. The message says whether anything was sent. When it says the outcome is unknown, check `GET /sigmafi/portfolio` before retrying.

`ApiError`

- `error` (integer, required): Error code
- `reason` (string, required): Error message explaining the reason of the error
- `detail` (string, required): Detailed error description

## Example request

```bash
curl -X POST "http://localhost:9000/sigmafi/orders" \
  -H "api_key: $LITHOS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "collateralNanoErgs": "string", "collateralTokens": [ { "tokenId": "string", "amount": "string" } ], "principalNanoErgs": "string", "principalToken": { "tokenId": "string", "amount": "string" }, "repayment": "string", "maturityHeight": 0, "durationBlocks": 30, "batchingFee": "string", "liquidation": "MaturityLiquidation" }'
```

## Example response

```json
{
  "txId": "string",
  "outcome": "accepted",
  "boxId": "string",
  "assetId": "string",
  "warnings": [
    "string"
  ]
}
```
