# Update Events

> Source: https://truto.one/docs/api-reference/unified-calendar-api/events/update/

`PATCH /unified/calendar/events/{id}`

Resource: **Events** · API: **Unified Calendar API**

## Supported integrations

Google, Google Calendar, Outlook Calendar

## Path parameters

- **`id`** _(string, required)_
  The ID of the resource.

## Query parameters

- **`integrated_account_id`** _(string, required)_
  The ID of the integrated account to use for the request.
- **`truto_response_format`** _(string)_
  The format of the response. - `unified` returns the response with unified mappings applied. - `raw` returns the unprocessed, raw response from the remote API. - `normalized` applies the unified mappings and returns the data in a normalized format. - `stream` returns the response as a stream, which is ideal for transmitting large datasets, files, or binary data. Using streaming mode helps to efficiently handle large payloads or real-time data flows without requiring the entire data to be buffered in memory. Defaults to `unified`.
  Allowed: `unified`, `raw`, `normalized`, `stream`
- **`truto_ignore_remote_data`** _(boolean)_
  Excludes the `remote_data` attribute from the response.
- **`truto_exclude_fields`** _(array<string>)_
  Array of fields to exclude from the response.
- **`remote_query`** _(object)_
  Query parameters to pass to the underlying API without any transformations. Refer [this guide](https://truto.one/docs/api-reference/overview/querying#remote-query-parameters) to see how to structure the query parameters.
- **`send_notifications`** _(string)_
  Allowed: `all`, `external_only`, `none`

## Request body

- **`calendar`** _(object)_
  The calendar associated with the event.
  - **`id`** _(string)_
    The unique identifier of the calendar.
  - **`name`** _(string)_
    The name of the calendar.
- **`start_time`** _(string, required)_
  If providing the start_time, the end_time should also be provided.
- **`end_time`** _(string)_
  If providing the end_time, the start_time should also be provided.
- **`timezone`** _(string)_
  Required if start_time or end_time is provided.
- **`title`** _(string, required)_
  The title of the event.
- **`description`** _(string)_
  The description of the event.
- **`status`** _(string)_
  The status of the event.
  Allowed: `confirmed`, `tentative`, `cancelled`, `draft`
- **`availability`** _(string)_
  The availability of the user during the time period of the event.
  Allowed: `busy`, `free`
- **`visibility`** _(string)_
  The visibility of the event.
  Allowed: `calendar_default`, `public`, `private`
- **`recurrence`** _(array<string>)_
  The recurrence of the event. List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545.
- **`attendees`** _(array<object>)_
  The attendees associated with the event.
  - **`person`** _(object)_
    The person associated with the attendee.
    - **`id`** _(string)_
      The unique identifier of the person.
    - **`name`** _(string)_
      The name of the person.
    - **`emails`** _(array<object>)_
      The emails of the person.
      - **`email`** _(string)_
        The email of the person.
      - **`type`** _(string)_
        The type of the email.
  - **`is_optional`** _(boolean)_
    Indicates if the attendance is optional.
  - **`is_self`** _(boolean)_
    Indicates if the attendee is the authenticated user.
  - **`is_organizer`** _(boolean)_
    Indicates if the attendee is the organizer of the event.
  - **`response`** _(object)_
    The response of the attendee.
    - **`status`** _(string)_
      The status of the response.
      Allowed: `needs_action`, `declined`, `tentative`, `accepted`
    - **`comment`** _(string)_
      The comment of the response.
- **`guests_can_invite_others`** _(boolean)_
  Indicates if guests can invite others to the event.
- **`guests_can_modify`** _(boolean)_
  Indicates if guests can modify the event.
- **`guests_can_see_other_guests`** _(boolean)_
  Indicates if guests can see other guests of the event.
- **`location`** _(object)_
  The location of the event.
  - **`id`** _(string)_
    The unique identifier of the location.
  - **`name`** _(string)_
    The name of the location.
  - **`address`** _(object)_
    - **`street_1`** _(string)_
      The first line of the street address.
    - **`street_2`** _(string)_
      The second line of the street address.
    - **`city`** _(string)_
      The city of the address.
    - **`state`** _(string)_
      The state of the address.
    - **`country`** _(string)_
      The country of the address.
    - **`postal_code`** _(string)_
      The postal code of the address.
  - **`url`** _(string)_
    The URL of the location.
  - **`coordinates`** _(object)_
    - **`latitude`** _(number)_
      The latitude of the location.
    - **`longitude`** _(number)_
      The longitude of the location.
- **`remote_data`** _(object)_
  Any additional data that should be passed as part of the request body. This data is not transformed by Truto and is passed as is to the remote API.

## Response body

- **`id`** _(string, required)_
  The unique identifier of the event.
- **`calendar`** _(object)_
  The calendar associated with the event.
  - **`id`** _(string)_
    The unique identifier of the calendar.
  - **`name`** _(string)_
    The name of the calendar.
- **`title`** _(string, required)_
  The title of the event.
- **`description`** _(string)_
  The description of the event.
- **`location`** _(object)_
  The location of the event.
  - **`id`** _(string)_
    The unique identifier of the location.
  - **`name`** _(string)_
    The name of the location.
  - **`address`** _(object)_
    - **`street_1`** _(string)_
      The first line of the street address.
    - **`street_2`** _(string)_
      The second line of the street address.
    - **`city`** _(string)_
      The city of the address.
    - **`state`** _(string)_
      The state of the address.
    - **`country`** _(string)_
      The country of the address.
    - **`postal_code`** _(string)_
      The postal code of the address.
  - **`url`** _(string)_
    The URL of the location.
  - **`coordinates`** _(object)_
    - **`latitude`** _(number)_
      The latitude of the location.
    - **`longitude`** _(number)_
      The longitude of the location.
- **`timezone`** _(string)_
  The timezone of the event.
- **`start_time`** _(string, required)_
  The date and time when the event starts.
- **`end_time`** _(string)_
  The date and time when the event ends.
- **`status`** _(string)_
  The status of the event.
  Allowed: `confirmed`, `tentative`, `cancelled`, `draft`
- **`attendees`** _(array<object>)_
  The attendees associated with the event.
  - **`person`** _(object)_
    The person associated with the attendee.
    - **`id`** _(string)_
      The unique identifier of the person.
    - **`name`** _(string)_
      The name of the person.
    - **`emails`** _(array<object>)_
      The emails of the person.
      - **`email`** _(string)_
        The email of the person.
      - **`type`** _(string)_
        The type of the email.
  - **`is_optional`** _(boolean)_
    Indicates if the attendance is optional.
  - **`is_self`** _(boolean)_
    Indicates if the attendee is the authenticated user.
  - **`is_organizer`** _(boolean)_
    Indicates if the attendee is the organizer of the event.
  - **`response`** _(object)_
    The response of the attendee.
    - **`status`** _(string)_
      The status of the response.
      Allowed: `needs_action`, `declined`, `tentative`, `accepted`
    - **`comment`** _(string)_
      The comment of the response.
- **`created_by`** _(object)_
  The person who created the event.
  - **`id`** _(string)_
    The unique identifier of the person.
  - **`name`** _(string)_
    The name of the person.
  - **`emails`** _(array<object>)_
    The emails of the person.
    - **`email`** _(string)_
      The email of the person.
    - **`type`** _(string)_
      The type of the email.
- **`organized_by`** _(object)_
  The person who created the event.
  - **`id`** _(string)_
    The unique identifier of the person.
  - **`name`** _(string)_
    The name of the person.
  - **`emails`** _(array<object>)_
    The emails of the person.
    - **`email`** _(string)_
      The email of the person.
    - **`type`** _(string)_
      The type of the email.
- **`type`** _(string)_
  The type of the event.
  Allowed: `default`, `out_of_office`, `focus_time`, `working_location`
- **`availability`** _(string)_
  The availability of the user during the time period of the event.
  Allowed: `busy`, `free`
- **`visibility`** _(string)_
  The visibility of the event.
  Allowed: `calendar_default`, `public`, `private`
- **`identifiers`** _(object)_
  The identifiers associated with the event.
  - **`ical_uid`** _(string)_
    The iCalendar UID of the event.
  - **`ical_sequence`** _(string)_
    The iCalendar sequence of the event.
- **`is_locked`** _(boolean)_
  Indicates if the event is locked and cannot be modified.
- **`urls`** _(object)_
  The URLs associated with the event.
  - **`url`** _(string)_
    The URL of the event.
  - **`type`** _(string)_
    The type of the URL.
- **`is_recurring`** _(boolean)_
  Indicates if the event is recurring.
- **`recurrence`** _(array<string>)_
  The recurrence of the event. List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545.
- **`parent_event`** _(object)_
  The parent event of a recurring event.
  - **`id`** _(string)_
    The unique identifier of the parent event.
- **`has_attachments`** _(boolean)_
  Indicates if the event has attachments.
- **`attachments`** _(array<object>)_
  The attachments associated with the event.
  - **`id`** _(string)_
    The unique identifier of the attachment.
  - **`name`** _(string)_
    The name of the attachment.
  - **`mime_type`** _(string)_
    The MIME type of the attachment.
  - **`url`** _(string)_
    The URL of the attachment.
  - **`created_at`** _(string)_
    The date when the attachment was created.
  - **`updated_at`** _(string)_
    The date when the attachment was updated.
- **`guests_can_invite_others`** _(boolean)_
  Indicates if guests can invite others to the event.
- **`guests_can_modify`** _(boolean)_
  Indicates if guests can modify the event.
- **`guests_can_see_other_guests`** _(boolean)_
  Indicates if guests can see other guests of the event.
- **`event_type`** _(object)_
  The event type object associated with the event.
  - **`id`** _(string)_
    The unique identifier of the event type.
- **`created_at`** _(string)_
  The date when the event was created.
- **`updated_at`** _(string)_
  The date when the event was updated.
- **`remote_data`** _(object)_
  Raw data returned from the remote API call.

## Code examples

### curl

```bash
curl -X PATCH 'https://api.truto.one/unified/calendar/events/{id}?integrated_account_id=<integrated_account_id>' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "calendar": {},
  "start_time": "your_start_time",
  "end_time": "your_end_time",
  "timezone": "your_timezone",
  "title": "your_title",
  "description": "your_description",
  "status": "confirmed",
  "availability": "busy",
  "visibility": "calendar_default",
  "recurrence": [],
  "attendees": [],
  "guests_can_invite_others": true,
  "guests_can_modify": true,
  "guests_can_see_other_guests": true,
  "location": {},
  "remote_data": {}
}'
```

### JavaScript

```javascript
const integratedAccountId = '<integrated_account_id>';

const body = {
  "calendar": {},
  "start_time": "your_start_time",
  "end_time": "your_end_time",
  "timezone": "your_timezone",
  "title": "your_title",
  "description": "your_description",
  "status": "confirmed",
  "availability": "busy",
  "visibility": "calendar_default",
  "recurrence": [],
  "attendees": [],
  "guests_can_invite_others": true,
  "guests_can_modify": true,
  "guests_can_see_other_guests": true,
  "location": {},
  "remote_data": {}
};

const response = await fetch(`https://api.truto.one/unified/calendar/events/{id}?integrated_account_id=${integratedAccountId}`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/unified/calendar/events/{id}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
    "integrated_account_id": "<integrated_account_id>"
}
payload = {
    "calendar": {},
    "start_time": "your_start_time",
    "end_time": "your_end_time",
    "timezone": "your_timezone",
    "title": "your_title",
    "description": "your_description",
    "status": "confirmed",
    "availability": "busy",
    "visibility": "calendar_default",
    "recurrence": [],
    "attendees": [],
    "guests_can_invite_others": True,
    "guests_can_modify": True,
    "guests_can_see_other_guests": True,
    "location": {},
    "remote_data": {}
}

response = requests.patch(url, headers=headers, params=params, json=payload)
print(response.json())
```

### Truto TS SDK

```typescript
import Truto from '@truto/truto-ts-sdk';

const truto = new Truto({
  token: '<your_api_token>',
});

const result = await truto.unifiedApi.update(
  'calendar',
  'events',
  '<resource_id>',
  {
  "calendar": {},
  "start_time": "your_start_time",
  "end_time": "your_end_time",
  "timezone": "your_timezone",
  "title": "your_title",
  "description": "your_description",
  "status": "confirmed",
  "availability": "busy",
  "visibility": "calendar_default",
  "recurrence": [],
  "attendees": [],
  "guests_can_invite_others": true,
  "guests_can_modify": true,
  "guests_can_see_other_guests": true,
  "location": {},
  "remote_data": {}
},
  { integrated_account_id: '<integrated_account_id>' }
);

console.log(result);
```

### Truto Python SDK

```python
import asyncio
from truto_python_sdk import TrutoApi

truto_api = TrutoApi(token="<your_api_token>")

async def main():
    result = await truto_api.unified_api.update(
        "calendar",
        "events",
        "<resource_id>",
        {
        "calendar": {},
        "start_time": "your_start_time",
        "end_time": "your_end_time",
        "timezone": "your_timezone",
        "title": "your_title",
        "description": "your_description",
        "status": "confirmed",
        "availability": "busy",
        "visibility": "calendar_default",
        "recurrence": [],
        "attendees": [],
        "guests_can_invite_others": True,
        "guests_can_modify": True,
        "guests_can_see_other_guests": True,
        "location": {},
        "remote_data": {}
},
        {"integrated_account_id": "<integrated_account_id>"}
    )
    print(result)

asyncio.run(main())
```
