# List Coupons

GET https://services.leadconnectorhq.com/payments/coupon/list

The "List Coupons" API allows you to retrieve a list of all coupons available in your location. Use this endpoint to view all promotional offers and special discounts for your customers.

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `altId` | string | Yes | Location Id |
| `altType` | string | Yes | Alt Type |
| `limit` | number | No | Maximum number of coupons to return |
| `offset` | number | No | Number of coupons to skip for pagination |
| `status` | string | No | Filter coupons by status |
| `search` | string | No | Search term to filter coupons by name or code |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/payments/coupon/list": {
      "get": {
        "summary": "List Coupons",
        "operationId": "listCoupons",
        "description": "The \"List Coupons\" API allows you to retrieve a list of all coupons available in your location. Use this endpoint to view all promotional offers and special discounts for your customers.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "altId",
            "required": true,
            "in": "query",
            "description": "Location Id",
            "schema": {
              "example": "BQdAwxa0ky1iK2sstLGJ",
              "type": "string"
            }
          },
          {
            "name": "altType",
            "required": true,
            "in": "query",
            "description": "Alt Type",
            "schema": {
              "example": "location",
              "enum": [
                "location"
              ],
              "type": "string"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Maximum number of coupons to return",
            "schema": {
              "default": 100,
              "example": 10,
              "type": "number"
            }
          },
          {
            "name": "offset",
            "required": false,
            "in": "query",
            "description": "Number of coupons to skip for pagination",
            "schema": {
              "default": 0,
              "example": 0,
              "type": "number"
            }
          },
          {
            "name": "status",
            "required": false,
            "in": "query",
            "description": "Filter coupons by status",
            "schema": {
              "example": "active",
              "enum": [
                "scheduled",
                "active",
                "expired"
              ],
              "type": "string"
            }
          },
          {
            "name": "search",
            "required": false,
            "in": "query",
            "description": "Search term to filter coupons by name or code",
            "schema": {
              "example": "DEAL50",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListCouponsResponseDto"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "payments/coupons.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": {
      "ListCouponsResponseDto": {
        "type": "object",
        "properties": {
          "data": {
            "description": "Array of coupon objects",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "_id": {
                  "type": "string",
                  "description": "Unique MongoDB identifier for the coupon",
                  "example": "67f6c132d9485f9dacd5f123"
                },
                "usageCount": {
                  "type": "number",
                  "description": "Number of times the coupon has been used",
                  "example": 12
                },
                "limitPerCustomer": {
                  "type": "number",
                  "description": "Maximum number of times a customer can use this coupon (0 for unlimited)",
                  "example": 5
                },
                "altId": {
                  "type": "string",
                  "description": "Location Id",
                  "example": "79t07PzK8Tvf73d12312"
                },
                "altType": {
                  "type": "string",
                  "description": "Type of entity",
                  "example": "location"
                },
                "name": {
                  "type": "string",
                  "description": "Display name of the coupon",
                  "example": "NEWT6"
                },
                "code": {
                  "type": "string",
                  "description": "Redemption code for the coupon",
                  "example": "NEWT6"
                },
                "discountType": {
                  "type": "string",
                  "description": "Type of discount (percentage or amount)",
                  "example": "percentage",
                  "enum": [
                    "percentage",
                    "amount"
                  ]
                },
                "discountValue": {
                  "type": "number",
                  "description": "Value of the discount (percentage or fixed amount)",
                  "example": 25
                },
                "status": {
                  "type": "string",
                  "description": "Current status of the coupon",
                  "example": "scheduled",
                  "enum": [
                    "scheduled",
                    "active",
                    "expired"
                  ]
                },
                "startDate": {
                  "type": "string",
                  "description": "Date when the coupon becomes active",
                  "example": "2025-04-30T18:30:00.000Z"
                },
                "endDate": {
                  "type": "string",
                  "description": "End date when the coupon expires",
                  "example": "2025-05-30T18:30:00.000Z"
                },
                "applyToFuturePayments": {
                  "type": "boolean",
                  "description": "Indicates if the coupon applies to future recurring payments",
                  "example": true
                },
                "applyToFuturePaymentsConfig": {
                  "description": "Configuration for how the coupon applies to future payments",
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "description": "Type of future payments configuration",
                          "example": "fixed",
                          "enum": [
                            "forever",
                            "fixed"
                          ]
                        },
                        "duration": {
                          "type": "number",
                          "description": "Duration value for fixed type configurations",
                          "example": 3
                        },
                        "durationType": {
                          "type": "string",
                          "description": "Duration type for fixed configurations (e.g. months)",
                          "example": "months"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "title": "ApplyToFuturePaymentsConfigDto"
                    }
                  ]
                },
                "productIds": {
                  "description": "Product Ids",
                  "example": [
                    "6241712be68f7a98102ba272"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "priceIds": {
                  "description": "Price Ids",
                  "example": [
                    "6241712be68f7a98102ba272"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "variantIds": {
                  "description": "Variant Ids",
                  "example": [
                    "6241712be68f7a98102ba272"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "userId": {
                  "type": "string",
                  "description": "User ID associated with the coupon (if applicable)",
                  "example": "q0m15dTLGeiGOXG123123"
                },
                "createdAt": {
                  "type": "string",
                  "description": "Creation timestamp",
                  "example": "2025-04-09T18:49:22.026Z"
                },
                "updatedAt": {
                  "type": "string",
                  "description": "Last update timestamp",
                  "example": "2025-04-09T18:49:22.026Z"
                }
              },
              "required": [
                "_id",
                "usageCount",
                "limitPerCustomer",
                "altId",
                "altType",
                "name",
                "code",
                "discountType",
                "discountValue",
                "status",
                "startDate",
                "applyToFuturePayments",
                "applyToFuturePaymentsConfig",
                "createdAt",
                "updatedAt"
              ],
              "title": "CouponDto"
            }
          },
          "totalCount": {
            "type": "number",
            "description": "Total number of coupons matching the query criteria",
            "example": 20
          },
          "traceId": {
            "type": "string",
            "description": "Unique identifier for tracing this API request",
            "example": "c667b18d-8f5e-44cf-a914"
          }
        },
        "required": [
          "data",
          "totalCount",
          "traceId"
        ],
        "title": "ListCouponsResponseDto"
      },
      "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/coupon/list?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/coupon/list?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/coupon/list"

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