# Send template

POST https://services.leadconnectorhq.com/proposals/templates/send

Send template to a client

## Authentication

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

- **Sub-Account token: OAuth access token or Private Integration Token.** No scopes required.
- **Agency token: OAuth access token or Private Integration Token.** No scopes required.

## Parameters

### Header Parameters

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

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/proposals/templates/send": {
      "post": {
        "summary": "Send template",
        "operationId": "sendTemplate",
        "description": "Send template to a client",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendDocumentFromPublicApiBodyDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Document sent successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SendTemplateResponseDto"
                }
              }
            }
          },
          "400": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": []
          },
          {
            "Agency-Access": []
          }
        ]
      }
    }
  },
  "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"
      },
      "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"
      },
      "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"
      }
    },
    "schemas": {
      "SendDocumentFromPublicApiBodyDto": {
        "type": "object",
        "properties": {
          "templateId": {
            "type": "string",
            "description": "Template Id",
            "example": "hTlkh7t8gujsahgg93"
          },
          "userId": {
            "type": "string",
            "description": "User Id",
            "example": "hTlkh7t8gujsahgg93"
          },
          "sendDocument": {
            "type": "boolean",
            "description": "Send Document",
            "example": true
          },
          "locationId": {
            "type": "string",
            "description": "Location Id",
            "example": "hTlkh7t8gujsahgg93"
          },
          "contactId": {
            "type": "string",
            "description": "Contact Id",
            "example": "hTlkh7t8gujsahgg93"
          },
          "opportunityId": {
            "type": "string",
            "description": "Opportunity Id",
            "example": "hTlkh7t8gujsahgg93"
          }
        },
        "required": [
          "templateId",
          "userId",
          "locationId",
          "contactId"
        ],
        "title": "SendDocumentFromPublicApiBodyDto"
      },
      "SendTemplateResponseDto": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success status",
            "example": true
          },
          "links": {
            "description": "Links for all recipients",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "referenceId": {
                  "type": "string",
                  "description": "Reference ID",
                  "example": "550e8400-e29b-41d4-a716-446655440000"
                },
                "documentId": {
                  "type": "string",
                  "description": "Document ID",
                  "example": "c1e87a91-93b2-4b78-821f-85cf0e1f925b"
                },
                "recipientId": {
                  "type": "string",
                  "description": "Recipient ID",
                  "example": "u240JcS0E5qE0ziHnwMm"
                },
                "entityName": {
                  "type": "string",
                  "enum": [
                    "contacts",
                    "users"
                  ],
                  "description": "Entity name that the recipient belongs to",
                  "example": "contacts"
                },
                "recipientCategory": {
                  "type": "string",
                  "enum": [
                    "recipient",
                    "cc",
                    "bcc"
                  ],
                  "description": "Recipient category (recipient, cc, or bcc)",
                  "example": "recipient"
                },
                "documentRevision": {
                  "type": "number",
                  "description": "Document revision number",
                  "example": 1
                },
                "createdBy": {
                  "type": "string",
                  "description": "Created by user ID",
                  "example": "b6d8fa28-1112-4dc7-b9d2-f22b75a477ea"
                },
                "deleted": {
                  "type": "boolean",
                  "description": "Whether the document is deleted",
                  "example": false
                }
              },
              "required": [
                "referenceId",
                "documentId",
                "recipientId",
                "entityName",
                "recipientCategory",
                "documentRevision",
                "createdBy",
                "deleted"
              ],
              "title": "ProposalEstimateLinksDto"
            }
          }
        },
        "required": [
          "success",
          "links"
        ],
        "title": "SendTemplateResponseDto"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/proposals/templates/send' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "templateId": "hTlkh7t8gujsahgg93",
  "userId": "hTlkh7t8gujsahgg93",
  "sendDocument": true,
  "locationId": "hTlkh7t8gujsahgg93",
  "contactId": "hTlkh7t8gujsahgg93",
  "opportunityId": "hTlkh7t8gujsahgg93"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "templateId": "hTlkh7t8gujsahgg93",
      "userId": "hTlkh7t8gujsahgg93",
      "sendDocument": true,
      "locationId": "hTlkh7t8gujsahgg93",
      "contactId": "hTlkh7t8gujsahgg93",
      "opportunityId": "hTlkh7t8gujsahgg93"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/proposals/templates/send', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/proposals/templates/send"

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

payload = {
    "templateId": "hTlkh7t8gujsahgg93",
    "userId": "hTlkh7t8gujsahgg93",
    "sendDocument": true,
    "locationId": "hTlkh7t8gujsahgg93",
    "contactId": "hTlkh7t8gujsahgg93",
    "opportunityId": "hTlkh7t8gujsahgg93"
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/proposals/templates/send',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "templateId": "hTlkh7t8gujsahgg93",
  "userId": "hTlkh7t8gujsahgg93",
  "sendDocument": true,
  "locationId": "hTlkh7t8gujsahgg93",
  "contactId": "hTlkh7t8gujsahgg93",
  "opportunityId": "hTlkh7t8gujsahgg93"
}',
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/proposals/templates/send")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"templateId\":\"hTlkh7t8gujsahgg93\",\"userId\":\"hTlkh7t8gujsahgg93\",\"sendDocument\":true,\"locationId\":\"hTlkh7t8gujsahgg93\",\"contactId\":\"hTlkh7t8gujsahgg93\",\"opportunityId\":\"hTlkh7t8gujsahgg93\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/proposals/templates/send"
  payload := strings.NewReader(`{
  "templateId": "hTlkh7t8gujsahgg93",
  "userId": "hTlkh7t8gujsahgg93",
  "sendDocument": true,
  "locationId": "hTlkh7t8gujsahgg93",
  "contactId": "hTlkh7t8gujsahgg93",
  "opportunityId": "hTlkh7t8gujsahgg93"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  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/proposals/templates/send")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"
request["Content-Type"] = "application/json"
request.body = '{
  "templateId": "hTlkh7t8gujsahgg93",
  "userId": "hTlkh7t8gujsahgg93",
  "sendDocument": true,
  "locationId": "hTlkh7t8gujsahgg93",
  "contactId": "hTlkh7t8gujsahgg93",
  "opportunityId": "hTlkh7t8gujsahgg93"
}'

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$body = '{
  "templateId": "hTlkh7t8gujsahgg93",
  "userId": "hTlkh7t8gujsahgg93",
  "sendDocument": true,
  "locationId": "hTlkh7t8gujsahgg93",
  "contactId": "hTlkh7t8gujsahgg93",
  "opportunityId": "hTlkh7t8gujsahgg93"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/proposals/templates/send' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
