# List Orders

GET https://services.leadconnectorhq.com/payments/orders

The "List Orders" API allows to retrieve a paginated list of orders. Customize your results by filtering orders based on name, alt type, order status, payment mode, date range, type of source, contact, funnel products or paginate through the list using the provided query parameters. This endpoint provides a straightforward way to explore and retrieve order information.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `payments/orders.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | No | LocationId is the id of the sub-account. |
| `altId` | string | Yes | AltId is the unique identifier e.g: location id. |
| `status` | string | No | Order status. |
| `paymentStatus` | string | No | Payment Status of the Order |
| `paymentMode` | string | No | Mode of payment. |
| `startAt` | string | No | Starting interval of orders. |
| `endAt` | string | No | Closing interval of orders. |
| `search` | string | No | The name of the order for searching. |
| `contactId` | string | No | Contact id for filtering of orders. |
| `funnelProductIds` | string | No | Funnel product ids separated by comma. |
| `sourceId` | string | No | Source id |
| `limit` | number | No | The maximum number of items to be included in a single page of results |
| `offset` | number | No | The starting index of the page, indicating the position from which the results should be retrieved. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/payments/orders": {
      "get": {
        "summary": "List Orders",
        "operationId": "listOrders",
        "description": "The \"List Orders\" API allows to retrieve a paginated list of orders. Customize your results by filtering orders based on name, alt type, order status, payment mode, date range, type of source, contact, funnel products or paginate through the list using the provided query parameters. This endpoint provides a straightforward way to explore and retrieve order information.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "locationId",
            "required": false,
            "in": "query",
            "description": "LocationId is the id of the sub-account.",
            "schema": {
              "example": "3SwdhCu3svxI8AKsPJt6",
              "type": "string"
            }
          },
          {
            "name": "altId",
            "required": true,
            "in": "query",
            "description": "AltId is the unique identifier e.g: location id.",
            "schema": {
              "example": "3SwdhCu3svxI8AKsPJt6",
              "type": "string"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Order status.",
            "schema": {
              "example": "completed",
              "type": "string"
            }
          },
          {
            "name": "paymentStatus",
            "required": false,
            "in": "query",
            "description": "Payment Status of the Order",
            "schema": {
              "example": "unpaid",
              "enum": [
                "paid",
                "unpaid",
                "refunded",
                "partially_paid"
              ],
              "type": "string"
            }
          },
          {
            "name": "paymentMode",
            "required": false,
            "in": "query",
            "description": "Mode of payment.",
            "schema": {
              "example": "live",
              "type": "string"
            }
          },
          {
            "name": "startAt",
            "required": false,
            "in": "query",
            "description": "Starting interval of orders.",
            "schema": {
              "example": "2024-02-01",
              "type": "string"
            }
          },
          {
            "name": "endAt",
            "required": false,
            "in": "query",
            "description": "Closing interval of orders.",
            "schema": {
              "example": "2024-02-13",
              "type": "string"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "The name of the order for searching.",
            "schema": {
              "example": "Awesome order",
              "type": "string"
            }
          },
          {
            "name": "contactId",
            "required": false,
            "in": "query",
            "description": "Contact id for filtering of orders.",
            "schema": {
              "example": "XPLSw2SVagl12LMDeTmQ",
              "type": "string"
            }
          },
          {
            "name": "funnelProductIds",
            "required": false,
            "in": "query",
            "description": "Funnel product ids separated by comma.",
            "schema": {
              "example": "61dd0c7dc077f712a5f787ff,61d6afc9d39ac5e35965c017",
              "type": "string"
            }
          },
          {
            "name": "sourceId",
            "required": false,
            "in": "query",
            "description": "Source id",
            "schema": {
              "example": "61dd0c7dc077f712a5f787ff",
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "The maximum number of items to be included in a single page of results",
            "schema": {
              "default": 10,
              "example": 20,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "The starting index of the page, indicating the position from which the results should be retrieved.",
            "schema": {
              "default": 0,
              "example": 0,
              "type": "number"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListOrdersResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "payments/orders.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "ListOrdersResponseDto": {
        "type": "object",
        "properties": {
          "data": {
            "description": "An array of orders",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_id": {
                  "type": "string",
                  "description": "The unique identifier for the order.",
                  "example": "653f5e0cde5a1314e62a837c"
                },
                "altId": {
                  "type": "string",
                  "description": "AltId is the unique identifier eg: location id.",
                  "example": "3SwdhCu3svxI8AKsPJt6"
                },
                "altType": {
                  "type": "string",
                  "example": "location",
                  "description": "AltType is the type of identifier."
                },
                "contactId": {
                  "type": "string",
                  "example": "XPLSw2SVagl12LMDeTmQ",
                  "description": "Contact id corresponding to the order."
                },
                "contactName": {
                  "type": "string",
                  "example": "James Bond",
                  "description": "Contact name corresponding to the order."
                },
                "contactEmail": {
                  "type": "string",
                  "example": "james.bond@gohighlevel.com",
                  "description": "Contact email corresponding to the order."
                },
                "currency": {
                  "type": "string",
                  "example": "USD",
                  "description": "Currency in which order was created."
                },
                "amount": {
                  "type": "number",
                  "example": "100",
                  "description": "Order value."
                },
                "subtotal": {
                  "type": "number",
                  "example": "100",
                  "description": "Order sub-total value."
                },
                "discount": {
                  "type": "number",
                  "example": "10",
                  "description": "Discount value on order."
                },
                "status": {
                  "type": "string",
                  "description": "The status of the order (e.g., completed).",
                  "example": "completed"
                },
                "liveMode": {
                  "type": "boolean",
                  "example": "false",
                  "description": "Order is in live / test mode."
                },
                "totalProducts": {
                  "type": "number",
                  "example": "5",
                  "description": "Total products in an order."
                },
                "sourceType": {
                  "type": "string",
                  "example": "funnel",
                  "description": "Source type of order (eg: funnel)."
                },
                "sourceName": {
                  "type": "string",
                  "example": "onestep",
                  "description": "Source name for the order."
                },
                "sourceId": {
                  "type": "string",
                  "description": "Source id for the order.",
                  "example": "kDj7BHej9Zyyq3QakJmz"
                },
                "sourceMeta": {
                  "type": "object",
                  "description": "Meta content for the source of order.",
                  "example": "{ domain: \"app.gohighlevel.com\", pageId:  \"rBVhyYhMsbxbO8ZqOcei\", pageUrl:  \"/v2/preview/rBVhyYhMsbxbO8ZqOcei\", stepId:   \"5a772f62-3fbc-418b-af1b-be8929dd64c2\"}"
                },
                "couponCode": {
                  "type": "string",
                  "description": "Coupon code for the order.",
                  "example": "100PER"
                },
                "createdAt": {
                  "format": "date-time",
                  "type": "string",
                  "description": "The creation timestamp of the order.",
                  "example": "2023-11-20T10:23:36.515Z"
                },
                "updatedAt": {
                  "format": "date-time",
                  "type": "string",
                  "description": "The last update timestamp of the order.",
                  "example": "2024-01-23T09:57:04.846Z"
                },
                "sourceSubType": {
                  "type": "string",
                  "description": "Source sub-type for the order.",
                  "example": "one_step_order_form"
                },
                "fulfillmentStatus": {
                  "type": "string",
                  "description": "Fulfillment status of the order.",
                  "example": "unfulfilled"
                },
                "onetimeProducts": {
                  "type": "number",
                  "example": "1",
                  "description": "Total one time products in an order."
                },
                "recurringProducts": {
                  "type": "number",
                  "example": "1",
                  "description": "Total recurring time products in an order."
                },
                "createdBy": {
                  "type": "string",
                  "example": "user123",
                  "description": "User ID who created the order."
                }
              },
              "required": [
                "_id",
                "altId",
                "altType",
                "status",
                "sourceType",
                "createdAt",
                "updatedAt"
              ],
              "title": "OrderResponseSchema"
            }
          },
          "totalCount": {
            "type": "number",
            "description": "total orders count"
          }
        },
        "required": [
          "data",
          "totalCount"
        ],
        "title": "ListOrdersResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/payments/orders"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

params = {
    "altId": "<ALTID>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/payments/orders?altId=<ALTID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
