# Create Calendar Resource

POST https://services.leadconnectorhq.com/calendars/resources/{resourceType}

Create calendar resource by resource type (Services V1)

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `resourceType` | string | Yes | Calendar Resource Type |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-07-28"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/calendars/resources/{resourceType}": {
      "post": {
        "summary": "Create Calendar Resource",
        "operationId": "createCalendarResource",
        "description": "Create calendar resource by resource type (Services V1)",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-07-28"
              ]
            }
          },
          {
            "name": "resourceType",
            "required": true,
            "in": "path",
            "description": "Calendar Resource Type",
            "schema": {
              "enum": [
                "equipments",
                "rooms"
              ],
              "type": "string",
              "example": "equipments"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCalendarResourceDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Calendar resource created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CalendarResourceByIdResponseDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "calendars/resources.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": {
      "CreateCalendarResourceDTO": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "Location ID",
            "example": "ocQHyuzHvysMo5N5VsXc"
          },
          "name": {
            "type": "string",
            "description": "Name of the calendar resource",
            "example": "Projector"
          },
          "description": {
            "type": "string",
            "description": "Description of the calendar resource",
            "example": "Main conference room projector"
          },
          "quantity": {
            "type": "number",
            "description": "Quantity of the equipment.",
            "example": 5
          },
          "outOfService": {
            "type": "number",
            "description": "Quantity of the out of service equipment.",
            "example": 1
          },
          "capacity": {
            "type": "number",
            "description": "Capacity of the room.",
            "example": 20
          },
          "calendarIds": {
            "description": "Service calendar IDs to be mapped with the resource.\n\n    One equipment can only be mapped with one service calendar.\n    \nOne room can be mapped with multiple service calendars.",
            "maxItems": 100,
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "Jsj0xnlDDjw0SuvX1J13"
            ]
          }
        },
        "required": [
          "locationId",
          "name",
          "description",
          "quantity",
          "outOfService",
          "capacity",
          "calendarIds"
        ],
        "title": "CreateCalendarResourceDTO"
      },
      "CalendarResourceByIdResponseDTO": {
        "type": "object",
        "properties": {
          "locationId": {
            "type": "string",
            "description": "Location ID of the resource",
            "example": "ocQHyuzHvysMo5N5VsXc"
          },
          "name": {
            "type": "string",
            "description": "Name of the resource",
            "example": "yoga room"
          },
          "resourceType": {
            "type": "string",
            "enum": [
              "equipments",
              "rooms"
            ],
            "description": "Type of the calendar resource",
            "example": "rooms"
          },
          "isActive": {
            "type": "boolean",
            "description": "Whether the resource is active",
            "example": true
          },
          "description": {
            "type": "string",
            "description": "Description of the resource",
            "example": "Spacious yoga studio"
          },
          "quantity": {
            "type": "number",
            "description": "Quantity of the resource",
            "example": 3
          },
          "outOfService": {
            "type": "number",
            "description": "Indicates if the resource is out of service",
            "example": 0
          },
          "capacity": {
            "type": "number",
            "description": "Capacity of the resource",
            "example": 85
          },
          "calendarIds": {
            "description": "Calendar IDs",
            "example": [
              "Jsj0xnlDDjw0SuvX1J13",
              "oCM5feFC86FAAbcO7lJK"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "locationId",
          "name",
          "resourceType",
          "isActive",
          "calendarIds"
        ],
        "title": "CalendarResourceByIdResponseDTO"
      },
      "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"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const body = {
  "locationId": "ocQHyuzHvysMo5N5VsXc",
  "name": "Projector",
  "description": "Main conference room projector",
  "quantity": 5,
  "outOfService": 1,
  "capacity": 20,
  "calendarIds": [
    "Jsj0xnlDDjw0SuvX1J13"
  ]
};

const response = await ghl.calendars.createCalendarResource('<RESOURCETYPE>', body);
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

body = {
    "locationId": "ocQHyuzHvysMo5N5VsXc",
    "name": "Projector",
    "description": "Main conference room projector",
    "quantity": 5,
    "outOfService": 1,
    "capacity": 20,
    "calendarIds": [
        "Jsj0xnlDDjw0SuvX1J13"
    ]
}

response = await client.calendars.create_calendar_resource('<RESOURCETYPE>', body=body)
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$body = [
    'locationId' => 'ocQHyuzHvysMo5N5VsXc',
    'name' => 'Projector',
    'description' => 'Main conference room projector',
    'quantity' => 5,
    'outOfService' => 1,
    'capacity' => 20,
    'calendarIds' => [
        'Jsj0xnlDDjw0SuvX1J13'
    ]
];

$response = $ghl->calendars->createCalendarResource('<RESOURCETYPE>', $body);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X POST 'https://services.leadconnectorhq.com/calendars/resources/<resourceType>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-07-28' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "locationId": "ocQHyuzHvysMo5N5VsXc",
  "name": "Projector",
  "description": "Main conference room projector",
  "quantity": 5,
  "outOfService": 1,
  "capacity": 20,
  "calendarIds": [
    "Jsj0xnlDDjw0SuvX1J13"
  ]
}'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-07-28',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
      "locationId": "ocQHyuzHvysMo5N5VsXc",
      "name": "Projector",
      "description": "Main conference room projector",
      "quantity": 5,
      "outOfService": 1,
      "capacity": 20,
      "calendarIds": [
        "Jsj0xnlDDjw0SuvX1J13"
      ]
  })
};

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/calendars/resources/{resourceType}"

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

payload = {
    "locationId": "ocQHyuzHvysMo5N5VsXc",
    "name": "Projector",
    "description": "Main conference room projector",
    "quantity": 5,
    "outOfService": 1,
    "capacity": 20,
    "calendarIds": [
        "Jsj0xnlDDjw0SuvX1J13"
    ]
}

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/resources/<resourceType>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-07-28',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '{
  "locationId": "ocQHyuzHvysMo5N5VsXc",
  "name": "Projector",
  "description": "Main conference room projector",
  "quantity": 5,
  "outOfService": 1,
  "capacity": 20,
  "calendarIds": [
    "Jsj0xnlDDjw0SuvX1J13"
  ]
}',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/calendars/resources/<resourceType>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-07-28")
  .header("Content-Type", "application/json")
  .body("{\"locationId\":\"ocQHyuzHvysMo5N5VsXc\",\"name\":\"Projector\",\"description\":\"Main conference room projector\",\"quantity\":5,\"outOfService\":1,\"capacity\":20,\"calendarIds\":[\"Jsj0xnlDDjw0SuvX1J13\"]}")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/calendars/resources/<resourceType>"
  payload := strings.NewReader(`{
  "locationId": "ocQHyuzHvysMo5N5VsXc",
  "name": "Projector",
  "description": "Main conference room projector",
  "quantity": 5,
  "outOfService": 1,
  "capacity": 20,
  "calendarIds": [
    "Jsj0xnlDDjw0SuvX1J13"
  ]
}`)
  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/calendars/resources/<resourceType>")

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 = '{
  "locationId": "ocQHyuzHvysMo5N5VsXc",
  "name": "Projector",
  "description": "Main conference room projector",
  "quantity": 5,
  "outOfService": 1,
  "capacity": 20,
  "calendarIds": [
    "Jsj0xnlDDjw0SuvX1J13"
  ]
}'

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

**PowerShell**

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

$body = '{
  "locationId": "ocQHyuzHvysMo5N5VsXc",
  "name": "Projector",
  "description": "Main conference room projector",
  "quantity": 5,
  "outOfService": 1,
  "capacity": 20,
  "calendarIds": [
    "Jsj0xnlDDjw0SuvX1J13"
  ]
}'

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