> For the complete documentation index, see [llms.txt](https://docs.2checkout.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.2checkout.com/api-reference/reference/order.md).

# Order

## GET /orders/

> Search orders using a multitude of filters

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/":{"get":{"tags":["Order"],"summary":"Search orders using a multitude of filters","parameters":[{"name":"ApproveStatus","in":"query","description":"Choose the desired status like WAITING, OK, FRAUD, INVALIDDATA","required":false,"style":"form","explode":true,"schema":{"type":"string","enum":["WAITING","OK","FRAUD","INVALIDDATA"]}},{"name":"Newer","in":"query","description":"Needed timestamp. If not provided, will return by default the data for last 7 days.","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"Status","in":"query","description":"Order status. Some of the available options are COMPLETE, PENDING, CANCELED, REFUND","required":false,"style":"form","explode":true,"schema":{"type":"string","enum":["COMPLETE","PENDING","CANCELED","REFUND"]}},{"name":"StartDate","in":"query","description":"Start date in format Y-m-d. Will overwrite Newer if provided.","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"EndDate","in":"query","description":"End date in format Y-m-d.","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"PartnerOrders","in":"query","description":"Decide if it will also include partner orders","required":false,"style":"form","explode":true,"schema":{"type":"boolean"}},{"name":"ExternalRefNo","in":"query","description":"The external reference number of the order","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"IncludeTestOrders","in":"query","description":"Should test orders be included in the result Values YES -  test orders are included NO - test orders are not included ONLY - only the test orders are included","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"Page","in":"query","description":"Needed page","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"Limit","in":"query","description":"Number of results per page","required":false,"style":"form","explode":true,"schema":{"type":"integer"}}],"responses":{"201":{"description":"Created","content":{"application/json":{}}}}}}}}
```

## List a customer's orders

> Returns the list of orders belonging to a given customer, across all of that customer's subscriptions.\
> \
> A customer can be identified either by their internal 2Checkout customer ID (\`CustomerReference\`) or by the external customer ID you assigned to them (\`ExternalCustomerReference\`) - at least one of the two is required. If both are provided, they must resolve to the same customer.\
> \
> Internally, 2Checkout resolves the customer, gathers all of their subscriptions, collects the order history for each subscription, removes duplicate orders (a single purchase can spawn several subscriptions that all reference the same order), sorts the de-duplicated result by order date (most recent first), and returns it paginated.\
> \
> Each item in the response has the exact same shape as a single order returned by \`GET /orders/{OrderReference}/\`. If a dispute/chargeback exists for an order, that item additionally includes \`ChargebackReasonCode\` and \`ChargebackResolution\`.\
> \
> Gated by the \`API\_GET\_CUSTOMER\_ORDERS\` feature flag - calls return a \`FORBIDDEN\` error for merchant accounts where the flag is not enabled.

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/customer/":{"get":{"tags":["Order"],"summary":"List a customer's orders","description":"Returns the list of orders belonging to a given customer, across all of that customer's subscriptions.\n\nA customer can be identified either by their internal 2Checkout customer ID (`CustomerReference`) or by the external customer ID you assigned to them (`ExternalCustomerReference`) - at least one of the two is required. If both are provided, they must resolve to the same customer.\n\nInternally, 2Checkout resolves the customer, gathers all of their subscriptions, collects the order history for each subscription, removes duplicate orders (a single purchase can spawn several subscriptions that all reference the same order), sorts the de-duplicated result by order date (most recent first), and returns it paginated.\n\nEach item in the response has the exact same shape as a single order returned by `GET /orders/{OrderReference}/`. If a dispute/chargeback exists for an order, that item additionally includes `ChargebackReasonCode` and `ChargebackResolution`.\n\nGated by the `API_GET_CUSTOMER_ORDERS` feature flag - calls return a `FORBIDDEN` error for merchant accounts where the flag is not enabled.","parameters":[{"name":"Accept","in":"header","required":true,"style":"simple","explode":false,"schema":{"type":"string","default":"application/json","enum":["application/json"]}},{"name":"X-Avangate-Authentication","in":"header","description":"Authentication header","required":true,"style":"simple","explode":false,"schema":{"type":"string"}},{"name":"CustomerReference","in":"query","description":"Internal 2Checkout customer reference (IdCustomer). One of CustomerReference or ExternalCustomerReference is required.","required":false,"style":"form","explode":true,"schema":{"type":"integer"}},{"name":"ExternalCustomerReference","in":"query","description":"Merchant's own external customer identifier. One of CustomerReference or ExternalCustomerReference is required.","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"Page","in":"query","description":"Page number for pagination. Must be >= 1. Default value is 1.","required":false,"style":"form","explode":true,"schema":{"type":"integer","minimum":1,"default":1}},{"name":"Limit","in":"query","description":"Number of orders per page. Must be between 1 and 200. Default value is 10.","required":false,"style":"form","explode":true,"schema":{"type":"integer","minimum":1,"maximum":200,"default":10}}],"responses":{"200":{"description":"OK","content":{"application/json":{}}},"400":{"description":"Bad request - validation error or missing/invalid customer identifier","content":{"application/json":{"schema":{"type":"object","properties":{"error_code":{"type":"string","enum":["INVALID_CUSTOMER","PAGINATION_PAGE_PARAMETER_INVALID","PAGINATION_LIMIT_PARAMETER_INVALID"]},"message":{"type":"string"}}}}}},"403":{"description":"Forbidden - feature flag not enabled for this merchant account","content":{"application/json":{"schema":{"type":"object","properties":{"error_code":{"type":"string","enum":["FORBIDDEN"]},"message":{"type":"string"}}}}}}}}}}}
```

## GET /orders/0/sale/

> Get order reference by sale id

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/0/sale/":{"get":{"tags":["Order"],"summary":"Get order reference by sale id","parameters":[{"in":"query","name":"SaleId","description":"Unique code that identifies a sale","required":true,"schema":{"type":"integer"}}],"responses":{"200":{"description":"Get order reference by sale id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderReference"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderReferenceSaleBadRequest"}}}}}}}},"components":{"schemas":{"OrderReference":{"type":"string"},"OrderReferenceSaleBadRequest":{"type":"object","properties":{"error_code":{"type":"string"},"message":{"type":"string"}}}}}}
```

## GET /orders/0/invoice/

> Get order reference by invoice id

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/0/invoice/":{"get":{"tags":["Order"],"summary":"Get order reference by invoice id","parameters":[{"name":"Accept","in":"header","required":true,"style":"simple","explode":false,"schema":{"type":"string","default":"application/json","enum":["application/json"]}},{"name":"X-Avangate-Authentication","in":"header","description":"Authentication header","required":true,"style":"simple","explode":false,"schema":{"type":"string"}},{"name":"InvoiceId","in":"query","description":"Unique code that identifies an invoice","required":true,"style":"form","explode":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Get order reference by invoice id","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderReference"}}}},"400":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderReferenceInvoiceBadRequest"}}}}}}}},"components":{"schemas":{"OrderReference":{"type":"string"},"OrderReferenceInvoiceBadRequest":{"type":"object","properties":{"error_code":{"type":"string"},"message":{"type":"string"}}}}}}
```

## GET /orders/{OrderReference}/

> Retrieve an order by reference

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/{OrderReference}/":{"get":{"tags":["Order"],"summary":"Retrieve an order by reference","parameters":[{"name":"Accept","in":"header","required":true,"style":"simple","explode":false,"schema":{"type":"string","default":"application/json","enum":["application/json"]}},{"name":"X-Avangate-Authentication","in":"header","description":"Authentication header","required":true,"style":"simple","explode":false,"schema":{"type":"string"}},{"name":"OrderReference","in":"path","description":"Reference number for approved/paid orders.","required":true,"style":"simple","explode":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{}}}}}}}}
```

## Cancel a purchase order

> Cancel order with purchase order type

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/{OrderReference}/":{"delete":{"tags":["Order"],"summary":"Cancel a purchase order","description":"Cancel order with purchase order type","parameters":[{"name":"Accept","in":"header","required":true,"style":"simple","explode":false,"schema":{"type":"string","default":"application/json","enum":["application/json"]}},{"name":"X-Avangate-Authentication","in":"header","description":"Authentication header","required":true,"style":"simple","explode":false,"schema":{"type":"string"}},{"name":"OrderReference","in":"path","description":"Reference number for purchase order type orders.","required":true,"style":"simple","explode":false,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"application/json":{}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/inline_response_400"}}}},"404":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/inline_response_404"}}}}}}}},"components":{"schemas":{"inline_response_400":{"type":"object","properties":{"error_code":{"type":"string"},"message":{"type":"string"}}},"inline_response_404":{"type":"object","properties":{"error_code":{"type":"string"},"message":{"type":"string"}}}}}}
```

## POST /orders/{OrderReference}/upload

> Order form upload

```json
{"openapi":"3.0.0","info":{"title":"API REST Documentation","version":"6.0-oas3"},"servers":[{"url":"https://api.2checkout.com/rest/6.0"}],"paths":{"/orders/{OrderReference}/upload":{"post":{"tags":["Order"],"summary":"Order form upload","parameters":[{"name":"X-Avangate-Authentication","in":"header","description":"Authentication header","required":true,"style":"simple","explode":false,"schema":{"type":"string"}},{"name":"Accept","in":"header","required":true,"style":"simple","explode":false,"schema":{"type":"string","enum":["application/json"]}},{"name":"OrderReference","in":"path","description":"Unique, system-generated order identifier.","required":true,"style":"simple","explode":false,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ordersUpload"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{}}},"400":{"description":"Invalid data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/inline_response_400"}}}}}}}},"components":{"schemas":{"ordersUpload":{"type":"object","properties":{"FileName":{"type":"string"},"ClientTime":{"type":"string"},"File":{"type":"string"}}},"inline_response_400":{"type":"object","properties":{"error_code":{"type":"string"},"message":{"type":"string"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.2checkout.com/api-reference/reference/order.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
