# Fetch Coupon

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

The "Get Coupon Details" API enables you to retrieve comprehensive information about a specific coupon using either its unique identifier or promotional code. Use this endpoint to view coupon parameters, usage statistics, validity periods, and other promotional details.

## 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 |
| `id` | string | Yes | Coupon id |
| `code` | string | Yes | Coupon code |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/payments/coupon": {
      "get": {
        "summary": "Fetch Coupon",
        "operationId": "fetchCoupon",
        "description": "The \"Get Coupon Details\" API enables you to retrieve comprehensive information about a specific coupon using either its unique identifier or promotional code. Use this endpoint to view coupon parameters, usage statistics, validity periods, and other promotional details.",
        "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": "id",
            "required": true,
            "in": "query",
            "description": "Coupon id",
            "schema": {
              "example": "6241712be68f7a98102ba272",
              "type": "string"
            }
          },
          {
            "name": "code",
            "required": true,
            "in": "query",
            "description": "Coupon code",
            "schema": {
              "example": "DEAL50",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateCouponResponseDto"
                }
              }
            }
          },
          "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": {
      "CreateCouponResponseDto": {
        "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"
              }
            ]
          },
          "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"
          },
          "traceId": {
            "type": "string",
            "description": "Unique identifier for tracing this API request",
            "example": "c667b18d-8f5e-44cf-a914"
          }
        },
        "required": [
          "_id",
          "usageCount",
          "limitPerCustomer",
          "altId",
          "altType",
          "name",
          "code",
          "discountType",
          "discountValue",
          "status",
          "startDate",
          "applyToFuturePayments",
          "applyToFuturePaymentsConfig",
          "createdAt",
          "updatedAt",
          "traceId"
        ],
        "title": "CreateCouponResponseDto"
      },
      "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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>' \
  -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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>', 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"

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

params = {
    "altId": "<ALTID>",
    "altType": "<ALTTYPE>",
    "id": "<ID>",
    "code": "<CODE>"
}

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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>',
  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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>")
  .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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>"
  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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>")

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?altId=<ALTID>&altType=<ALTTYPE>&id=<ID>&code=<CODE>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
