# Create Order

Allows your customer to create a buy or sell crypto order with Banxa. Upon success, the response will contain a checkout URL which will be unique for the order. The customer will  be redirected to this URL to complete the checkout process, which will expire after 1 minute if a redirect does not occur.

Endpoint: POST /api/orders
Version: 1.3
Security: sec0

## Security:

  - `sec0` (unknown)
    apiKey in header Authorization

## Header parameters:

  - `Accept` (string)

  - `X-Request-Id` (string)
    This is the correlation ID related to the request.

## Request fields (application/json):

  - `account_reference` (string, required)
    Unique customer reference provided by you. Used to check whether customer has completed KYC.

  - `payment_method_id` (integer)
    Payment method ID associated with the order.

  - `source` (string, required)
    Source currency or cryptocurrency code. This parameter indicates whether the order is a buy or a sell cryptocurrency order.

  - `source_amount` (string)
    Source amount

  - `target` (string, required)
    Target currency or cryptocurrency code. This parameter indicates whether the order is a buy or a sell cryptocurrency order.

  - `target_amount` (string)
    Target amount. This will be overridden if a `source_amount` is also passed.

  - `wallet_address` (string, required)
    Wallet address to receive cryptocurrency. Should be sent for buy cryptocurrency orders only.

  - `wallet_address_tag` (string, required)
    Wallet tag or memo associated with the wallet address. Should be sent for buy cryptocurrency orders only. This is required when the Customer's wallet address has a Memo or Tag such as BNB (Memo) and XRP (Tag).

  - `blockchain` (string)
    Blockchain network code. If not provided, the default blockchain configured for the cryptocurrency will be used. Refer to the [Get Crypto Currencies](ref:get-crypto-currencies) endpoint to retrieve a list of supported blockchain network codes.

  - `return_url_on_success` (string, required)
    Return URL when the customer has completed the checkout process.

  - `return_url_on_cancelled` (string)
    Return URL when the customer cancels the checkout process.

  - `return_url_on_failure` (string)
    Return URL when the customer fails to complete the checkout process.

  - `meta_data` (string)
    Free form string that you can use to send us any information that will be returned in the [Get Orders](ref:get-orders) endpoint

  - `refund_address` (string, required)
    Refund wallet address. Should be sent for sell cryptocurrency orders only. Used in the event in the event that a refund is necessary and the transferred coins need to be returned.

  - `refund_address_tag` (string)
    Refund wallet address tag or memo. Should be sent for sell cryptocurrency orders only. This is required when the Customer's wallet address has a Memo or Tag such as BNB (Memo) and XRP (Tag).

  - `source_address` (string)
    Source wallet address. Should be sent for sell cryptocurrency orders only.

  - `source_address_tag` (string)
    Source wallet address tag or memo. Should be sent for sell cryptocurrency orders only. Required when source wallet address for BNB (Memo) or XRP (Tag).

  - `email` (string)
    Customer's email address. This will pre-populate the customers' email address field when they are redirected to Banxa checkout

  - `mobile` (string)
    Customer's mobile number. This will pre-populate the customers' mobile number field when they are redirected to Banxa checkout

  - `discount_code` (string)
    (Beta) A code that can be passed to change your commission rate on this order. Please contact your account manager for code setup.

## Response 200:

  - `200` (unknown)
    200

## Response 200 fields (application/json):

  - `data` (object)

  - `data.order` (object)

  - `data.order.id` (string)
    Example: 0164d962448fbd34f644ffd65624d8ef

  - `data.order.account_id` (string)
    Example: 098f6bcd4621d373cade4e832627b4f6

  - `data.order.account_reference` (string)
    Example: 098f6bcd4621d373cade4e832627b4f6

  - `data.order.country` (string)
    Example: US

  - `data.order.order_type` (string)
    Example: CRYPTO-BUY

  - `data.order.fiat_code` (string)
    Example: AUD

  - `data.order.coin_code` (string)
    Example: BTC

  - `data.order.wallet_address` (string)
    Example: 39Mn6uYF1C1ZHbi5KgmyAjrTPX5RCWThbp

  - `data.order.blockchain` (object)

  - `data.order.blockchain.code` (string)
    Example: BTC

  - `data.order.blockchain.description` (string)
    Example: Bitcoin

  - `data.order.created_at` (string)
    Example: 16-May-2019 10:30:43

  - `data.order.checkout_url` (string)
    Example: https://[merchant].banxa.com/portal?expires=xxx&oid=xxx&signature=xxx

## Response 422:

  - `422` (unknown)
    422

## Response 422 fields (application/json):

  - `errors` (object)

  - `errors.status` (integer)
    Example: 422

  - `errors.code` (integer)
    Example: 422

  - `errors.title` (string)
    Example: An invalid wallet address was entered.

## Response 200 examples:

  - `OK` (unknown)

  - `With Promotion` (unknown)

## Response 422 examples:

  - `Invalid Wallet Address` (unknown)

  - `Invalid payment method ID` (unknown)

