# Create notification

POST https://services.leadconnectorhq.com/calendars/{calendarId}/notifications

Create Calendar notifications, either one or multiple. All notification settings must be for single calendar only

## Authentication

Send `Authorization: Bearer <token>` using:

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

## Parameters

### Header Parameters

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

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `calendarId` | string | Yes | Calendar ID |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/calendars/{calendarId}/notifications": {
      "post": {
        "summary": "Create notification",
        "operationId": "createNotification",
        "description": "Create Calendar notifications, either one or multiple. All notification settings must be for single calendar only",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "calendarId",
            "required": true,
            "in": "path",
            "schema": {
              "type": "string",
              "example": "ocQHyuzHvysMo5N5VsXc"
            },
            "description": "Calendar ID"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateNotificationDto"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateNotificationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "calendars/events.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": {
      "CreateNotificationDto": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "receiverType": {
              "type": "string",
              "description": "notification recipient type",
              "enum": [
                "contact",
                "guest",
                "assignedUser",
                "emails",
                "phoneNumbers",
                "business"
              ],
              "example": "user"
            },
            "channel": {
              "type": "string",
              "description": "Notification channel",
              "enum": [
                "email",
                "inApp",
                "sms",
                "whatsapp"
              ],
              "example": "email"
            },
            "notificationType": {
              "type": "string",
              "description": "Notification type",
              "enum": [
                "booked",
                "confirmation",
                "cancellation",
                "reminder",
                "followup",
                "reschedule"
              ],
              "example": "confirmation"
            },
            "isActive": {
              "type": "boolean",
              "description": "Is the notification active",
              "default": true,
              "example": true
            },
            "templateId": {
              "type": "string",
              "description": "Template ID for email notification. Not necessary for in-App notification",
              "example": "MwPcayliwcdoUFzvbTok"
            },
            "body": {
              "type": "string",
              "description": "Body  for email notification. Not necessary for in-App notification",
              "example": "Your appointment has been confirmed."
            },
            "subject": {
              "type": "string",
              "description": "Subject  for email notification. Not necessary for in-App notification",
              "example": "Appointment Confirmation"
            },
            "afterTime": {
              "description": "Specifies the time after which the follow-up notification should be sent. This is not required for other notification types.",
              "example": [
                {
                  "timeOffset": 1,
                  "unit": "hours"
                }
              ],
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "timeOffset": {
                    "type": "number",
                    "description": "Time offset value for the notification schedule",
                    "example": 1
                  },
                  "unit": {
                    "type": "string",
                    "description": "Unit of time for the offset",
                    "example": "hours"
                  }
                },
                "title": "SchedulesDTO"
              }
            },
            "beforeTime": {
              "description": "Specifies the time before which the reminder notification should be sent. This is not required for other notification types.",
              "example": [
                {
                  "timeOffset": 1,
                  "unit": "hours"
                }
              ],
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "timeOffset": {
                    "type": "number",
                    "description": "Time offset value for the notification schedule",
                    "example": 1
                  },
                  "unit": {
                    "type": "string",
                    "description": "Unit of time for the offset",
                    "example": "hours"
                  }
                },
                "title": "SchedulesDTO"
              }
            },
            "additionalEmailIds": {
              "description": "Additional email addresses to receive notifications.",
              "example": [
                "example1@email.com",
                "example2@email.com"
              ],
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "additionalPhoneNumbers": {
              "description": "Additional phone numbers to receive notifications.",
              "example": [
                "+919876744444",
                "+919876744445"
              ],
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "selectedUsers": {
              "description": "Selected users for in-App and business email notifications. Supports user IDs and special keyword \"sub_account_admin\"",
              "example": [
                "userId1",
                "userId2",
                "sub_account_admin"
              ],
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "fromAddress": {
              "type": "string",
              "description": "from address for email notification",
              "example": "notifications@example.com"
            },
            "fromName": {
              "type": "string",
              "description": "from name for email/sms notification",
              "example": "Acme Scheduling"
            },
            "fromNumber": {
              "type": "string",
              "description": "from number for sms notification",
              "example": "+15551234567"
            }
          },
          "required": [
            "receiverType",
            "channel",
            "notificationType"
          ],
          "title": "CreateCalendarNotificationDTO"
        }
      },
      "CreateNotificationResponse": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "_id": {
              "type": "string",
              "description": "Notification ID",
              "example": "629a5d0a8c3f2b001f3d4e5a"
            },
            "receiverType": {
              "type": "string",
              "example": "contact",
              "enum": [
                "contact",
                "guest",
                "assignedUser",
                "emails",
                "phoneNumbers",
                "business"
              ],
              "description": "Notification recipient type"
            },
            "additionalEmailIds": {
              "example": [
                "example1@email.com",
                "example2@email.com"
              ],
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Additional email addresses to receive notifications"
            },
            "additionalPhoneNumbers": {
              "example": [
                "+919876744444",
                "+919876744445"
              ],
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Additional phone numbers to receive notifications"
            },
            "channel": {
              "type": "string",
              "example": "email",
              "enum": [
                "email",
                "inApp",
                "sms",
                "whatsapp"
              ],
              "description": "Notification channel"
            },
            "notificationType": {
              "type": "string",
              "example": "confirmation",
              "enum": [
                "booked",
                "confirmation",
                "cancellation",
                "reminder",
                "followup",
                "reschedule"
              ],
              "description": "Notification type"
            },
            "isActive": {
              "type": "boolean",
              "example": true,
              "description": "Whether the notification is active"
            },
            "additionalWhatsappNumbers": {
              "example": [
                "+919876744444",
                "+919876744445"
              ],
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Additional WhatsApp numbers to receive notifications"
            },
            "templateId": {
              "type": "string",
              "example": "0as9d8as0d",
              "description": "Template ID for the notification"
            },
            "body": {
              "type": "string",
              "example": "This is a test notification",
              "description": "Notification body content"
            },
            "subject": {
              "type": "string",
              "example": "Test Notification",
              "description": "Notification subject line"
            },
            "afterTime": {
              "example": [
                {
                  "timeOffset": 1,
                  "unit": "hours"
                }
              ],
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "timeOffset": {
                    "type": "number",
                    "description": "Time offset value for the notification schedule",
                    "example": 1
                  },
                  "unit": {
                    "type": "string",
                    "description": "Unit of time for the offset",
                    "example": "hours"
                  }
                },
                "title": "SchedulesDTO"
              },
              "description": "Time schedules after which follow-up notifications are sent"
            },
            "beforeTime": {
              "example": [
                {
                  "timeOffset": 1,
                  "unit": "hours"
                }
              ],
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "timeOffset": {
                    "type": "number",
                    "description": "Time offset value for the notification schedule",
                    "example": 1
                  },
                  "unit": {
                    "type": "string",
                    "description": "Unit of time for the offset",
                    "example": "hours"
                  }
                },
                "title": "SchedulesDTO"
              },
              "description": "Time schedules before which reminder notifications are sent"
            },
            "selectedUsers": {
              "example": [
                "user1",
                "user2"
              ],
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "Selected user IDs for the notification"
            },
            "deleted": {
              "type": "boolean",
              "example": false,
              "description": "Whether the notification is deleted"
            }
          },
          "title": "CalendarNotificationResponseDTO"
        }
      },
      "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/<calendarId>/notifications' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3' \
  -H 'Content-Type: application/json' \
  --data-raw '[
  {
    "receiverType": "user",
    "channel": "email",
    "notificationType": "confirmation",
    "isActive": true,
    "templateId": "MwPcayliwcdoUFzvbTok",
    "body": "Your appointment has been confirmed.",
    "subject": "Appointment Confirmation",
    "afterTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "beforeTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "additionalEmailIds": [
      "example1@email.com",
      "example2@email.com"
    ],
    "additionalPhoneNumbers": [
      "+919876744444",
      "+919876744445"
    ],
    "selectedUsers": [
      "userId1",
      "userId2",
      "sub_account_admin"
    ],
    "fromAddress": "notifications@example.com",
    "fromName": "Acme Scheduling",
    "fromNumber": "+15551234567"
  }
]'
```

**Node.js**

```javascript
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify([
      {
        "receiverType": "user",
        "channel": "email",
        "notificationType": "confirmation",
        "isActive": true,
        "templateId": "MwPcayliwcdoUFzvbTok",
        "body": "Your appointment has been confirmed.",
        "subject": "Appointment Confirmation",
        "afterTime": [
          {
            "timeOffset": 1,
            "unit": "hours"
          }
        ],
        "beforeTime": [
          {
            "timeOffset": 1,
            "unit": "hours"
          }
        ],
        "additionalEmailIds": [
          "example1@email.com",
          "example2@email.com"
        ],
        "additionalPhoneNumbers": [
          "+919876744444",
          "+919876744445"
        ],
        "selectedUsers": [
          "userId1",
          "userId2",
          "sub_account_admin"
        ],
        "fromAddress": "notifications@example.com",
        "fromName": "Acme Scheduling",
        "fromNumber": "+15551234567"
      }
  ])
};

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

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/calendars/{calendarId}/notifications"

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

payload = [
    {
        "receiverType": "user",
        "channel": "email",
        "notificationType": "confirmation",
        "isActive": true,
        "templateId": "MwPcayliwcdoUFzvbTok",
        "body": "Your appointment has been confirmed.",
        "subject": "Appointment Confirmation",
        "afterTime": [
            {
                "timeOffset": 1,
                "unit": "hours"
            }
        ],
        "beforeTime": [
            {
                "timeOffset": 1,
                "unit": "hours"
            }
        ],
        "additionalEmailIds": [
            "example1@email.com",
            "example2@email.com"
        ],
        "additionalPhoneNumbers": [
            "+919876744444",
            "+919876744445"
        ],
        "selectedUsers": [
            "userId1",
            "userId2",
            "sub_account_admin"
        ],
        "fromAddress": "notifications@example.com",
        "fromName": "Acme Scheduling",
        "fromNumber": "+15551234567"
    }
]

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/<calendarId>/notifications',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => '[
  {
    "receiverType": "user",
    "channel": "email",
    "notificationType": "confirmation",
    "isActive": true,
    "templateId": "MwPcayliwcdoUFzvbTok",
    "body": "Your appointment has been confirmed.",
    "subject": "Appointment Confirmation",
    "afterTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "beforeTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "additionalEmailIds": [
      "example1@email.com",
      "example2@email.com"
    ],
    "additionalPhoneNumbers": [
      "+919876744444",
      "+919876744445"
    ],
    "selectedUsers": [
      "userId1",
      "userId2",
      "sub_account_admin"
    ],
    "fromAddress": "notifications@example.com",
    "fromName": "Acme Scheduling",
    "fromNumber": "+15551234567"
  }
]',
]);

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

**Java**

```java
HttpResponse<String> response = Unirest
  .post("https://services.leadconnectorhq.com/calendars/<calendarId>/notifications")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .header("Content-Type", "application/json")
  .body("[{\"receiverType\":\"user\",\"channel\":\"email\",\"notificationType\":\"confirmation\",\"isActive\":true,\"templateId\":\"MwPcayliwcdoUFzvbTok\",\"body\":\"Your appointment has been confirmed.\",\"subject\":\"Appointment Confirmation\",\"afterTime\":[{\"timeOffset\":1,\"unit\":\"hours\"}],\"beforeTime\":[{\"timeOffset\":1,\"unit\":\"hours\"}],\"additionalEmailIds\":[\"example1@email.com\",\"example2@email.com\"],\"additionalPhoneNumbers\":[\"+919876744444\",\"+919876744445\"],\"selectedUsers\":[\"userId1\",\"userId2\",\"sub_account_admin\"],\"fromAddress\":\"notifications@example.com\",\"fromName\":\"Acme Scheduling\",\"fromNumber\":\"+15551234567\"}]")
  .asString();
```

**Go**

```go
package main

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

func main() {
  url := "https://services.leadconnectorhq.com/calendars/<calendarId>/notifications"
  payload := strings.NewReader(`[
  {
    "receiverType": "user",
    "channel": "email",
    "notificationType": "confirmation",
    "isActive": true,
    "templateId": "MwPcayliwcdoUFzvbTok",
    "body": "Your appointment has been confirmed.",
    "subject": "Appointment Confirmation",
    "afterTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "beforeTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "additionalEmailIds": [
      "example1@email.com",
      "example2@email.com"
    ],
    "additionalPhoneNumbers": [
      "+919876744444",
      "+919876744445"
    ],
    "selectedUsers": [
      "userId1",
      "userId2",
      "sub_account_admin"
    ],
    "fromAddress": "notifications@example.com",
    "fromName": "Acme Scheduling",
    "fromNumber": "+15551234567"
  }
]`)
  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/<calendarId>/notifications")

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 = '[
  {
    "receiverType": "user",
    "channel": "email",
    "notificationType": "confirmation",
    "isActive": true,
    "templateId": "MwPcayliwcdoUFzvbTok",
    "body": "Your appointment has been confirmed.",
    "subject": "Appointment Confirmation",
    "afterTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "beforeTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "additionalEmailIds": [
      "example1@email.com",
      "example2@email.com"
    ],
    "additionalPhoneNumbers": [
      "+919876744444",
      "+919876744445"
    ],
    "selectedUsers": [
      "userId1",
      "userId2",
      "sub_account_admin"
    ],
    "fromAddress": "notifications@example.com",
    "fromName": "Acme Scheduling",
    "fromNumber": "+15551234567"
  }
]'

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

**PowerShell**

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

$body = '[
  {
    "receiverType": "user",
    "channel": "email",
    "notificationType": "confirmation",
    "isActive": true,
    "templateId": "MwPcayliwcdoUFzvbTok",
    "body": "Your appointment has been confirmed.",
    "subject": "Appointment Confirmation",
    "afterTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "beforeTime": [
      {
        "timeOffset": 1,
        "unit": "hours"
      }
    ],
    "additionalEmailIds": [
      "example1@email.com",
      "example2@email.com"
    ],
    "additionalPhoneNumbers": [
      "+919876744444",
      "+919876744445"
    ],
    "selectedUsers": [
      "userId1",
      "userId2",
      "sub_account_admin"
    ],
    "fromAddress": "notifications@example.com",
    "fromName": "Acme Scheduling",
    "fromNumber": "+15551234567"
  }
]'

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