# Calendars

## Get All Calendars

<mark style="color:blue;">`GET`</mark> `https://api.pyas.io/google/calendars`

Gets all calendars that a user has access to.

#### Query Parameters

| Name                                        | Type   | Description                                                                       |
| ------------------------------------------- | ------ | --------------------------------------------------------------------------------- |
| accountId<mark style="color:red;">\*</mark> | String | The user's Pyas account id. This is returned when you connect an account to Pyas. |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| x-api-key<mark style="color:red;">\*</mark> | String | API key     |

{% tabs %}
{% tab title="200: OK Successfully retrieved list of calendars" %}

```json
{
    "success": true,
    "data": {
        "calendars": [
            {
                "kind": "calendar#calendarListEntry",
                "etag": "\"000000000000000000000\"",
                "id": "some-user@gmail.com",
                "summary": "some-user@gmail.com",
                "timeZone": "UTC",
                "colorId": "14",
                "backgroundColor": "#9fe1e7",
                "foregroundColor": "#000000",
                "selected": true,
                "accessRole": "owner",
                "defaultReminders": [
                    {
                        "method": "popup",
                        "minutes": 10
                    }
                ],
                "notificationSettings": {
                    "notifications": [
                        {
                            "type": "eventCreation",
                            "method": "email"
                        },
                        {
                            "type": "eventChange",
                            "method": "email"
                        },
                        {
                            "type": "eventCancellation",
                            "method": "email"
                        },
                        {
                            "type": "eventResponse",
                            "method": "email"
                        }
                    ]
                },
                "primary": true,
                "conferenceProperties": {
                    "allowedConferenceSolutionTypes": [
                        "hangoutsMeet"
                    ]
                }
            },
            {
                "kind": "calendar#calendarListEntry",
                "etag": "\"111111111111111111111111\"",
                "id": "en.usa#holiday@group.v.calendar.google.com",
                "summary": "Holidays in United States",
                "description": "Holidays and Observances in United States",
                "timeZone": "UTC",
                "colorId": "8",
                "backgroundColor": "#16a765",
                "foregroundColor": "#000000",
                "selected": true,
                "accessRole": "reader",
                "defaultReminders": [],
                "conferenceProperties": {
                    "allowedConferenceSolutionTypes": [
                        "hangoutsMeet"
                    ]
                }
            },
            {
                "kind": "calendar#calendarListEntry",
                "etag": "\"1662297009786000\"",
                "id": "addressbook#contacts@group.v.calendar.google.com",
                "summary": "Birthdays",
                "description": "Displays birthdays, anniversaries, and other event dates of people in Google Contacts.",
                "timeZone": "UTC",
                "colorId": "13",
                "backgroundColor": "#92e1c0",
                "foregroundColor": "#000000",
                "selected": true,
                "accessRole": "reader",
                "defaultReminders": [],
                "conferenceProperties": {
                    "allowedConferenceSolutionTypes": [
                        "hangoutsMeet"
                    ]
                }
            }
        ]
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid/missing API key" %}

```json
{
    "error": "Unauthorized. Invalid API key."
}
```

{% endtab %}

{% tab title="400: Bad Request Missing account id" %}

```json
{
    "errors": [
        {
            "msg": "an account id is required.",
            "param": "accountId",
            "location": "query"
        }
    ]
}
```

{% endtab %}

{% tab title="404: Not Found Account Not Found. Invalid accountId" %}

```json
{
    "success": false,
    "error": "Invalid account id. Account Not Found",
    "code": 404
}
```

{% endtab %}
{% endtabs %}

## Get a Calendar by ID

<mark style="color:blue;">`GET`</mark> `https://api.pyas.io/google/calendars/{id}`&#x20;

Gets a calendar by id

#### Path Parameters

| Name                                   | Type   | Description                        |
| -------------------------------------- | ------ | ---------------------------------- |
| {id}<mark style="color:red;">\*</mark> | String | The id of the calendar to retrieve |

#### Query Parameters

| Name                                        | Type   | Description                                                                      |
| ------------------------------------------- | ------ | -------------------------------------------------------------------------------- |
| accountId<mark style="color:red;">\*</mark> | String | The user's Pyas account id. This is returned when you connect an account to Pyas |

#### Headers

| Name                                        | Type   | Description |
| ------------------------------------------- | ------ | ----------- |
| x-api-key<mark style="color:red;">\*</mark> | String | API key     |

{% tabs %}
{% tab title="200: OK Successfully retrieved the calendar" %}

```json
{
    "success": true,
    "calendar": {
        "kind": "calendar#calendar",
        "etag": "\"000000000000000000\"",
        "id": "some-user@gmail.com",
        "summary": "some-user@gmail.com",
        "timeZone": "UTC",
        "conferenceProperties": {
            "allowedConferenceSolutionTypes": [
                "hangoutsMeet"
            ]
        }
    }
}
```

{% endtab %}

{% tab title="404: Not Found Account Not Found. Invalid accountId" %}

```json
{
    "success": false,
    "error": "Invalid account id. Account Not Found",
    "code": 404
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid/missing API key" %}

```json
{
    "error": "Unauthorized. Invalid API key."
}
```

{% endtab %}

{% tab title="400: Bad Request Missing account id" %}

```json
{
    "errors": [
        {
            "msg": "an account id is required.",
            "param": "accountId",
            "location": "query"
        },
        {
            "msg": "account id must be a string",
            "param": "accountId",
            "location": "query"
        }
    ]
}
```

{% endtab %}

{% tab title="404: Not Found Calendar Not Found" %}

```json
{
    "success": false,
    "error": "Not Found",
    "code": 404
}
```

{% endtab %}
{% endtabs %}
