# Get Service Booking by ID

GET https://services.leadconnectorhq.com/calendars/services/bookings/{bookingId}

Get a specific service booking by ID

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `bookingId` | string | Yes | Unique Service Booking ID |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/calendars/services/bookings/{bookingId}": {
      "get": {
        "summary": "Get Service Booking by ID",
        "operationId": "getServiceBookingById",
        "description": "Get a specific service booking by ID",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "bookingId",
            "required": true,
            "in": "path",
            "description": "Unique Service Booking ID",
            "schema": {
              "example": "IkqiJlXJ7o9h61tCHHod",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceBookingResponseDTO"
                }
              }
            }
          },
          "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/events.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": {
      "ServiceBookingResponseDTO": {
        "type": "object",
        "properties": {
          "bookingId": {
            "type": "string",
            "description": "Booking ID",
            "example": "7NkT25Vor1v4aQatFsv2"
          },
          "locationId": {
            "type": "string",
            "description": "Location ID",
            "example": "0007BWpSzSwfiuSl0tR2"
          },
          "contactId": {
            "type": "string",
            "description": "Contact ID",
            "example": "9NkT25Vor1v4aQatFsv2"
          },
          "serviceLocationId": {
            "type": "string",
            "description": "Service Location ID",
            "example": "65e5f6dfacf123513228d384"
          },
          "title": {
            "type": "string",
            "description": "Service Booking Title",
            "example": "John Doe - Hair Styling"
          },
          "startTime": {
            "type": "string",
            "description": "Start Time",
            "example": "2023-09-25T16:00:00+05:30"
          },
          "endTime": {
            "type": "string",
            "description": "End Time",
            "example": "2023-09-25T16:30:00+05:30"
          },
          "services": {
            "description": "Services",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Service ID",
                  "example": "68e5f6dfacf123513228d384"
                },
                "serviceCategoryId": {
                  "type": "string",
                  "description": "Service Category ID",
                  "example": "3c4d5e6f7890123456789abc"
                },
                "serviceStaffId": {
                  "type": "string",
                  "description": "Service Staff ID",
                  "example": "7NkT25Vor1v4aQatFsv2"
                },
                "serviceStartTime": {
                  "type": "string",
                  "description": "Service Start Time",
                  "example": "2023-09-25T16:00:00+05:30"
                },
                "serviceEndTime": {
                  "type": "string",
                  "description": "Service End Time",
                  "example": "2023-09-25T16:30:00+05:30"
                },
                "serviceResources": {
                  "description": "Service Resources",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Resource ID",
                        "example": "6985f6dfacf123513228d384"
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "title": "ServiceResourceDTO"
                  },
                  "example": [
                    {
                      "id": "6985f6dfacf123513228d384"
                    }
                  ]
                },
                "serviceAddOns": {
                  "description": "Service Add-ons",
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "description": "Add-on ID",
                        "example": "6985f6dfacf123513228d384"
                      },
                      "quantity": {
                        "type": "number",
                        "description": "Add-on quantity",
                        "example": 2
                      }
                    },
                    "required": [
                      "id"
                    ],
                    "title": "ServiceAddOnResponseDTO"
                  },
                  "example": [
                    {
                      "id": "6985f6dfacf123513228d384"
                    }
                  ]
                }
              },
              "required": [
                "id",
                "serviceCategoryId",
                "serviceStaffId",
                "serviceStartTime",
                "serviceEndTime"
              ],
              "title": "ServiceDTO"
            },
            "example": [
              {
                "id": "68e5f6dfacf123513228d384",
                "serviceCategoryId": "3c4d5e6f7890123456789abc",
                "serviceStaffId": "7NkT25Vor1v4aQatFsv2",
                "serviceStartTime": "2023-09-25T16:00:00+05:30",
                "serviceEndTime": "2023-09-25T16:30:00+05:30"
              }
            ]
          },
          "timezone": {
            "type": "string",
            "description": "Timezone",
            "example": "America/New_York"
          },
          "status": {
            "type": "string",
            "description": "Status",
            "example": "confirmed"
          },
          "deleted": {
            "type": "boolean",
            "description": "Tells if the booking is deleted",
            "example": false
          },
          "dateAdded": {
            "type": "string",
            "description": "Date Added",
            "example": "2023-09-25T16:00:00+05:30"
          },
          "dateUpdated": {
            "type": "string",
            "description": "Date Updated",
            "example": "2023-09-25T16:00:00+05:30"
          },
          "createdBy": {
            "description": "Booking booked by metadata",
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "userId": {
                    "type": "string",
                    "description": "The ID of the user who created or updated the appointment",
                    "example": "7NkT25Vor1v4aQatFsv2"
                  },
                  "source": {
                    "type": "string",
                    "description": "The source of the appointment",
                    "example": "public_api"
                  }
                },
                "required": [
                  "source"
                ],
                "title": "CreatedOrUpdatedBy"
              }
            ],
            "example": {
              "userId": "7NkT25Vor1v4aQatFsv2",
              "source": "public_api"
            }
          },
          "meetingLocation": {
            "type": "string",
            "description": "Meeting Location (If service location is an ask the booker, then the meeting location is used for the booking)",
            "example": "123 Main St, Anytown, USA"
          }
        },
        "required": [
          "bookingId",
          "locationId",
          "contactId",
          "serviceLocationId",
          "title",
          "startTime",
          "endTime",
          "services",
          "timezone",
          "status",
          "deleted",
          "dateAdded",
          "dateUpdated",
          "createdBy"
        ],
        "title": "ServiceBookingResponseDTO"
      },
      "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 GET 'https://services.leadconnectorhq.com/calendars/services/bookings/<bookingId>' \
  -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/calendars/services/bookings/<bookingId>', 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/bookings/{bookingId}"

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

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

**PHP**

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

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/calendars/services/bookings/<bookingId>',
  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/calendars/services/bookings/<bookingId>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/calendars/services/bookings/<bookingId>"
  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/calendars/services/bookings/<bookingId>")

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/calendars/services/bookings/<bookingId>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
