# Get Order by ID

GET https://services.leadconnectorhq.com/payments/orders/{orderId}

The "Get Order by ID" API allows to retrieve information for a specific order using its unique identifier. Use this endpoint to fetch details for a single order based on the provided order ID.

## 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 |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `orderId` | string | Yes | ID of the order that needs to be returned |

### 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. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/payments/orders/{orderId}": {
      "get": {
        "summary": "Get Order by ID",
        "operationId": "getOrderById",
        "description": "The \"Get Order by ID\" API allows to retrieve information for a specific order using its unique identifier. Use this endpoint to fetch details for a single order based on the provided order ID.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "orderId",
            "required": true,
            "in": "path",
            "description": "ID of the order that needs to be returned",
            "schema": {
              "example": "653f5e0cde5a1314e62a837c",
              "type": "string"
            }
          },
          {
            "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"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetOrderResponseSchema"
                }
              }
            }
          },
          "400": {
            "description": "Order not found",
            "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": {
      "GetOrderResponseSchema": {
        "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."
          },
          "currency": {
            "type": "string",
            "example": "USD",
            "description": "Currency in which order was created."
          },
          "amount": {
            "type": "number",
            "example": "100",
            "description": "Order value."
          },
          "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."
          },
          "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"
          },
          "fulfillmentStatus": {
            "type": "string",
            "description": "Fulfillment status of the order.",
            "example": "unfulfilled"
          },
          "contactSnapshot": {
            "type": "object",
            "description": "Contact details of the order.",
            "example": "{ last_name: \"Mcclain\", type: \"lead\", first_name_lower_case: \"rogan\", email: \"anish+11@gohighlevel.com\", last_name_lower_case: \"mcclain\", location_id: \"o6241QsiRwUIJHyjuhos\", company_name: \"Jordan and Cox Trading\"}"
          },
          "amountSummary": {
            "description": "Amount details of the order.",
            "example": "{ subtotal: 100, discount: 5 }",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "subtotal": {
                    "type": "number",
                    "example": "100",
                    "description": "Order sub-total value."
                  },
                  "discount": {
                    "type": "number",
                    "example": "10",
                    "description": "Discount value on order."
                  }
                },
                "required": [
                  "subtotal"
                ],
                "title": "AmountSummary"
              }
            ]
          },
          "source": {
            "description": "Source details of the order.",
            "example": "{ type: \"invoice\", id: \"61dd48ff65b013bc39bb09c6\" }",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "funnel",
                      "website",
                      "invoice",
                      "calendar",
                      "text2Pay",
                      "document_contracts",
                      "membership",
                      "mobile_app",
                      "communities",
                      "point_of_sale",
                      "manual",
                      "form",
                      "survey",
                      "payment_link",
                      "external"
                    ]
                  },
                  "subType": {
                    "type": "string",
                    "enum": [
                      "one_step_order_form",
                      "two_step_order_form",
                      "upsell",
                      "tap_to_pay",
                      "card_payment",
                      "store",
                      "contact_view",
                      "email_campaign",
                      "payments_dashboard",
                      "shopify",
                      "subscription_view",
                      "store_upsell",
                      "woocommerce",
                      "service",
                      "meeting",
                      "imported_csv",
                      "qr_code",
                      "saas_one_time",
                      "saas_subscription"
                    ]
                  },
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "meta": {
                    "type": "object"
                  }
                },
                "required": [
                  "type",
                  "id"
                ],
                "title": "OrderSource"
              }
            ]
          },
          "items": {
            "description": "Item details of the order.",
            "example": "{ _id: 61dd33e88058b9f967ca79dc, authorizeAmount: 0, locationId: \"SBAWb4yu7A4LSc0skQ6g\", name: \"Sample Product\": price: {}, product: { name: \"Testing product\", productType: \"SERVICE\" }}",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "coupon": {
            "type": "object",
            "description": "Coupon details of the order.",
            "example": "{ code: \"FEST10\", _id: \"63455e48901b43d4ef364a20\" }"
          },
          "trackingId": {
            "type": "string",
            "description": "Tracking id of the order.",
            "example": "63319ef9-de0a-4c84-aebd-3585fb4a0cdf"
          },
          "fingerprint": {
            "type": "string",
            "description": "Fingerprint id of the order.",
            "example": "5d51db5a-42b0-4b04-ba88-2c046c982a3a"
          },
          "meta": {
            "type": "object",
            "description": "Meta details of the order.",
            "example": "{ couponSessionExpired: true }"
          },
          "markAsTest": {
            "type": "boolean",
            "description": "Is test order.",
            "example": "false"
          },
          "traceId": {
            "type": "string",
            "description": "Trace id of the order.",
            "example": "d3b16a92-a8ed-4e6b-8467-844750f78ed5"
          },
          "automaticTaxesCalculated": {
            "type": "boolean",
            "description": "Automatic taxes applied for the Order",
            "example": true
          },
          "taxCalculationProvider": {
            "type": "object",
            "description": "Provider name for automatic tax calculation",
            "example": "taxjar"
          },
          "createdBy": {
            "type": "string",
            "example": "user123",
            "description": "User ID who created the order."
          }
        },
        "required": [
          "_id",
          "altId",
          "altType",
          "status",
          "createdAt",
          "updatedAt"
        ],
        "title": "GetOrderResponseSchema"
      },
      "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/<orderId>?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/<orderId>?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/{orderId}"

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/<orderId>?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/<orderId>?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/<orderId>?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/<orderId>?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/<orderId>?altId=<ALTID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
