# Create Service Location

POST https://services.leadconnectorhq.com/calendars/services/locations

Create a new service location

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `calendars.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": {
    "/calendars/services/locations": {
      "post": {
        "summary": "Create Service Location",
        "operationId": "createServiceLocation",
        "description": "Create a new service location",
        "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/CreateServiceLocationDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Service location created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceLocationResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "User not authenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "calendars.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"
      },
      "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": {
      "CreateServiceLocationDTO": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "Location ID",
            "example": "0007BWpSzSwfiuSl0tR2"
          },
          "name": {
            "type": "string",
            "description": "Location name",
            "example": "Midtown Therapy Studio"
          },
          "slug": {
            "type": "string",
            "description": "URL-friendly slug identifier",
            "example": "midtown-therapy-studio"
          },
          "phone": {
            "type": "string",
            "description": "Phone number",
            "example": "+1-212-555-0174"
          },
          "address": {
            "type": "string",
            "description": "Use a full street address when locationType is offline. Use a user-facing label when locationType is ask_booker.",
            "example": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service"
          },
          "coverImage": {
            "type": "string",
            "description": "URL of the cover image for this service location",
            "example": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg"
          },
          "locationType": {
            "type": "string",
            "description": "Location type",
            "example": "offline",
            "enum": [
              "offline",
              "ask_booker"
            ]
          }
        },
        "required": [
          "locationId",
          "name",
          "slug"
        ],
        "title": "CreateServiceLocationDTO"
      },
      "ServiceLocationResponseDTO": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Service Location ID",
            "example": "65e5f6dfacf123513228d384"
          },
          "locationId": {
            "type": "string",
            "description": "Location ID",
            "example": "0007BWpSzSwfiuSl0tR2"
          },
          "name": {
            "type": "string",
            "description": "Location name",
            "example": "Downtown Wellness Center"
          },
          "slug": {
            "type": "string",
            "description": "Unique URL-friendly identifier for the service location",
            "example": "downtown-wellness-center"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether location is active",
            "example": true,
            "default": true
          },
          "isPrivate": {
            "type": "boolean",
            "description": "Whether location is private (not shown publicly)",
            "example": false,
            "default": false
          },
          "coverImage": {
            "type": "string",
            "description": "URL of the cover image displayed for this location",
            "example": "https://storage.example.com/locations/downtown-wellness-center/cover.jpg"
          },
          "locationType": {
            "type": "string",
            "description": "Location type",
            "example": "offline",
            "enum": [
              "offline",
              "ask_booker"
            ]
          },
          "address": {
            "type": "string",
            "description": "Use a full street address when locationType is offline. Use a user-facing label when locationType is ask_booker.",
            "example": "456 Market Street, Suite 200, San Francisco, CA 94105"
          },
          "phone": {
            "type": "string",
            "description": "Contact phone number for the service location",
            "example": "+1-415-555-0198"
          }
        },
        "required": [
          "id",
          "locationId",
          "name",
          "slug"
        ],
        "title": "ServiceLocationResponseDTO"
      },
      "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"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/calendars/services/locations' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "0007BWpSzSwfiuSl0tR2",
  "name": "Midtown Therapy Studio",
  "slug": "midtown-therapy-studio",
  "phone": "+1-212-555-0174",
  "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
  "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
  "locationType": "offline"
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "0007BWpSzSwfiuSl0tR2",
      "name": "Midtown Therapy Studio",
      "slug": "midtown-therapy-studio",
      "phone": "+1-212-555-0174",
      "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
      "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
      "locationType": "offline"
  })
};

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/calendars/services/locations"

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

payload = {
    "locationId": "0007BWpSzSwfiuSl0tR2",
    "name": "Midtown Therapy Studio",
    "slug": "midtown-therapy-studio",
    "phone": "+1-212-555-0174",
    "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
    "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
    "locationType": "offline"
}

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/calendars/services/locations',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "0007BWpSzSwfiuSl0tR2",
  "name": "Midtown Therapy Studio",
  "slug": "midtown-therapy-studio",
  "phone": "+1-212-555-0174",
  "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
  "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
  "locationType": "offline"
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/calendars/services/locations")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"0007BWpSzSwfiuSl0tR2\",\"name\":\"Midtown Therapy Studio\",\"slug\":\"midtown-therapy-studio\",\"phone\":\"+1-212-555-0174\",\"address\":\"789 5th Avenue, Floor 3, New York, NY 10022 / Home Service\",\"coverImage\":\"https://storage.example.com/locations/midtown-therapy-studio/cover.jpg\",\"locationType\":\"offline\"}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/calendars/services/locations"
  payload := strings.NewReader(`{
  "locationId": "0007BWpSzSwfiuSl0tR2",
  "name": "Midtown Therapy Studio",
  "slug": "midtown-therapy-studio",
  "phone": "+1-212-555-0174",
  "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
  "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
  "locationType": "offline"
}`)
  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/calendars/services/locations")

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 = '{
  "locationId": "0007BWpSzSwfiuSl0tR2",
  "name": "Midtown Therapy Studio",
  "slug": "midtown-therapy-studio",
  "phone": "+1-212-555-0174",
  "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
  "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
  "locationType": "offline"
}'

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

**PowerShell**

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

$body = '{
  "locationId": "0007BWpSzSwfiuSl0tR2",
  "name": "Midtown Therapy Studio",
  "slug": "midtown-therapy-studio",
  "phone": "+1-212-555-0174",
  "address": "789 5th Avenue, Floor 3, New York, NY 10022 / Home Service",
  "coverImage": "https://storage.example.com/locations/midtown-therapy-studio/cover.jpg",
  "locationType": "offline"
}'

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