For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HomeGuidesAPI Reference
HomeGuidesAPI Reference
  • Online API
    • API Environments
    • Direct Payment Flow
    • REST
    • HTTPS
    • Dates
    • Pagination
    • Authentication
    • Idempotent Requests
    • Timeouts
    • API Simulator
  • Models
    • Introduction
    • Contact Object
    • Consumer Object
    • Discount Object
    • Item Object
    • Money Object
    • Order Details Object
    • Payment Object
    • Refund Object
    • Shipping Courier Object
  • Service Status
    • GETPing
  • Configuration
    • GETGet Configuration
  • Orders
    • Introduction
    • GETGet Order
    • POSTCreate Order
  • Javascript afterpay.js
    • Information
    • Redirect Method
  • Payments
    • Introduction
    • POSTCapture Payment
    • PUTUpdate Shipping Courier
    • GETGet Payment By Order ID
    • GETGet Payment By Token
    • GETList Payment(s)
    • POSTCreate Refund
    • PUTUpdate Payment by Order ID
    • POSTReverse Payment By Token
  • Errors
    • Introduction
    • Get Errors
    • Put/Post Errors
  • Reference
LogoLogo
Orders

Create Order

POST
https://global-api-sandbox.afterpay.com/v1/orders/environment::environment
POST
/v1/orders/environment::environment
$curl -X POST https://global-api-sandbox.afterpay.com/v1/orders/environment:environment \
> -H "User-Agent: User-Agent" \
> -H "Content-Type: application/json" \
> -u "<username>:<password>" \
> -d '{
> "totalAmount": {
> "amount": "0.00",
> "currency": "string"
> },
> "consumer": {
> "givenNames": "Joe",
> "surname": "Consumer",
> "email": "test@example.com"
> }
>}'
1{}
This endpoint creates an order that is used to initiate the Afterpay payment process. Afterpay uses the information in the order request to assist with the consumer’s pre-approval process. **Warning**: The API Simulator includes form elements for both required and optional Body Params. If not populated with values, Readme will send empty strings to the Afterpay Online API. Any optional parameter that is validated against a Model will need to have all of its required sub-params populated with non-empty values. Therefore, to avoid receiving unexpected "400" responses from Afterpay, please fill out all fields of the simulation form with valid values. This is particularly important for the `amount` and `currency` sub-params of the `totalAmount`, `taxAmount` and `shippingAmount` params. **Note**: It is not possible to update the order information (including `totalAmount`) after the order token is generated. If the consumer's cart changes on the merchant side after a token is generated, please discard this token. Use the current order information to generate a new order token. Use the new token to send the consumer through the Afterpay screenflow before attempting to Capture Payment. ### Connection Timeouts | Timeout | Time (Seconds) | | ------- | ------------ | | Open | 10 | | Read | 20 |
Was this page helpful?
Previous

Information

Next
Built with

This endpoint creates an order that is used to initiate the Afterpay payment process. Afterpay uses the information in the order request to assist with the consumer’s pre-approval process.

Warning: The API Simulator includes form elements for both required and optional Body Params. If not populated with values, Readme will send empty strings to the Afterpay Online API. Any optional parameter that is validated against a Model will need to have all of its required sub-params populated with non-empty values. Therefore, to avoid receiving unexpected “400” responses from Afterpay, please fill out all fields of the simulation form with valid values. This is particularly important for the amount and currency sub-params of the totalAmount, taxAmount and shippingAmount params.

Note: It is not possible to update the order information (including totalAmount) after the order token is generated. If the consumer’s cart changes on the merchant side after a token is generated, please discard this token. Use the current order information to generate a new order token. Use the new token to send the consumer through the Afterpay screenflow before attempting to Capture Payment.

Connection Timeouts

TimeoutTime (Seconds)
Open10
Read20

Authentication

AuthorizationBasic

Basic authentication of the form Basic <base64(username:password)>.

Path parameters

environmentstringRequired

Use api-sandbox for AU/NZ, or api.us-sandbox for US.

Headers

User-AgentstringRequired
AcceptstringOptionalDefaults to application/json

Request

This endpoint expects an object.
totalAmountobjectRequired
Total amount for order to be charged to consumer.
consumerobjectRequired
The consumer requesting the order.
billingobjectOptional
Billing address.
shippingobjectOptional
Shipping address.
courierobjectOptional
Shipping Courier details.
descriptionstringOptional
A description of the order.
itemslist of objectsOptional
An array of order items.
discountslist of objectsOptional
An array of discounts.
merchantobjectOptional
merchantReferencestringOptional

The merchant’s id/reference that this order corresponds to.

taxAmountobjectOptional
The included tax amount after applying all discounts.
shippingAmountobjectOptional
The shipping amount.

Response

Returns a token and expiry date/time if successful. | Attribute | Type | Description | | --------- | ---- | ----------- | | expires | string | The UTC timestamp of when the order token will expire, in [ISO 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format. | | token | string | Order token to be used to complete payment. |

Errors

422
Unprocessable Entity Error

Returns a token and expiry date/time if successful.

AttributeTypeDescription
expiresstringThe UTC timestamp of when the order token will expire, in ISO 8601 format.
tokenstringOrder token to be used to complete payment.