# Email Verification

POST https://services.leadconnectorhq.com/email/verify

Verify Email

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Location Id, The email verification charges will be deducted from this location (if rebilling is enabled) / company wallet |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-07-28"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/email/verify": {
      "post": {
        "summary": "Email Verification",
        "operationId": "emailVerification",
        "description": "Verify Email",
        "parameters": [
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location Id, The email verification charges will be deducted from this location (if rebilling is enabled) / company wallet",
            "schema": {
              "example": "5DP4iH6HLkQsiKESj6rh",
              "type": "string"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-07-28"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VerificationBodyDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmailVerificationResponse"
                }
              }
            }
          },
          "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": [
              "lc-email.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"
      },
      "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"
      }
    },
    "schemas": {
      "VerificationBodyDto": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "example": "email",
            "enum": [
              "email",
              "contact"
            ],
            "description": "Email Verification type"
          },
          "verify": {
            "type": "string",
            "example": "abc@xyz.com",
            "description": "Email Verification recepient (email address / contactId)"
          }
        },
        "required": [
          "type",
          "verify"
        ],
        "title": "VerificationBodyDto"
      },
      "EmailVerificationResponse": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "reason": {
                "example": [
                  "mailbox_does_not_exist"
                ],
                "description": "Reason for email verification failure",
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "result": {
                "type": "string",
                "example": "undeliverable",
                "enum": [
                  "deliverable",
                  "undeliverable",
                  "do_not_send",
                  "unknown",
                  "catch_all"
                ],
                "description": "Email verification result"
              },
              "risk": {
                "type": "string",
                "example": "low",
                "enum": [
                  "high",
                  "low",
                  "medium",
                  "unknown"
                ],
                "description": "Risk level of email sending to bounce"
              },
              "address": {
                "type": "string",
                "example": "abc@xyz.com",
                "description": "Email address"
              },
              "leadconnectorRecomendation": {
                "example": {
                  "isEmailValid": false
                },
                "description": "Lead Connector email verification recomendation",
                "deprecated": true,
                "allOf": [
                  {
                    "type": "object",
                    "properties": {
                      "isEmailValid": {
                        "type": "boolean",
                        "example": false,
                        "description": "Email verification status",
                        "deprecated": true
                      }
                    },
                    "title": "LeadConnectorRecomandationDto"
                  }
                ]
              }
            },
            "required": [
              "result",
              "risk",
              "address",
              "leadconnectorRecomendation"
            ],
            "title": "EmailVerifiedResponseDto"
          },
          {
            "type": "object",
            "properties": {
              "verified": {
                "type": "boolean",
                "example": false,
                "description": "Email verification not processed"
              },
              "message": {
                "type": "string",
                "example": "Validation is disabled / proper config not found",
                "description": "Email verification failure message"
              },
              "address": {
                "type": "string",
                "example": "abc@xyz.com",
                "description": "Email address"
              }
            },
            "required": [
              "verified"
            ],
            "title": "EmailNotVerifiedResponseDto"
          }
        ]
      },
      "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 POST 'https://services.leadconnectorhq.com/email/verify?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "type": "email",
  "verify": "abc@xyz.com"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-07-28',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "type": "email",
      "verify": "abc@xyz.com"
  })
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/email/verify?locationId=<LOCATIONID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/email/verify"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-07-28"
}

params = {
    "locationId": "<LOCATIONID>"
}

payload = {
    "type": "email",
    "verify": "abc@xyz.com"
}

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/email/verify?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-07-28',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "type": "email",
  "verify": "abc@xyz.com"
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/email/verify?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-07-28")
  .header("Content-Type", "application/json")
  .body("{\"type\":\"email\",\"verify\":\"abc@xyz.com\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/email/verify?locationId=<LOCATIONID>"
  payload := strings.NewReader(`{
  "type": "email",
  "verify": "abc@xyz.com"
}`)
  req, _ := http.NewRequest("POST", url, payload)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-07-28")

  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/email/verify?locationId=<LOCATIONID>")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-07-28"
request["Content-Type"] = "application/json"
request.body = '{
  "type": "email",
  "verify": "abc@xyz.com"
}'

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

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-07-28"
}

$body = '{
  "type": "email",
  "verify": "abc@xyz.com"
}'

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/email/verify?locationId=<LOCATIONID>' -Method 'POST' -Headers $headers -Body $body -ContentType 'application/json'
$response | ConvertTo-Json
```
