# Get Contacts By BusinessId

GET https://services.leadconnectorhq.com/contacts/business/{businessId}

Get Contacts By BusinessId

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `businessId` | string | Yes | Business Id |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | string | No | Maximum number of records per page (up to 100, default 25) |
| `locationId` | string | Yes | Location Id |
| `skip` | string | No | Number of records to skip |
| `query` | string | No | Search query (name, email, phone) |
| `startAfter` | array | No | Cursor for pagination (comma-separated name,id pair) |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/contacts/business/{businessId}": {
      "get": {
        "summary": "Get Contacts By BusinessId",
        "operationId": "getContactsByBusinessid",
        "description": "Get Contacts By BusinessId",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "businessId",
            "required": true,
            "in": "path",
            "description": "Business Id",
            "schema": {
              "type": "string",
              "example": "641c094001436dbc2081e642"
            }
          },
          {
            "name": "limit",
            "required": false,
            "in": "query",
            "description": "Maximum number of records per page (up to 100, default 25)",
            "schema": {
              "type": "string",
              "example": "10"
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Location Id",
            "schema": {
              "type": "string",
              "example": "5DP4iH6HLkQsiKESj6rh"
            }
          },
          {
            "name": "skip",
            "required": false,
            "in": "query",
            "description": "Number of records to skip",
            "schema": {
              "type": "string",
              "example": "10"
            }
          },
          {
            "name": "query",
            "required": false,
            "in": "query",
            "description": "Search query (name, email, phone)",
            "schema": {
              "type": "string",
              "example": "John"
            }
          },
          {
            "name": "startAfter",
            "required": false,
            "in": "query",
            "description": "Cursor for pagination (comma-separated name,id pair)",
            "oneOf": [
              {
                "type": "string",
                "example": "eleanor sakai,xurJiljRhcxpwRYXbxUU"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "example": [
                  "eleanor sakai",
                  "xurJiljRhcxpwRYXbxUU"
                ]
              }
            ],
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ContactsSearchSuccessfulResponseDto"
                }
              }
            }
          },
          "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": [
          {
            "bearer": [
              "contacts.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": {
      "ContactsSearchSuccessfulResponseDto": {
        "type": "object",
        "properties": {
          "contacts": {
            "description": "List of contacts associated with the business",
            "example": [
              {
                "id": "ocQHyuzHvysMo5N5VsXc",
                "locationId": "C2QujeCh8ZnC7al2InWR",
                "email": "JohnDeo@gmail.com",
                "country": "DE",
                "source": "xyz form",
                "dateAdded": "2020-10-29T09:31:30.255Z"
              }
            ],
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique identifier of the contact",
                  "example": "ocQHyuzHvysMo5N5VsXc"
                },
                "locationId": {
                  "type": "string",
                  "description": "Location Id the contact belongs to",
                  "example": "C2QujeCh8ZnC7al2InWR"
                },
                "email": {
                  "type": "string",
                  "description": "Email address of the contact",
                  "example": "JohnDeo@gmail.com"
                },
                "timezone": {
                  "type": "string",
                  "description": "Timezone of the contact",
                  "example": "Asia/Calcutta"
                },
                "country": {
                  "type": "string",
                  "description": "Country of the contact",
                  "example": "DE"
                },
                "source": {
                  "type": "string",
                  "description": "Source from which the contact was created",
                  "example": "xyz form"
                },
                "dateAdded": {
                  "type": "string",
                  "description": "Date and time the contact was added (ISO 8601)",
                  "example": "2020-10-29T09:31:30.255Z"
                },
                "customFields": {
                  "description": "List of custom field values for the contact",
                  "example": [
                    {
                      "id": "6dvNaf7VhkQ9snc5vnjJ",
                      "value": "My Text"
                    }
                  ],
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Unique identifier of the custom field",
                        "example": "MgobCB14YMVKuE4Ka8p1"
                      },
                      "value": {
                        "type": "string",
                        "description": "Value of the custom field",
                        "example": "name"
                      }
                    },
                    "title": "CustomFieldSchema"
                  }
                },
                "tags": {
                  "description": "List of tags associated with the contact",
                  "example": [
                    "nisi sint commodo amet",
                    "consequat"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "businessId": {
                  "type": "string",
                  "description": "Business Id the contact is associated with",
                  "example": "641c094001436dbc2081e642"
                },
                "attributions": {
                  "description": "List of attribution sources for the contact",
                  "example": [
                    {
                      "url": "Trigger Link",
                      "campaign": "Summer Sale"
                    }
                  ],
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "url": {
                        "type": "string",
                        "description": "Attribution source type",
                        "example": "Trigger Link"
                      },
                      "campaign": {
                        "type": "string",
                        "description": "Campaign name",
                        "example": "Summer Sale 2024",
                        "nullable": true
                      },
                      "utmSource": {
                        "type": "string",
                        "description": "UTM source parameter",
                        "example": "google",
                        "nullable": true
                      },
                      "utmMedium": {
                        "type": "string",
                        "description": "UTM medium parameter",
                        "example": "cpc",
                        "nullable": true
                      },
                      "utmContent": {
                        "type": "string",
                        "description": "UTM content parameter",
                        "example": "ad_variation_1",
                        "nullable": true
                      },
                      "referrer": {
                        "type": "string",
                        "description": "Referrer URL",
                        "example": "https://www.google.com",
                        "nullable": true
                      },
                      "campaignId": {
                        "type": "string",
                        "description": "Campaign Id",
                        "example": "641c094001436dbc2081e642",
                        "nullable": true
                      },
                      "fbclid": {
                        "type": "string",
                        "description": "Facebook click Id",
                        "example": "fb.1.1674748390986.1171287961",
                        "nullable": true
                      },
                      "gclid": {
                        "type": "string",
                        "description": "Google click Id",
                        "example": "CjOKCQjwnNyUBhCZARISAI9AYIFtNnIcWcYGIOQINz_ZoFI5SSLRRugSoPZoiEu27IZBY£1-MAIWmEaAo2VEALW_WCB",
                        "nullable": true
                      },
                      "msclikid": {
                        "type": "string",
                        "description": "Microsoft click Id",
                        "example": "MS!AzEREREDJKSJD",
                        "nullable": true
                      },
                      "dclid": {
                        "type": "string",
                        "description": "DoubleClick click Id",
                        "example": "EAIaIQobChMIw",
                        "nullable": true
                      },
                      "fbc": {
                        "type": "string",
                        "description": "Facebook browser Id",
                        "example": "fb.1.1674748390986.1171287961",
                        "nullable": true
                      },
                      "fbp": {
                        "type": "string",
                        "description": "Facebook pixel Id",
                        "example": "fb. 1.1674748390986.1171287961",
                        "nullable": true
                      },
                      "fbEventId": {
                        "type": "string",
                        "description": "Facebook event Id",
                        "example": "Mozilla/5.0",
                        "nullable": true
                      },
                      "userAgent": {
                        "type": "string",
                        "description": "Browser user agent string",
                        "example": "Mozilla/5.0",
                        "nullable": true
                      },
                      "ip": {
                        "type": "string",
                        "description": "IP address of the visitor",
                        "example": "58.111.106.198",
                        "nullable": true
                      },
                      "medium": {
                        "type": "string",
                        "description": "Attribution medium (e.g. survey, funnel)",
                        "example": "survey",
                        "nullable": true
                      },
                      "mediumId": {
                        "type": "string",
                        "description": "Id of the attribution medium",
                        "example": "FglfHAn30PRwsZVyQlKp",
                        "nullable": true
                      }
                    },
                    "required": [
                      "url"
                    ],
                    "title": "AttributionSource"
                  }
                },
                "followers": {
                  "description": "List of user Ids following this contact",
                  "example": [
                    "641c094001436dbc2081e642"
                  ],
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              },
              "title": "ContactsSearchSchema"
            }
          },
          "count": {
            "type": "number",
            "description": "Total number of contacts matching the query",
            "example": 10
          }
        },
        "title": "ContactsSearchSuccessfulResponseDto"
      },
      "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/contacts/business/<businessId>?locationId=<LOCATIONID>' \
  -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/contacts/business/<businessId>?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/contacts/business/{businessId}"

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

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

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/contacts/business/<businessId>?locationId=<LOCATIONID>',
  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/contacts/business/<businessId>?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/contacts/business/<businessId>?locationId=<LOCATIONID>"
  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/contacts/business/<businessId>?locationId=<LOCATIONID>")

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/contacts/business/<businessId>?locationId=<LOCATIONID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
