# Create Business

POST https://services.leadconnectorhq.com/businesses/

Create Business

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `businesses.write`

## 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": {
    "/businesses/": {
      "post": {
        "summary": "Create Business",
        "operationId": "createBusiness",
        "description": "Create Business",
        "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/CreateBusinessDto"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UpdateBusinessResponseDto"
                }
              }
            }
          },
          "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": [
              "businesses.write"
            ]
          }
        ]
      }
    }
  },
  "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"
      }
    },
    "schemas": {
      "CreateBusinessDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "example": "Microsoft"
          },
          "locationId": {
            "type": "string",
            "example": "5DP4iH6HLkQsiKESj6rh"
          },
          "phone": {
            "type": "string",
            "example": "+18832327657"
          },
          "email": {
            "type": "string",
            "example": "john@deo.com"
          },
          "website": {
            "type": "string",
            "example": "www.xyz.com"
          },
          "address": {
            "type": "string",
            "example": "street adress"
          },
          "city": {
            "type": "string",
            "example": "new york"
          },
          "postalCode": {
            "type": "string",
            "example": "12312312"
          },
          "state": {
            "type": "string",
            "example": "new york"
          },
          "country": {
            "type": "string",
            "example": "us"
          },
          "description": {
            "type": "string",
            "example": "business description"
          }
        },
        "required": [
          "name",
          "locationId"
        ],
        "title": "CreateBusinessDto"
      },
      "UpdateBusinessResponseDto": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Success Value",
            "example": true
          },
          "buiseness": {
            "description": "Business Response",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Business Id",
                    "example": "63771dcac1116f0e21de8e12"
                  },
                  "name": {
                    "type": "string",
                    "description": "Business Name",
                    "example": "Microsoft"
                  },
                  "phone": {
                    "type": "string",
                    "description": "phone number"
                  },
                  "email": {
                    "type": "string",
                    "description": "email",
                    "example": "abc@microsoft.com"
                  },
                  "website": {
                    "type": "string",
                    "description": "website",
                    "example": "microsoft.com"
                  },
                  "address": {
                    "type": "string",
                    "description": "address"
                  },
                  "city": {
                    "type": "string",
                    "description": "city"
                  },
                  "description": {
                    "type": "string",
                    "description": "description"
                  },
                  "state": {
                    "type": "string",
                    "description": "state"
                  },
                  "postalCode": {
                    "type": "string",
                    "description": "postal code"
                  },
                  "country": {
                    "type": "string",
                    "description": "country",
                    "example": "united states"
                  },
                  "updatedBy": {
                    "description": "updated By",
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {},
                        "title": "BusinessCreatedByOrUpdatedBy"
                      }
                    ]
                  },
                  "locationId": {
                    "type": "string",
                    "description": "locaitonId"
                  },
                  "createdBy": {
                    "description": "Created By",
                    "allOf": [
                      {
                        "type": "object",
                        "properties": {},
                        "title": "BusinessCreatedByOrUpdatedBy"
                      }
                    ]
                  },
                  "createdAt": {
                    "format": "date-time",
                    "type": "string",
                    "description": "Creation Time"
                  },
                  "updatedAt": {
                    "format": "date-time",
                    "type": "string",
                    "description": "Last updation time"
                  }
                },
                "required": [
                  "id",
                  "name",
                  "locationId"
                ],
                "title": "BusinessDto"
              }
            ]
          }
        },
        "required": [
          "success",
          "buiseness"
        ],
        "title": "UpdateBusinessResponseDto"
      },
      "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/businesses/' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "Microsoft",
  "locationId": "5DP4iH6HLkQsiKESj6rh",
  "phone": "+18832327657",
  "email": "john@deo.com",
  "website": "www.xyz.com",
  "address": "street adress",
  "city": "new york",
  "postalCode": "12312312",
  "state": "new york",
  "country": "us",
  "description": "business description"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "name": "Microsoft",
      "locationId": "5DP4iH6HLkQsiKESj6rh",
      "phone": "+18832327657",
      "email": "john@deo.com",
      "website": "www.xyz.com",
      "address": "street adress",
      "city": "new york",
      "postalCode": "12312312",
      "state": "new york",
      "country": "us",
      "description": "business description"
  })
};

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/businesses/"

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

payload = {
    "name": "Microsoft",
    "locationId": "5DP4iH6HLkQsiKESj6rh",
    "phone": "+18832327657",
    "email": "john@deo.com",
    "website": "www.xyz.com",
    "address": "street adress",
    "city": "new york",
    "postalCode": "12312312",
    "state": "new york",
    "country": "us",
    "description": "business description"
}

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/businesses/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "name": "Microsoft",
  "locationId": "5DP4iH6HLkQsiKESj6rh",
  "phone": "+18832327657",
  "email": "john@deo.com",
  "website": "www.xyz.com",
  "address": "street adress",
  "city": "new york",
  "postalCode": "12312312",
  "state": "new york",
  "country": "us",
  "description": "business description"
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/businesses/")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"name\":\"Microsoft\",\"locationId\":\"5DP4iH6HLkQsiKESj6rh\",\"phone\":\"+18832327657\",\"email\":\"john@deo.com\",\"website\":\"www.xyz.com\",\"address\":\"street adress\",\"city\":\"new york\",\"postalCode\":\"12312312\",\"state\":\"new york\",\"country\":\"us\",\"description\":\"business description\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/businesses/"
  payload := strings.NewReader(`{
  "name": "Microsoft",
  "locationId": "5DP4iH6HLkQsiKESj6rh",
  "phone": "+18832327657",
  "email": "john@deo.com",
  "website": "www.xyz.com",
  "address": "street adress",
  "city": "new york",
  "postalCode": "12312312",
  "state": "new york",
  "country": "us",
  "description": "business description"
}`)
  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/businesses/")

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 = '{
  "name": "Microsoft",
  "locationId": "5DP4iH6HLkQsiKESj6rh",
  "phone": "+18832327657",
  "email": "john@deo.com",
  "website": "www.xyz.com",
  "address": "street adress",
  "city": "new york",
  "postalCode": "12312312",
  "state": "new york",
  "country": "us",
  "description": "business description"
}'

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

**PowerShell**

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

$body = '{
  "name": "Microsoft",
  "locationId": "5DP4iH6HLkQsiKESj6rh",
  "phone": "+18832327657",
  "email": "john@deo.com",
  "website": "www.xyz.com",
  "address": "street adress",
  "city": "new york",
  "postalCode": "12312312",
  "state": "new york",
  "country": "us",
  "description": "business description"
}'

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