# List orders

Retrieves a list of orders that either have the same reference ID or belong to the same guest. You must include either the referenceId of the order or the guestRef as a query string parameter in the URI of the request, but not both.

 In the response, items.ref contains the order reference. Use the order reference to interact with a specific order, for example, to retrieve it, update it, or create a data extension for it.

Endpoint: GET /v2.1/orders
Version: v2.1
Security: BasicAuth

## Query parameters:

  - `referenceId` (string)
    A unique identifier generated by your organization to reference the order. For flight orders, this is often the PNR. Specify either referenceId or guestRef in the query parameters, not both.
    Example: "B94TXY-1"

  - `guestRef` (string)
    The guest reference. This is a unique identifier of the guest record. If you don't know the guest reference, first retrieve guests using the Sitecore CDP Guest REST API. Specify either referenceId or guestRef in the query parameters, not both.

  - `offset` (object)
    Collection responses use offset pagination. The offset query parameter is used to exclude from a response the first N items of the entire resource collection.

  - `limit` (object)
    Collection responses use offset pagination. This query parameter lets you adjust the maximum number of collection items to return for a single request.
    Example: 40

  - `expand` (array)
    You can expand items in a collection by setting expand=true. This eliminates the need to send multiple follow-up requests (one for the collection and another for each of its items). This also helps you check if the data you intend to create already exists.
    Example: true

  - `sort` (string)
    You can sort search results by the date and time when the order was created (created) or made (orderedAt). You can only use orderedAt if you list orders using guestRef.

## Response 200 fields (application/json):

  - `offset` (integer)
    The request's offset.

  - `limit` (integer)
    The request's limit.
    Example: 10

  - `first` (object)
    The request's first list of orders URL.

  - `first.href` (string)
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/orders?guestRef=2d7de9df-45a2-45ea-872c-30e45139007d&offset=1&limit=10"

  - `last` (object)
    The request's last list of orders URL.

  - `last.href` (string)
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/orders?guestRef=2d7de9df-45a2-45ea-872c-30e45139007d&offset=1&limit=10"

  - `next` (object)
    The request's next list of orders URL.

  - `next.href` (string)
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/orders?guestRef=2d7de9df-45a2-45ea-872c-30e45139007d&offset=1&limit=10"

  - `href` (string)
    The request's URL.
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/orders?guestRef=cadd106a-feff-42b2-90fb-a6ed136ece51/contacts?offset=0&limit=10"

  - `items` (array)

  - `items.href` (string)
    Example: "https://api-engage-eu.sitecorecloud.io/v2.1/orders/cadd106a-feff-42b2-90fb-a6ed136ece51"

## Response 401 fields (application/json):

  - `status` (string)
    The HTTP request status.
    Example: "UNAUTHORIZED"

  - `code` (integer)
    The HTTP response status code.
    Example: 401

  - `message` (string)
    Error description.
    Example: "Authentication credentials are required to access the resource. All requests must be authenticated."

  - `moreInfoUrl` (string)
    URL to get more information about the error.
    Example: "https://support.sitecore.com"


