> 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

## Search orders using a multitude of filters

> Use this endpoint to retrieve multiple orders depending on the filter parameters.

```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","description":"Use this endpoint to retrieve multiple orders depending on the filter parameters.","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":{}}}}}}}}
```

## Retrieve a customer's orders

> Returns a paginated list of the orders belonging to a customer, across all of that customer's subscriptions. Available in API 6.0 over REST, JSON-RPC (\`getCustomerOrders\`) and SOAP (\`getCustomerOrders\`).\
> \
> The customer can be identified by the internal 2Checkout customer ID (\`CustomerReference\`) or by the external customer ID set by the merchant (\`ExternalCustomerReference\`). At least one of the two is required. If both are provided, they must resolve to the same customer.\
> \
> Internally, 2Checkout:\
> 1\. Resolves the customer from the provided identifier(s).\
> 2\. Gathers all subscriptions belonging to that customer.\
> 3\. Collects the order history of each subscription.\
> 4\. Removes duplicate orders (a single purchase can create several subscriptions that reference the same order).\
> 5\. Sorts the result by order date, most recent first.\
> 6\. Returns the requested page.\
> \
> Each item in \`Items\` has the same shape as a single order returned by \`getOrder\`, and the \`Items\`/\`Pagination\` envelope is the same one used by \`searchOrders\`. If a dispute/chargeback exists for an order, the item additionally includes \`ChargebackReasonCode\` and \`ChargebackResolution\`.\
> \
> If the customer exists but has no subscriptions (and therefore no resolvable orders), an empty \`Items\` array is returned rather than an error.\
> \
> This method is available only for merchant accounts on which the \`API\_GET\_CUSTOMER\_ORDERS\` feature flag is enabled. When the flag is off, every call returns a \`FORBIDDEN\` error.<br>

```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":"Retrieve a customer's orders","description":"Returns a paginated list of the orders belonging to a customer, across all of that customer's subscriptions. Available in API 6.0 over REST, JSON-RPC (`getCustomerOrders`) and SOAP (`getCustomerOrders`).\n\nThe customer can be identified by the internal 2Checkout customer ID (`CustomerReference`) or by the external customer ID set by the merchant (`ExternalCustomerReference`). At least one of the two is required. If both are provided, they must resolve to the same customer.\n\nInternally, 2Checkout:\n1. Resolves the customer from the provided identifier(s).\n2. Gathers all subscriptions belonging to that customer.\n3. Collects the order history of each subscription.\n4. Removes duplicate orders (a single purchase can create several subscriptions that reference the same order).\n5. Sorts the result by order date, most recent first.\n6. Returns the requested page.\n\nEach item in `Items` has the same shape as a single order returned by `getOrder`, and the `Items`/`Pagination` envelope is the same one used by `searchOrders`. If a dispute/chargeback exists for an order, the item additionally includes `ChargebackReasonCode` and `ChargebackResolution`.\n\nIf the customer exists but has no subscriptions (and therefore no resolvable orders), an empty `Items` array is returned rather than an error.\n\nThis method is available only for merchant accounts on which the `API_GET_CUSTOMER_ORDERS` feature flag is enabled. When the flag is off, every call returns a `FORBIDDEN` error.\n","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":"The internal 2Checkout customer ID (IdCustomer). At least one of CustomerReference or ExternalCustomerReference must be provided.","required":false,"style":"form","explode":true,"schema":{"type":"integer"}},{"name":"ExternalCustomerReference","in":"query","description":"The external customer ID set by the merchant. At least one of CustomerReference or ExternalCustomerReference must be provided. If both identifiers are provided, they must resolve to the same customer.","required":false,"style":"form","explode":true,"schema":{"type":"string"}},{"name":"Page","in":"query","description":"Page number, 1-based. Default value is 1. Must be greater than or equal to 1.","required":false,"style":"form","explode":true,"schema":{"type":"integer","minimum":1,"default":1}},{"name":"Limit","in":"query","description":"Number of orders per page. Default value is 10. Must be between 1 and 200.","required":false,"style":"form","explode":true,"schema":{"type":"integer","minimum":1,"maximum":200,"default":10}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"Items":{"type":"array","description":"Orders of the customer, sorted by order date, latest first. Each item has the same shape as a single order returned by getOrder. If a dispute/chargeback exists for the order, the item also includes ChargebackReasonCode and ChargebackResolution.","items":{"type":"object","additionalProperties":true,"properties":{"ChargebackReasonCode":{"type":"string","description":"Reason code of the dispute/chargeback. Present only if a dispute/chargeback exists for the order."},"ChargebackResolution":{"type":"string","description":"Resolution of the dispute/chargeback. Present only if a dispute/chargeback exists for the order."}}}},"Pagination":{"type":"object","description":"Pagination object with the following parameters: Page — the requested page. Limit — the requested page size. Count — the total number of distinct orders of the customer, across all pages. The value is the same even if Page is past the last page of results.","properties":{"Page":{"type":"integer","description":"The requested page."},"Limit":{"type":"integer","description":"The requested page size."},"Count":{"type":"integer","description":"The customer's total number of distinct orders across all pages. The value is the same even when Page is past the last page of results."}}}}}}}},"400":{"description":"Bad request - validation error or missing required parameters","content":{"application/json":{"schema":{"type":"object","properties":{"error_code":{"type":"string","description":"Error code identifying the specific validation failure.","enum":["INVALID_CUSTOMER","PAGINATION_PAGE_PARAMETER_INVALID","PAGINATION_LIMIT_PARAMETER_INVALID"]},"message":{"type":"string","description":"Detailed error message."}}}}}},"403":{"description":"The getCustomerOrders feature is not enabled for the merchant account (API_GET_CUSTOMER_ORDERS feature flag is off)","content":{"application/json":{"schema":{"type":"object","properties":{"error_code":{"type":"string"},"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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
