# Update a calendar

> **PUT** `https://api.us.nylas.com/v3/grants/{grant_id}/calendars/{calendar_id}`

Source: https://developer.nylas.com/docs/reference/api/calendar/put-calendars-id/

Updates the specified calendar.

When you make a `PUT` request, Nylas replaces all data in the nested object with the information
included in your request. For more information, see
[Updating objects](/docs/reference/api/#updating-objects).

**Authentication:** NYLAS_API_KEY, ACCESS_TOKEN

## Parameters

### Query parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `select` | string | No | Specify fields that you want Nylas to return, as a comma-separated list (for example, `select=id,updated_at`). This allows you to receive only the portion of object data that you're interested in. You can use `select` to optimize response size and reduce latency by limiting queries to only the information that you need. |

### Path parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `grant_id` | string | Yes | ID of the grant to access. Use `/me/` to refer to the grant associated with an access token. |
| `calendar_id` | string | Yes | ID of the calendar to access. You can use `primary` to refer to the primary calendar associated with a grant. Nylas recommends you URL-encode this field, or you might receive a [`404` error](/docs/api/errors/400-response/) if the ID contains special characters (for example, `#`). |

## Request body

Content-Type: application/json

- `description` (string) - (Not supported for iCloud or EWS) A brief description of the calendar.
- `hex_color` (string) - (Not supported for iCloud or EWS) The background color of the calendar, in hexadecimal format (for
example, `#0099EE`). When empty, Nylas uses the default background color.

You can set or modify this value using a `PUT` request only.
- `hex_foreground_color` (string) - (Google only) The foreground color of the calendar, in hexadecimal format (for example, `#0099EE`).
When empty, Nylas uses the default foreground color.

You can modify this value using a `PUT` request only.
- `location` (string) - (Not supported for iCloud or EWS) The geographic location of the calendar, as free-form text.
- `metadata` (object) - The metadata associated with the object. For more information, see
[Metadata](/docs/reference/api/#metadata).
- `name` (string) - The name of the calendar.

Microsoft doesn't allow you to update the name of a user's primary calendar.
- `timezone` (string) - (Google and virtual calendars only) An [IANA timezone database](https://en.wikipedia.org/wiki/Tz_database)
formatted string (for example, `America/New_York`).
- `notetaker` (object)
  - `meeting_settings` (object) - A collection of settings for the Notetaker bot.
    - `action_items` (boolean) - When `true`, Notetaker generates a list of action items from the meeting. If `action_items` is
`true`, `video_recording`, `audio_recording`, and `transcription` must also be `true`.
    - `action_items_settings` (object)
      - `custom_instructions` (string) - A custom prompt to pass to Nylas' AI model and specify settings for the list of action items
it generates. `action_items` must be `true` to use this field.
    - `audio_recording` (boolean) - When `true`, Notetaker records the meeting's audio.
    - `leave_after_silence_seconds` (integer) - The number of seconds of silence after which the Notetaker bot automatically leaves
the meeting. This helps end recordings when meetings have concluded but participants
haven't disconnected the call. Must be between 10 and 3600 seconds (1 hour).
    - `summary` (boolean) - When `true`, Notetaker generates a summary of the meeting. If `summary` is `true`,
`video_recording`, `audio_recording`, and `transcription` must also be `true`.
    - `summary_settings` (object)
      - `custom_instructions` (string) - A custom prompt to pass to Nylas' AI model and specify settings for the summary it generates.
`summary` must be `true` to use this field.
    - `transcription` (boolean) - When `true`, Notetaker transcribes the meeting's audio. If `transcription` is `true`,
`video_recording` and `audio_recording` must also be `true`.
    - `video_recording` (boolean) - When `true`, Notetaker records the meeting's video.
    - `transcription_settings` (object) - Optional settings that tune how Notetaker transcribes audio. `transcription` must be
`true` for these settings to take effect. Provide any combination of the fields below.

The fields fall into two independent groups:

- **Language hints** (`expected_languages`, `fallback_language`) constrain automatic
  language detection. This declares the languages you expect; it does not translate
  transcripts or force the recording into a specific language.
- **Keyword hints** (`keywords`, `use_speaker_names_as_keywords`) bias recognition toward
  domain-specific terms such as names, acronyms, and product names.

Set on individual Notetakers, on calendar sync, or on event sync. When set on a calendar,
events inherit the value unless the event's own request overrides it. Send `null` or `{}`
to clear inherited settings and return to default transcription behavior.

See [Set transcription languages](/docs/v3/notetaker/#set-transcription-languages) for
supported language codes and validation rules.
      - `expected_languages` (array) - Language codes the audio is expected to contain. Optional. When provided, it must
contain at least one supported code and cannot be `null` or empty. When omitted,
transcription considers all supported languages.
      - `fallback_language` (string) - Language to use if Notetaker does not detect one of the `expected_languages`. Optional.
When `expected_languages` is set, the fallback must be one of those codes. When
`expected_languages` is omitted, transcription considers all supported languages and
the fallback may be any supported code. When `fallback_language` is omitted, the
transcriber auto-detects the language. The field is not stored, so responses do not
return it.
      - `keywords` (array) - Domain-specific terms that bias transcription toward recognizing them correctly, such
as names, acronyms, and product names. Optional. Up to 200 terms; each term must be
1 to 200 characters and cannot contain control characters. Cannot be `null`.
      - `use_speaker_names_as_keywords` (boolean) - When `true`, Notetaker adds known speaker names to the keyword set so they are
transcribed accurately. Optional. Cannot be `null`.
  - `name` (string) - The display name for the Notetaker bot.
  - `rules` (object) - Rules for when the Notetaker bot should join a meeting.
    - `event_selection` (array) - Specify the types of events Notetaker should join.
- "all": Join all events with meeting links.
- "external": Join all events where the host's domain differs from any participant's domain.
- "internal": Join all events where the host's domain matches all participants' domains.
- "own_events": Join all events where the user is the host.
- "participant_only": Join all events where the user is a participant, but not the host.
    - `participant_filter` (object) - Specify filters to determine which events Notetaker should join, based on the number of
participants. If you don't specify any settings, a Notetaker joins meetings regardless of
participants.
      - `participants_gte` (integer) - Join all events where the number of participants is greater than or equal to the specified
value.
      - `participants_lte` (integer) - Join all events where the number of participants is less than or equal to the specified
value.

## Responses

### 200 - Calendar Response

- `request_id` (string) - The request ID.
- `data` (object) - A Calendar object.
  - `description` (string) - (Not supported for iCloud or EWS) A brief description of the calendar.
  - `grant_id` (string) - The ID of grant for the connected user.
  - `hex_color` (string) - (Not supported for iCloud or EWS) The background color of the calendar, in hexadecimal format (for
example, `#0099EE`). When empty, Nylas uses the default background color.

You can set or modify this value using a `PUT` request only.
  - `hex_foreground_color` (string) - (Google only) The foreground color of the calendar, in hexadecimal format (for example, `#0099EE`).
When empty, Nylas uses the default foreground color.

You can modify this value using a `PUT` request only.
  - `id` (string) - A globally unique object identifier for Microsoft accounts. An email address for Google accounts.
  - `is_owned_by_user` (boolean) - If `true`, indicates that the user owns the calendar. This field can't be modified once set.
  - `is_primary` (boolean) - If `true`, indicates that the calendar is the primary for the grant.
  - `location` (string) - (Not supported for iCloud or EWS) The geographic location of the calendar, as free-form text.
  - `metadata` (object) - The metadata associated with the object. For more information, see
[Metadata](/docs/reference/api/#metadata).
  - `name` (string) - The name of the calendar.
  - `object` (string) - The type of object.
  - `read_only` (boolean) - Set by the provider. If `true`, indicates that the calendar is read-only.

If the calendar is read-only, all of its events have `read_only` set to `true`. This field _cannot_
be modified.
  - `timezone` (string) - (Google and virtual calendars only) An [IANA timezone database](https://en.wikipedia.org/wiki/Tz_database)
formatted string (for example, `America/New_York`).
  - `notetaker` (object)
    - `meeting_settings` (object) - A collection of settings for the Notetaker bot.
      - `action_items` (boolean) - When `true`, Notetaker generates a list of action items from the meeting. If `action_items` is
`true`, `video_recording`, `audio_recording`, and `transcription` must also be `true`.
      - `action_items_settings` (object)
        - `custom_instructions` (string) - A custom prompt to pass to Nylas' AI model and specify settings for the list of action items
it generates. `action_items` must be `true` to use this field.
      - `audio_recording` (boolean) - When `true`, Notetaker records the meeting's audio.
      - `leave_after_silence_seconds` (integer) - The number of seconds of silence after which the Notetaker bot automatically leaves
the meeting. This helps end recordings when meetings have concluded but participants
haven't disconnected the call. Must be between 10 and 3600 seconds (1 hour).
      - `summary` (boolean) - When `true`, Notetaker generates a summary of the meeting. If `summary` is `true`,
`video_recording`, `audio_recording`, and `transcription` must also be `true`.
      - `summary_settings` (object)
        - `custom_instructions` (string) - A custom prompt to pass to Nylas' AI model and specify settings for the summary it generates.
`summary` must be `true` to use this field.
      - `transcription` (boolean) - When `true`, Notetaker transcribes the meeting's audio. If `transcription` is `true`,
`video_recording` and `audio_recording` must also be `true`.
      - `video_recording` (boolean) - When `true`, Notetaker records the meeting's video.
      - `transcription_settings` (object) - Optional settings that tune how Notetaker transcribes audio. `transcription` must be
`true` for these settings to take effect. Provide any combination of the fields below.

The fields fall into two independent groups:

- **Language hints** (`expected_languages`, `fallback_language`) constrain automatic
  language detection. This declares the languages you expect; it does not translate
  transcripts or force the recording into a specific language.
- **Keyword hints** (`keywords`, `use_speaker_names_as_keywords`) bias recognition toward
  domain-specific terms such as names, acronyms, and product names.

Set on individual Notetakers, on calendar sync, or on event sync. When set on a calendar,
events inherit the value unless the event's own request overrides it. Send `null` or `{}`
to clear inherited settings and return to default transcription behavior.

See [Set transcription languages](/docs/v3/notetaker/#set-transcription-languages) for
supported language codes and validation rules.
        - `expected_languages` (array) - Language codes the audio is expected to contain. Optional. When provided, it must
contain at least one supported code and cannot be `null` or empty. When omitted,
transcription considers all supported languages.
        - `fallback_language` (string) - Language to use if Notetaker does not detect one of the `expected_languages`. Optional.
When `expected_languages` is set, the fallback must be one of those codes. When
`expected_languages` is omitted, transcription considers all supported languages and
the fallback may be any supported code. When `fallback_language` is omitted, the
transcriber auto-detects the language. The field is not stored, so responses do not
return it.
        - `keywords` (array) - Domain-specific terms that bias transcription toward recognizing them correctly, such
as names, acronyms, and product names. Optional. Up to 200 terms; each term must be
1 to 200 characters and cannot contain control characters. Cannot be `null`.
        - `use_speaker_names_as_keywords` (boolean) - When `true`, Notetaker adds known speaker names to the keyword set so they are
transcribed accurately. Optional. Cannot be `null`.
    - `name` (string) - The display name for the Notetaker bot.
    - `rules` (object) - Rules for when the Notetaker bot should join a meeting.
      - `event_selection` (array) - Specify the types of events Notetaker should join.
- "all": Join all events with meeting links.
- "external": Join all events where the host's domain differs from any participant's domain.
- "internal": Join all events where the host's domain matches all participants' domains.
- "own_events": Join all events where the user is the host.
- "participant_only": Join all events where the user is a participant, but not the host.
      - `participant_filter` (object) - Specify filters to determine which events Notetaker should join, based on the number of
participants. If you don't specify any settings, a Notetaker joins meetings regardless of
participants.
        - `participants_gte` (integer) - Join all events where the number of participants is greater than or equal to the specified
value.
        - `participants_lte` (integer) - Join all events where the number of participants is less than or equal to the specified
value.

### 400 - Bad Request

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 401 - Unauthorized

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The error from the provider.

### 404 - Not Found

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.
  - `provider_error` (object) - The raw error from the provider, if available
    - `code` (string)
    - `message` (string)

### 429 - Rate Limit

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

### 504 - Provider Failure

- `request_id` (string) - The request ID.
- `error` (object) - The response error object.
  - `type` (string) - The error type.
  - `message` (string) - The error message.

## Code samples

### cURL

```bash
curl --compressed --request PUT \
  --url 'https://api.us.nylas.com/v3/grants/<NYLAS_GRANT_ID>/calendars/<CALENDAR_ID>' \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <NYLAS_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "My New Calendar",
    "description": "Description of my new calendar",
    "location": "Location description",
    "timezone": "America/Los_Angeles"
  }'
```

### Node.js SDK

```javascript
import Nylas from "nylas";

const nylas = new Nylas({
  apiKey: "<NYLAS_API_KEY>",
  apiUri: "<NYLAS_API_URI>",
});

async function updateCalendar() {
  try {
    const calendar = await nylas.calendars.update({
      identifier: "<NYLAS_GRANT_ID>",
      calendarId: "<CALENDAR_ID>",
      requestBody: {
        name: "Nylas DevRel Calendar",
        description: "Nylas Developer Relations",
      },
    });

    console.log("Updated Calendar:", calendar);
  } catch (error) {
    console.error("Error to update calendar:", error);
  }
}

updateCalendar();

```

### Python SDK

```python
from nylas import Client

nylas = Client(
    "<NYLAS_API_KEY>",
    "<NYLAS_API_URI>"
)

grant_id = "<NYLAS_GRANT_ID>"

calendar = nylas.calendars.update(
    grant_id,
    calendar_id="<CALENDAR_ID>",
    request_body={
      "name": 'Nylas DevRel Calendar',
      "description": 'Nylas Developer Relations'
    }
)

print(calendar)
```

### Ruby SDK

```ruby
require 'nylas'	

nylas = Nylas::Client.new(api_key: "<NYLAS_API_KEY>")

request_body = {
	"name": "\"New Test Calendar (changed)\"",
	"description": "\"this calendar has been updated!\"",
}

calendar, _request_ids = nylas.calendars.update(
		identifier: "<NYLAS_GRANT_ID>", 
		calendar_id: "<CALENDAR_ID", 
		request_body: request_body)

puts calendar
```

### Java SDK

```java
import com.nylas.NylasClient;
import com.nylas.models.*;

public class UpdateCalendar {
  public static void main(String[] args) throws NylasSdkTimeoutError, NylasApiError {
    NylasClient nylas = new NylasClient.Builder("<NYLAS_API_KEY>").build();
      
    UpdateCalendarRequest requestBody = new UpdateCalendarRequest.Builder().
        name("My New Calendar").
        description("Description of my new calendar").
        location("Location description").
        timezone("America/Los_Angeles").
        build();
      
    Response<Calendar> calendar = nylas.calendars().update(
        "<CALENDAR_ID>",
        "<CALENDAR_ID>", 
        requestBody);

    System.out.println(calendar.getData());        
  }
}
```

### Kotlin SDK

```kotlin
import com.nylas.NylasClient
import com.nylas.models.*
import com.nylas.resources.Calendars

fun main(args: Array<String>) {
  val nylas: NylasClient = NylasClient(apiKey = "<NYLAS_API_KEY>")

  val requestBody = UpdateCalendarRequest.Builder().
      name("\"New Test Calendar (changed)\"").
      description("\"this calendar has been updated!\"").
      location("Location description").
      timezone("America/Los_Angeles").
      build()

  val calendar: Response<Calendar> = nylas.calendars().update(
      "<CALENDAR_ID>",
      "<CALENDAR_ID>",
      requestBody)
      
  print(calendar.data)
}
```
