# Get Subscription by ID

GET https://services.leadconnectorhq.com/payments/subscriptions/{subscriptionId}

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

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

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

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `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/subscriptions/{subscriptionId}": {
      "get": {
        "summary": "Get Subscription by ID",
        "operationId": "getSubscriptionById",
        "description": "The \"Get Subscription by ID\" API allows to retrieve information for a specific subscription using its unique identifier. Use this endpoint to fetch details for a single subscription based on the provided subscription ID.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "subscriptionId",
            "required": true,
            "in": "path",
            "description": "ID of the subscription that needs to be returned",
            "schema": {
              "example": "6322e9c9e39fc14ab3ed7042",
              "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",
              "enum": [
                "location"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetSubscriptionResponseSchema"
                }
              }
            }
          },
          "400": {
            "description": "Subscription 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/subscriptions.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": {
      "GetSubscriptionResponseSchema": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "The unique identifier for the subscription.",
            "example": "64bf78af39118e4011926cba"
          },
          "altType": {
            "type": "object",
            "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 subscription."
          },
          "contactSnapshot": {
            "type": "object",
            "description": "Contact details of the subscriber.",
            "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\"}"
          },
          "coupon": {
            "type": "object",
            "description": "Coupon details of the subscription.",
            "example": "{ _id: \"6374c6926d119a393fe1e556\", usageCount: 5260, altId: \"jVFIxsMY19D94nOSIOEO\", altType: \"location\", name: \"FREE-100%\", code: \"FREE100\", discountType: \"percentage\", discountValue: 100 }"
          },
          "currency": {
            "type": "string",
            "example": "USD",
            "description": "Currency in which subscription was made."
          },
          "amount": {
            "type": "number",
            "example": "100",
            "description": "Subscription value."
          },
          "status": {
            "type": "object",
            "example": "active",
            "description": "Subscription status."
          },
          "liveMode": {
            "type": "boolean",
            "example": "false",
            "description": "Subscription is in live / test mode."
          },
          "entityType": {
            "type": "string",
            "example": "order",
            "description": "Entity type of subscription (eg: order)."
          },
          "entityId": {
            "type": "string",
            "example": "62f4db0f3059ecee61379012",
            "description": "Entity id for the subscription. e.g: order id"
          },
          "entitySource": {
            "description": "Entity source details for the subscription.",
            "example": "{ type: \"funnel\", id: \"lx6ROqruHGVQD2PZwFxK\", subType: \"upsell\", name: \"test 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"
              }
            ]
          },
          "subscriptionId": {
            "type": "string",
            "example": "I-0UE609H8E43P",
            "description": "Subscription id for subscription."
          },
          "subscriptionSnapshot": {
            "type": "object",
            "description": "Snapshot of subscription.",
            "example": "{ status: \"ACTIVE\", status_update_time: \"2022-08-16T11:06:53Z\", id: \"I-0UE609H8E43P\", plan_id: \"P-82K11750F0313430KMLRGE6Y\", start_time: \"2022-08-16T11:05:31Z\", quantity: 1 }"
          },
          "paymentProvider": {
            "type": "object",
            "description": "Payment provider details for the subscription.",
            "example": "{ type: \"paypal\", connectedAccount: { _id: \"64410debdc8f3b0503523abb\", merchantClientId: \"AeXtjrxdgsJiCPwQt5jML5pH-0mwmLs-tH7ub4Uo3IrDKvRl34FvJy8niI6E1wmS_pryIRdNllyVl58b\" } }"
          },
          "ipAddress": {
            "type": "string",
            "example": "103.100.16.82",
            "description": "Ip address from where subscription was initiated."
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "The creation timestamp of the subscription.",
            "example": "2023-11-20T10:23:36.515Z"
          },
          "updatedAt": {
            "format": "date-time",
            "type": "string",
            "description": "The last update timestamp of the subscription.",
            "example": "2024-01-23T09:57:04.846Z"
          },
          "meta": {
            "type": "object",
            "description": "Meta details of the subscription.",
            "example": "{ collection: \"transactionsv2\", id: \"6320652f0f664b6632006920\" }"
          },
          "markAsTest": {
            "type": "boolean",
            "description": "Is test subscription.",
            "example": "false"
          },
          "schedule": {
            "description": "Scedule details for the subscription.",
            "example": "{ collection: \"transactionsv2\", id: \"6320652f0f664b6632006920\" }",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "executeAt": {
                    "type": "string"
                  },
                  "rrule": {
                    "type": "object",
                    "properties": {
                      "intervalType": {
                        "type": "string",
                        "enum": [
                          "yearly",
                          "monthly",
                          "weekly",
                          "daily",
                          "hourly",
                          "minutely",
                          "secondly"
                        ],
                        "example": "monthly"
                      },
                      "interval": {
                        "type": "number",
                        "example": 2
                      },
                      "startDate": {
                        "type": "string",
                        "description": "Start date in YYYY-MM-DD format",
                        "example": "2023-01-01"
                      },
                      "startTime": {
                        "type": "string",
                        "description": "Start time in HH:mm:ss format",
                        "example": "20:45:00"
                      },
                      "endDate": {
                        "type": "string",
                        "description": "End date in YYYY-MM-DD format",
                        "example": "2029-11-01"
                      },
                      "endTime": {
                        "type": "string",
                        "description": "End time in HH:mm:ss format",
                        "example": "18:45:00"
                      },
                      "dayOfMonth": {
                        "type": "number",
                        "description": "-1, 1, 2, 3, ..., 27, 28",
                        "example": 15
                      },
                      "dayOfWeek": {
                        "type": "string",
                        "enum": [
                          "mo",
                          "tu",
                          "we",
                          "th",
                          "fr",
                          "sa",
                          "su"
                        ],
                        "example": "mo"
                      },
                      "numOfWeek": {
                        "type": "number",
                        "description": "-1, 1, 2, 3, 4",
                        "example": -1
                      },
                      "monthOfYear": {
                        "type": "string",
                        "enum": [
                          "jan",
                          "feb",
                          "mar",
                          "apr",
                          "may",
                          "jun",
                          "jul",
                          "aug",
                          "sep",
                          "oct",
                          "nov",
                          "dec"
                        ],
                        "example": "jan"
                      },
                      "count": {
                        "type": "number",
                        "description": "Max number of task executions",
                        "example": 10
                      },
                      "daysBefore": {
                        "type": "number",
                        "description": "Execute task number of days before",
                        "example": 5
                      }
                    },
                    "required": [
                      "intervalType",
                      "interval",
                      "startDate"
                    ],
                    "title": "CustomRRuleOptionsDto"
                  }
                },
                "title": "ScheduleOptionsDto"
              }
            ]
          },
          "autoPayment": {
            "type": "object",
            "description": "Auto payment details of the subscription.",
            "example": "{ customerId: \"908879612\", paymentMethodId: \"908646635\" }"
          },
          "recurringProduct": {
            "type": "object",
            "description": "Recurring product details of the subscription.",
            "example": "{ locationId: \"Z4Bxl8J4SaPEPLq9IQ8g\", funnel: \"bQHJWKcyjiKjk4BHv91g\", step: \"2281a993-8a75-4b48-9912-571f29c99a74\", name: \"Sofa Set\" }"
          },
          "canceledAt": {
            "format": "date-time",
            "type": "string",
            "description": "Cancellation timestamp of the subscription.",
            "example": "2023-11-20T10:23:36.515Z"
          },
          "canceledBy": {
            "type": "string",
            "example": "qUuXUiB2AiA2DIthEicP",
            "description": "User id who cancelled the subscription."
          },
          "traceId": {
            "type": "string",
            "description": "Trace id of the subscription.",
            "example": "302d2cf4-1ba0-4bf5-bc3b-f8fa76fda58a"
          },
          "createdBy": {
            "type": "string",
            "example": "user123",
            "description": "User ID who created the subscription."
          }
        },
        "required": [
          "_id",
          "altType",
          "altId",
          "createdAt",
          "updatedAt"
        ],
        "title": "GetSubscriptionResponseSchema"
      },
      "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/subscriptions/<subscriptionId>?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/subscriptions/<subscriptionId>?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/subscriptions/{subscriptionId}"

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