# List Prices for a Product

GET https://services.leadconnectorhq.com/products/{productId}/price

The "List Prices for a Product" API allows retrieving a paginated list of prices associated with a specific product. Customize your results by filtering prices or paginate through the list using the provided query parameters.

## Authentication

Send `Authorization: Bearer <token>` using any one of:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `products/prices.readonly`
- **Agency token: OAuth access token or Private Integration Token.** Scopes: `products/prices.readonly`

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `productId` | string | Yes | ID of the product that needs to be used |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `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. |
| `locationId` | string | Yes | The unique identifier for the location. |
| `ids` | string | No | To filter the response only with the given price ids, Please provide with comma separated |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/products/{productId}/price": {
      "get": {
        "summary": "List Prices for a Product",
        "operationId": "listPricesForAProduct",
        "description": "The \"List Prices for a Product\" API allows retrieving a paginated list of prices associated with a specific product. Customize your results by filtering prices or paginate through the list using the provided query parameters.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "productId",
            "required": true,
            "in": "path",
            "description": "ID of the product that needs to be used",
            "schema": {
              "example": "6578278e879ad2646715ba9c",
              "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": 0,
              "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"
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "The unique identifier for the location.",
            "schema": {
              "example": "3SwdhCsvxI8Au3KsPJt6",
              "type": "string"
            }
          },
          {
            "name": "ids",
            "required": false,
            "in": "query",
            "description": "To filter the response only with the given price ids, Please provide with comma separated",
            "schema": {
              "example": "6241712be68f7a98102ba272,632027d51f7876cd3020213d",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListPricesResponseDto"
                }
              }
            }
          },
          "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": [
              "products/prices.readonly"
            ]
          },
          {
            "Agency-Access": [
              "products/prices.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": {
      "ListPricesResponseDto": {
        "type": "object",
        "properties": {
          "prices": {
            "description": "An array of prices",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_id": {
                  "type": "string",
                  "description": "The unique identifier for the price.",
                  "example": "655b33aa2209e60b6adb87a7"
                },
                "membershipOffers": {
                  "description": "An array of membership offers associated with the price.",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "label": {
                        "type": "string",
                        "description": "Membership offer label",
                        "example": "top_50"
                      },
                      "value": {
                        "type": "string",
                        "description": "Membership offer label",
                        "example": "50"
                      },
                      "_id": {
                        "type": "string",
                        "description": "The unique identifier for the membership offer.",
                        "example": "655b33aa2209e60b6adb87a7"
                      }
                    },
                    "required": [
                      "label",
                      "value",
                      "_id"
                    ],
                    "title": "MembershipOfferDto"
                  }
                },
                "variantOptionIds": {
                  "description": "An array of variant option IDs associated with the price.",
                  "example": [
                    "h4z7u0im2q8",
                    "h3nst2ltsnn"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "locationId": {
                  "type": "string",
                  "description": "The unique identifier for the location.",
                  "example": "3SwdhCsvxI8Au3KsPJt6"
                },
                "product": {
                  "type": "string",
                  "description": "The unique identifier for the associated product.",
                  "example": "655b33a82209e60b6adb87a5"
                },
                "userId": {
                  "type": "string",
                  "description": "The unique identifier for the user.",
                  "example": "6YAtzfzpmHAdj0e8GkKp"
                },
                "name": {
                  "type": "string",
                  "description": "The name of the price.",
                  "example": "Red / S"
                },
                "type": {
                  "type": "string",
                  "description": "The type of the price (e.g., one_time).",
                  "example": "one_time",
                  "enum": [
                    "one_time",
                    "recurring"
                  ]
                },
                "currency": {
                  "type": "string",
                  "description": "The currency code for the price.",
                  "example": "INR"
                },
                "amount": {
                  "type": "number",
                  "description": "The amount of the price.",
                  "example": 199999
                },
                "recurring": {
                  "description": "The recurring details of the price (if type is recurring).",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "interval": {
                          "type": "string",
                          "description": "The interval at which the recurring event occurs.",
                          "example": "day",
                          "enum": [
                            "day",
                            "month",
                            "week",
                            "year"
                          ]
                        },
                        "intervalCount": {
                          "type": "number",
                          "description": "The number of intervals between each occurrence of the event.",
                          "example": 1
                        }
                      },
                      "required": [
                        "interval",
                        "intervalCount"
                      ],
                      "title": "RecurringDto"
                    }
                  ]
                },
                "createdAt": {
                  "format": "date-time",
                  "type": "string",
                  "description": "The creation timestamp of the price.",
                  "example": "2023-11-20T10:23:38.645Z"
                },
                "updatedAt": {
                  "format": "date-time",
                  "type": "string",
                  "description": "The last update timestamp of the price.",
                  "example": "2024-01-23T09:57:04.852Z"
                },
                "compareAtPrice": {
                  "type": "number",
                  "description": "The compare-at price for comparison purposes.",
                  "example": 2000000
                },
                "trackInventory": {
                  "type": "boolean",
                  "description": "Indicates whether inventory tracking is enabled.",
                  "example": null
                },
                "availableQuantity": {
                  "type": "number",
                  "description": "Available inventory stock quantity",
                  "example": 5
                },
                "allowOutOfStockPurchases": {
                  "type": "boolean",
                  "description": "Continue selling when out of stock",
                  "example": true
                }
              },
              "required": [
                "_id",
                "name",
                "type",
                "currency",
                "amount"
              ],
              "title": "DefaultPriceResponseDto"
            }
          },
          "total": {
            "type": "number",
            "default": "Total number of prices available",
            "example": 10
          }
        },
        "required": [
          "prices",
          "total"
        ],
        "title": "ListPricesResponseDto"
      },
      "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"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const response = await ghl.products.listPricesForAProduct('<PRODUCTID>', { locationId: '<LOCATIONID>' });
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

response = await client.products.list_prices_for_a_product('<PRODUCTID>', locationId='<LOCATIONID>')
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$response = $ghl->products->listPricesForAProduct('<PRODUCTID>', ['locationId' => '<LOCATIONID>']);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/products/<productId>/price?locationId=<LOCATIONID>' \
  -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/products/<productId>/price?locationId=<LOCATIONID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/products/{productId}/price"

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

params = {
    "locationId": "<LOCATIONID>"
}

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/products/<productId>/price?locationId=<LOCATIONID>',
  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/products/<productId>/price?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/products/<productId>/price?locationId=<LOCATIONID>"
  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/products/<productId>/price?locationId=<LOCATIONID>")

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/products/<productId>/price?locationId=<LOCATIONID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
