# Get invoice

GET https://services.leadconnectorhq.com/invoices/{invoiceId}

API to get invoice by invoice id

## Authentication

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

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `invoiceId` | string | Yes | Invoice Id |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `altId` | string | Yes | location Id / company Id based on altType |
| `altType` | string | Yes | Alt Type |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/invoices/{invoiceId}": {
      "get": {
        "summary": "Get invoice",
        "operationId": "getInvoice",
        "description": "API to get invoice by invoice id",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "invoiceId",
            "required": true,
            "in": "path",
            "description": "Invoice Id",
            "schema": {
              "example": "6578278e879ad2646715ba9c",
              "type": "string"
            }
          },
          {
            "name": "altId",
            "required": true,
            "in": "query",
            "description": "location Id / company Id based on altType",
            "schema": {
              "example": "6578278e879ad2646715ba9c",
              "type": "string"
            }
          },
          {
            "name": "altType",
            "required": true,
            "in": "query",
            "description": "Alt Type",
            "schema": {
              "example": "location",
              "enum": [
                "location"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GetInvoiceResponseDto"
                }
              }
            }
          },
          "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.readonly"
            ]
          },
          {
            "Agency-Access": [
              "invoices.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": {
      "GetInvoiceResponseDto": {
        "type": "object",
        "properties": {
          "_id": {
            "type": "string",
            "description": "Invoice Id",
            "example": "6578278e879ad2646715ba9c"
          },
          "status": {
            "type": "string",
            "description": "Invoice Status",
            "example": "draft",
            "enum": [
              "draft",
              "sent",
              "payment_processing",
              "paid",
              "void",
              "partially_paid"
            ]
          },
          "liveMode": {
            "type": "boolean",
            "description": "Live Mode",
            "example": false
          },
          "amountPaid": {
            "type": "number",
            "description": "Amount Paid",
            "example": 0
          },
          "altId": {
            "type": "string",
            "description": "Location Id or Agency Id",
            "example": "6578278e879ad2646715ba9c"
          },
          "altType": {
            "type": "string",
            "enum": [
              "location"
            ]
          },
          "name": {
            "type": "string",
            "description": "Name of the invoice",
            "example": "New Invoice"
          },
          "businessDetails": {
            "type": "object",
            "description": "Business Details",
            "example": {
              "name": "Alex",
              "address": {
                "addressLine1": "9931 Beechwood",
                "city": "St. Houston",
                "state": "TX",
                "countryCode": "USA",
                "postalCode": "559-6993"
              },
              "phoneNo": "+1-214-559-6993",
              "website": "www.example.com"
            }
          },
          "invoiceNumber": {
            "type": "number",
            "description": "Invoice Number",
            "example": "19"
          },
          "currency": {
            "type": "string",
            "description": "Currency",
            "example": "USD"
          },
          "contactDetails": {
            "type": "object",
            "description": "Contact Details",
            "example": {
              "id": "c6tZZU0rJBf30ZXx9Gli",
              "phoneNo": "+1-214-559-6993",
              "email": "alex@example.com",
              "customFields": [],
              "name": "Alex",
              "address": {
                "countryCode": "US"
              }
            }
          },
          "issueDate": {
            "type": "string",
            "description": "Issue date in YYYY-MM-DD format",
            "example": "2023-01-01"
          },
          "dueDate": {
            "type": "string",
            "description": "Due date in YYYY-MM-DD format",
            "example": "2023-01-01"
          },
          "discount": {
            "type": "object",
            "description": "Discount",
            "example": {
              "type": "percentage",
              "value": 0
            }
          },
          "invoiceItems": {
            "description": "Invoice Items",
            "example": [
              {
                "taxes": [],
                "_id": "c6tZZU0rJBf30ZXx9Gli",
                "productId": "c6tZZU0rJBf30ZXx9Gli",
                "priceId": "c6tZZU0rJBf30ZXx9Gli",
                "currency": "USD",
                "name": "Macbook Pro",
                "qty": 1,
                "amount": 999
              }
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "total": {
            "type": "number",
            "description": "Total Amount",
            "example": 999
          },
          "title": {
            "type": "string",
            "description": "Title",
            "example": "INVOICE"
          },
          "amountDue": {
            "type": "number",
            "description": "Total Amount Due",
            "example": 999
          },
          "createdAt": {
            "type": "string",
            "description": "created at",
            "example": "2023-12-12T09:27:42.355Z"
          },
          "updatedAt": {
            "type": "string",
            "description": "updated at",
            "example": "2023-12-12T09:27:42.355Z"
          },
          "automaticTaxesEnabled": {
            "type": "boolean",
            "description": "Automatic taxes enabled for the Invoice",
            "example": true
          },
          "automaticTaxesCalculated": {
            "type": "boolean",
            "description": "Is Automatic taxes calculated for the Invoice items",
            "example": true
          },
          "paymentSchedule": {
            "type": "object",
            "description": "split invoice into payment schedule summing up to full invoice amount"
          },
          "totalSummary": {
            "type": "object",
            "properties": {
              "subTotal": {
                "type": "number",
                "description": "subTotal",
                "example": 999
              },
              "discount": {
                "type": "number",
                "description": "discount",
                "example": 0
              },
              "tax": {
                "type": "number",
                "description": "tax",
                "example": 0
              }
            },
            "required": [
              "subTotal",
              "discount",
              "tax"
            ],
            "title": "TotalSummaryDto"
          },
          "remindersConfiguration": {
            "description": "Reminders Configuration",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "reminderExecutionDetailsList": {
                    "description": "List of reminders",
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {},
                        "title": "ReminderExecutionDetailsList"
                      }
                    ]
                  },
                  "reminderSettings": {
                    "description": "Reminder settings",
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {
                          "defaultEmailTemplateId": {
                            "type": "string",
                            "description": "default template Id of reminder",
                            "example": "dhwjqi2899012990w2u"
                          },
                          "reminders": {
                            "description": "List of reminders",
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "enabled": {
                                  "type": "boolean",
                                  "description": "Flag indicating if the reminder is enabled or not",
                                  "example": true
                                },
                                "emailTemplate": {
                                  "type": "string",
                                  "description": "Email template to be used for sending reminders",
                                  "example": "default"
                                },
                                "smsTemplate": {
                                  "type": "string",
                                  "description": "SMS template to be used for sending reminders",
                                  "example": "default"
                                },
                                "emailSubject": {
                                  "type": "string",
                                  "description": "Subject of the reminder",
                                  "example": "Reminder"
                                },
                                "reminderId": {
                                  "type": "string",
                                  "description": "Unique identifier for the reminder",
                                  "example": "9333e45f-a27d-4659-90e5-76c5ef06d094"
                                },
                                "reminderName": {
                                  "type": "string",
                                  "description": "Name of the reminder",
                                  "example": "Special Reminder"
                                },
                                "reminderTime": {
                                  "type": "string",
                                  "description": "Time condition for the reminder",
                                  "example": "before",
                                  "enum": [
                                    "before",
                                    "after"
                                  ]
                                },
                                "intervalType": {
                                  "type": "string",
                                  "description": "Interval type for the reminder",
                                  "example": "daily",
                                  "enum": [
                                    "yearly",
                                    "monthly",
                                    "weekly",
                                    "daily",
                                    "hourly",
                                    "minutely",
                                    "secondly"
                                  ]
                                },
                                "maxReminders": {
                                  "type": "number",
                                  "description": "Maximum number of reminders that can be sent",
                                  "example": 3
                                },
                                "reminderInvoiceCondition": {
                                  "type": "string",
                                  "description": "Condition for sending the reminder",
                                  "example": "invoice_sent",
                                  "enum": [
                                    "invoice_sent",
                                    "invoice_overdue"
                                  ]
                                },
                                "reminderNumber": {
                                  "type": "number",
                                  "description": "frequency gap of the reminder to exeucte",
                                  "example": 10
                                },
                                "startTime": {
                                  "type": "string",
                                  "description": "Business Hour Start Time",
                                  "example": "9:00 AM"
                                },
                                "endTime": {
                                  "type": "string",
                                  "description": "Business Hour End Time",
                                  "example": "5:00 PM"
                                },
                                "timezone": {
                                  "type": "string",
                                  "description": "Timezone at which reminder will be sent",
                                  "example": "businessTZ"
                                }
                              },
                              "required": [
                                "enabled",
                                "emailTemplate",
                                "smsTemplate",
                                "emailSubject",
                                "reminderId",
                                "reminderName",
                                "reminderTime",
                                "intervalType",
                                "maxReminders",
                                "reminderInvoiceCondition",
                                "reminderNumber"
                              ],
                              "title": "ReminderDto"
                            }
                          }
                        },
                        "required": [
                          "defaultEmailTemplateId",
                          "reminders"
                        ],
                        "title": "ReminderSettingsDto"
                      }
                    ]
                  }
                },
                "required": [
                  "reminderExecutionDetailsList",
                  "reminderSettings"
                ],
                "title": "RemindersConfigurationDto"
              }
            ]
          }
        },
        "required": [
          "_id",
          "status",
          "liveMode",
          "amountPaid",
          "altId",
          "altType",
          "name",
          "businessDetails",
          "invoiceNumber",
          "currency",
          "contactDetails",
          "issueDate",
          "dueDate",
          "invoiceItems",
          "total",
          "title",
          "amountDue",
          "createdAt",
          "updatedAt",
          "totalSummary"
        ],
        "title": "GetInvoiceResponseDto"
      },
      "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/<invoiceId>?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/invoices/<invoiceId>?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/invoices/{invoiceId}"

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