# Preview Estimate Template

GET https://services.leadconnectorhq.com/invoices/estimate/template/preview

Get a preview of an estimate template

## Authentication

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

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

## Parameters

### Header Parameters

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

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `altId` | string | Yes | Location Id or Agency Id |
| `altType` | string | Yes |  |
| `templateId` | string | Yes | Template Id |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/invoices/estimate/template/preview": {
      "get": {
        "summary": "Preview Estimate Template",
        "operationId": "previewEstimateTemplate",
        "description": "Get a preview of an estimate template",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "altId",
            "required": true,
            "in": "query",
            "description": "Location Id or Agency Id",
            "schema": {
              "example": "6578278e879ad2646715ba9c",
              "type": "string"
            }
          },
          {
            "name": "altType",
            "required": true,
            "in": "query",
            "schema": {
              "enum": [
                "location"
              ],
              "type": "string"
            }
          },
          {
            "name": "templateId",
            "required": true,
            "in": "query",
            "description": "Template Id",
            "schema": {
              "example": "5f9d6d8b1b2d2c001f2d9e4b",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EstimateTemplateResponseDTO"
                }
              }
            }
          },
          "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": [
              "invoices/estimate.readonly"
            ]
          },
          {
            "Agency-Access": [
              "invoices/estimate.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": {
      "EstimateTemplateResponseDTO": {
        "type": "object",
        "properties": {
          "altId": {
            "type": "string",
            "description": "Location Id or Agency Id",
            "example": "6578278e879ad2646715ba9c"
          },
          "altType": {
            "type": "string",
            "enum": [
              "location"
            ]
          },
          "_id": {
            "type": "string",
            "description": "Unique identifier",
            "example": "67ac9a51106ee8311e911XXXX"
          },
          "liveMode": {
            "type": "boolean",
            "description": "Indicates if it is in live mode",
            "example": true
          },
          "deleted": {
            "type": "boolean",
            "description": "Indicates if deleted",
            "example": false
          },
          "name": {
            "type": "string",
            "description": "Name",
            "example": "Estimate Name"
          },
          "currency": {
            "type": "string",
            "description": "Currency code",
            "example": "USD"
          },
          "businessDetails": {
            "description": "Business details associated with the estimate",
            "example": {
              "logoUrl": "your_image-url",
              "name": "Business name",
              "address": {
                "addressLine1": "address line 1",
                "city": "Test City",
                "state": "State Name",
                "countryCode": "US",
                "postalCode": "12345"
              },
              "phoneNo": "+1 1234567890",
              "website": "www.example.com",
              "customValues": [
                {
                  "name": "Test",
                  "fieldKey": "{{custom_values.test}}",
                  "id": "5DYTWoiQvWiIJZXX44XXX",
                  "value": "Test's Custom Value"
                }
              ]
            },
            "allOf": [
              {
                "type": "object",
                "properties": {},
                "title": "BusinessDetails"
              }
            ]
          },
          "items": {
            "description": "An array of items",
            "example": [
              {
                "taxes": [],
                "taxInclusive": false,
                "_id": "67ac9a51106ee8311e911XXXX",
                "description": "<p>Futuristic anti-gravity racing</p>",
                "currency": "USD",
                "productId": "67ac9a51106ee8311e911XXXX",
                "priceId": "67ac9a51106ee8311e911XXXX",
                "amount": 9.99,
                "qty": 1,
                "name": "TEST",
                "type": "one_time"
              },
              {
                "taxes": [
                  {
                    "_id": "67ac9a51106ee8311e911XXXX",
                    "name": "TaxTwo",
                    "rate": 8.5,
                    "calculation": "exclusive"
                  }
                ],
                "taxInclusive": true,
                "_id": "67ac9a51106ee8311e911XXXX",
                "productId": "67ac9a51106ee8311e911XXXX",
                "priceId": "67ac9a51106ee8311e911XXXX",
                "currency": "USD",
                "name": "TEST2",
                "qty": 1,
                "amount": 500,
                "description": "",
                "type": "recurring"
              }
            ],
            "type": "array",
            "items": {
              "type": "array"
            }
          },
          "discount": {
            "description": "Discount details for the estimate template",
            "example": {
              "type": "percentage",
              "value": 0
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "number",
                    "description": "Discount Value",
                    "example": 10,
                    "default": 0
                  },
                  "type": {
                    "type": "string",
                    "description": "Discount type",
                    "enum": [
                      "percentage",
                      "fixed"
                    ],
                    "example": "percentage",
                    "default": "percentage"
                  },
                  "validOnProductIds": {
                    "description": "Product Ids on which discount is applicable",
                    "example": "[ '6579751d56f60276e5bd4154' ]",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "type"
                ],
                "title": "DiscountDto"
              }
            ]
          },
          "title": {
            "type": "string",
            "description": "Title",
            "example": "ESTIMATE"
          },
          "estimateNumberPrefix": {
            "type": "string",
            "description": "Estimate number prefix",
            "example": "EST-"
          },
          "attachments": {
            "description": "Attachments",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Id of the file selected",
                  "example": "6241712be68f7a98102ba272"
                },
                "name": {
                  "type": "string",
                  "description": "Name of the file ",
                  "example": "Electronics.pdf"
                },
                "url": {
                  "type": "string",
                  "description": "URL of the file",
                  "example": "https://example.com/digital-delivery"
                },
                "type": {
                  "type": "string",
                  "description": "Type of the file"
                },
                "size": {
                  "type": "number",
                  "description": "Size of the file",
                  "example": 10000
                }
              },
              "required": [
                "id",
                "name",
                "url",
                "type",
                "size"
              ],
              "title": "AttachmentsDto"
            }
          },
          "updatedBy": {
            "type": "string",
            "description": "User Id of who last updated",
            "example": "3HIpOF9NIc5ltriQXXXX"
          },
          "total": {
            "type": "number",
            "description": "Total amount",
            "example": 1222.03
          },
          "createdAt": {
            "format": "date-time",
            "type": "string",
            "description": "Timestamp when created",
            "example": "2025-02-12T13:17:47.416Z"
          },
          "updatedAt": {
            "format": "date-time",
            "type": "string",
            "description": "Timestamp when last updated",
            "example": "2025-02-12T13:17:47.416Z"
          },
          "__v": {
            "type": "number",
            "description": "Version number",
            "example": 0
          },
          "automaticTaxesEnabled": {
            "type": "boolean",
            "description": "Indicates if automatic taxes are enabled for this estimate",
            "example": false
          },
          "termsNotes": {
            "type": "string",
            "description": "Terms and conditions for the estimate, supports HTML markup",
            "example": "<p>All services are subject to availability.</p>"
          }
        },
        "required": [
          "altId",
          "altType",
          "_id",
          "liveMode",
          "deleted",
          "name",
          "currency",
          "businessDetails",
          "items",
          "discount",
          "total",
          "createdAt",
          "updatedAt",
          "__v",
          "automaticTaxesEnabled"
        ],
        "title": "EstimateTemplateResponseDTO"
      },
      "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/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>' \
  -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/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/invoices/estimate/template/preview"

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

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

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/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>',
  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/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>"
  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/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>")

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/invoices/estimate/template/preview?altId=<ALTID>&altType=<ALTTYPE>&templateId=<TEMPLATEID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
