# Get Transaction by ID

GET https://services.leadconnectorhq.com/payments/transactions/{transactionId}

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

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `transactionId` | string | Yes | ID of the transaction 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. |
| `altType` | string | Yes | AltType is the type of identifier. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/payments/transactions/{transactionId}": {
      "get": {
        "summary": "Get Transaction by ID",
        "operationId": "getTransactionById",
        "description": "The \"Get Transaction by ID\" API allows to retrieve information for a specific transaction using its unique identifier. Use this endpoint to fetch details for a single transaction based on the provided transaction ID.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "transactionId",
            "required": true,
            "in": "path",
            "description": "ID of the transaction that needs to be returned",
            "schema": {
              "example": "61dd0feac077f72010f78804",
              "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"
            }
          },
          {
            "name": "altType",
            "required": true,
            "in": "query",
            "description": "AltType is the type of identifier.",
            "schema": {
              "example": "location",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetTxnResponseSchema"
                }
              }
            }
          },
          "400": {
            "description": "Transaction 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/transactions.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": {
      "GetTxnResponseSchema": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "The unique identifier for the transaction.",
            "example": "61dd0feac077f72010f78804"
          },
          "altType": {
            "type": "string",
            "example": "location",
            "description": "AltType is the type of identifier."
          },
          "altId": {
            "type": "string",
            "description": "AltId is the unique identifier eg: location id.",
            "example": "3SwdhCu3svxI8AKsPJt6"
          },
          "contactId": {
            "type": "string",
            "example": "XPLSw2SVagl12LMDeTmQ",
            "description": "Contact id corresponding to the transaction."
          },
          "contactSnapshot": {
            "type": "object",
            "description": "Contact details of the transaction.",
            "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\"}"
          },
          "currency": {
            "type": "string",
            "example": "USD",
            "description": "Currency in which transaction was made."
          },
          "amount": {
            "type": "number",
            "example": "100",
            "description": "Transaction value."
          },
          "status": {
            "type": "object",
            "example": "succeeded",
            "description": "Transaction status."
          },
          "liveMode": {
            "type": "boolean",
            "example": "false",
            "description": "Transaction is in live / test mode."
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "The creation timestamp of the transaction.",
            "example": "2023-11-20T10:23:36.515Z"
          },
          "updatedAt": {
            "format": "date-time",
            "type": "string",
            "description": "The last update timestamp of the transaction.",
            "example": "2024-01-23T09:57:04.846Z"
          },
          "entityType": {
            "type": "string",
            "example": "order",
            "description": "Entity type of transaction (eg: order)."
          },
          "entityId": {
            "type": "string",
            "example": "61dd0fe9c077f73e67f78803",
            "description": "Entity id for the transaction. e.g: order id"
          },
          "entitySource": {
            "description": "Entity source details for the transaction.",
            "example": "{ type: \"funnel\", id: \"BDBMEghdIUaqMPEsK349\", subType: \"two_step_order_form\", name: \"new funnel\" }",
            "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"
              }
            ]
          },
          "chargeId": {
            "type": "string",
            "example": "in_1KGcXDCScnf89tZohCsmImwE",
            "description": "Charge id for transaction."
          },
          "chargeSnapshot": {
            "type": "object",
            "description": "Charge snapshot of transaction.",
            "example": "{ id: \"in_1KGcXDCScnf89tZohCsmImwE\", object: \"invoice\", account_country: \"US\",  account_name:  \"GHL-Testing\" }"
          },
          "invoiceId": {
            "type": "string",
            "example": "in_1KGcXDCScnf89tZohCsmImwE",
            "description": "Invoice id for the transaction."
          },
          "subscriptionId": {
            "type": "string",
            "example": "sub_1KGcXDCScnf89tZoVkoEMCEL",
            "description": "Subscription id for transaction."
          },
          "paymentProvider": {
            "type": "object",
            "description": "Payment provider details of the transaction.",
            "example": "{ type: \"stripe\", connectedAccount: { _id: \"612ca676b484b241fef9d962\", accountId: \"acct_1Ihw53CScnf89tZo\" } }"
          },
          "ipAddress": {
            "type": "string",
            "example": "107.178.194.224",
            "description": "Ip address from where transaction was initiated."
          },
          "meta": {
            "type": "object",
            "description": "Meta details of the transaction.",
            "example": "{ stepId: \"af7c731e-e36f-4152-bd1a-3f69a31d6d6d\", pageId: \"A8ltotc2jZxurJba4e3Y\", pageUrl: \"/v2/preview/A8ltotc2jZxurJba4e3Y\" }"
          },
          "markAsTest": {
            "type": "boolean",
            "description": "Is test transaction.",
            "example": "false"
          },
          "isParent": {
            "type": "boolean",
            "description": "Is parent transaction.",
            "example": "false"
          },
          "amountRefunded": {
            "type": "number",
            "example": "10",
            "description": "Transaction amount refunded."
          },
          "receiptId": {
            "type": "string",
            "example": "6492fbea489bc07892c6defb",
            "description": "Receipt id for transaction."
          },
          "qboSynced": {
            "type": "boolean",
            "description": "Is transaction qbo synced.",
            "example": "false"
          },
          "qboResponse": {
            "type": "object",
            "description": "Qbo details of the transaction.",
            "example": "{ domain: \"QBO\", sparse: false, Id: \"180\", SyncToken: \"0\", TotalAmt: 25 }"
          },
          "traceId": {
            "type": "string",
            "description": "Trace id of the transaction.",
            "example": "d3b16a92-a8ed-4e6b-8467-844750f78ed5"
          },
          "mergedFromContactId": {
            "type": "string",
            "example": "XPLSw2SVagl12LMDeTmQ",
            "description": "ID of the contact that was merged from."
          },
          "createdBy": {
            "type": "string",
            "example": "user123",
            "description": "User ID who created the transaction."
          }
        },
        "required": [
          "_id",
          "altType",
          "altId",
          "createdAt",
          "updatedAt"
        ],
        "title": "GetTxnResponseSchema"
      },
      "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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>' \
  -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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/payments/transactions/{transactionId}"

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

params = {
    "altId": "<ALTID>",
    "altType": "<ALTTYPE>"
}

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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>',
  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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>")
  .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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>"
  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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>")

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/transactions/<transactionId>?altId=<ALTID>&altType=<ALTTYPE>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
