# Calendars

You can use the /v2/users/:user_id/calendars endpoints to manage the calendars of your users.

This API is an extension of the Users API, that's why all url are prefixed with /users/:user_id/. You can refer to the User API reference to have more informations about user creation.

# The calendar object

GET method return the calendarList objects, which contains calendars of the user. Every calendar might contain several subcalendars.

Attributes

  • sync_suggestions Boolean
    Property of `calendarList` object, if set true - synchronize suggested dates with calendars. Default is true.
  • _id ObjectId
    The `_id` of calendarList.
  • belongs_to ObjectId
    The `_id` of user of calendarList.

###Calendar properties

Attributes

  • access_broken Boolean
    Connection status, false by default.

  • _id ObjectId
    The `_id` of calendar.
  • primary Boolean
    The user can have several calendars, but only one will be the main calendar.
  • name String
    The name of calendar defined by user.
  • source String
    The source of calendar. It might be Vyte, Google, Office 365 and other sources.
  • source_id String
    The `_id` of source of the calendar.
  • subcalendars Array
    Array of `subcalendar` Objects.
  • ###Subcalendar properties

    Attributes

    • _id ObjectId
      The `_id` of calendar.
    • name String
      The name of calendar defined by user.
    • source String
      The source of calendar. It might be Vyte, Google, Office 365 and other sources.
    • source_id String
      The `_id` of source of the calendar.
    • primary Boolean
      The user can have several subcalendars, but only one will be the main calendar.
    • display Boolean
      If set true, the subcalendar is visible in users calendar.
    • busy Boolean
      If set true, the subcalendar will be displayed as busy.
    • bcolor String
      Defines the background colour for the subcalendar.
    • fcolor String
      Defines the font colour for the subcalendar.
    • writable Boolean
      If set true, the user can add and delete events.
    • THE CALENDAR_LIST OBJECT

      { "sync_suggestions": true,
      	"_id": "604b9727a7a147a3195f72d2",
      	"calendars":
      		[ { "access_broken": false,
      		"primary": false,
      		"_id": "604b9727a7a14726d85f72d6",
      		"name": "Vyte",
      		"source": "vyte_user",
      		"source_id": "604b97276793f6001ef96d7e",
      		"subcalendars": 
      			[
      			{"name": "My Events",
      			"source": "vyte_user",
      			"source_id": "604b97276793f6001ef96d7e",
      			"display": false,
      			"busy": true,
      			"color_id": "d",
      			"bcolor": "#c1defa",
      			"primary": false,
      			"writable": false
      			},
      			{"name": "My Events OPTIONS",
      			"source": "vyte_user_suggestions",
      			"source_id": "604b97276793f6001ef96d7e",
      			"display": false,
      			"busy": true,
      			"color_id": "d",
      			"bcolor": "#c1defa",
      			"primary": false,
      			"writable": false
      			}
      			]
       			},
      		{ "access_broken": true,
      		"primary": true,
      		"_id": "604b9727a7a147d4d45f72d1",
      		"source": "google",
      		"name": "testuser@gmail.com",
      		"token": "604b97276793f6001ef96d7f",
      		"subcalendars": [] } ],
      		"belongs_to": "604b97276793f6001ef96d7e",
      		"updatedAt": "2021-03-12T16:30:32.230Z",
      		"createdAt": "2021-03-12T16:30:31.835Z",
      		"__v": 1 }
      
      

      # Retrieve the calendars of a user

      ENDPOINT Authorization apiKey

      GET /v2/users/:user_id/calendars HTTP/1.1
      

      Path parameters

      • user_id string

        The id of the user whose calendars you want to retrieve.

      Query parameters

      No parameters.

        Returns

        An CalendarList object if there is no error.

        CODE SAMPLE

        curl \
        --request GET 'https://api.vyte.in/v2/users/5f2d28fb1e0662e70071d46b/calendars' \
        --header 'Authorization: vkjvi2bvfo54ssbybmcts0x42z1sbzm6t0mot8trh8i03reno0' \
        

        RESPONSE SAMPLE

        { "sync_suggestions": true,
        	"_id": "604b9727a7a147a3195f72d2",
        	"calendars":
        		[ { "access_broken": false,
        		"primary": false,
        		"_id": "604b9727a7a14726d85f72d6",
        		"name": "Vyte",
        		"source": "vyte_user",
        		"source_id": "604b97276793f6001ef96d7e",
        		"subcalendars": 
        			[
        			{"name": "My Events",
        			"source": "vyte_user",
        			"source_id": "604b97276793f6001ef96d7e",
        			"display": false,
        			"busy": true,
        			"color_id": "d",
        			"bcolor": "#c1defa",
        			"primary": false,
        			"writable": false
        			},
        			{"name": "My Events OPTIONS",
        			"source": "vyte_user_suggestions",
        			"source_id": "604b97276793f6001ef96d7e",
        			"display": false,
        			"busy": true,
        			"color_id": "d",
        			"bcolor": "#c1defa",
        			"primary": false,
        			"writable": false
        			}
        			]
         			},
        		{ "access_broken": true,
        		"primary": true,
        		"_id": "604b9727a7a147d4d45f72d1",
        		"source": "google",
        		"name": "testuser@gmail.com",
        		"token": "604b97276793f6001ef96d7f",
        		"subcalendars": [] } ],
        		"belongs_to": "604b97276793f6001ef96d7e",
        		"updatedAt": "2021-03-12T16:30:32.230Z",
        		"createdAt": "2021-03-12T16:30:31.835Z",
        		"__v": 1 }
        
        

        # Update the calendars of a user

        ENDPOINT Authorization apiKey

        PUT /v2/users/:user_id/calendars HTTP/1.1
        

        Path parameters

        • user_id string

          The id of the user whose calendar you want to update.

        Query parameters

        No parameters.

          Body parameters

          • name String
            The name of calendar or sub calendar defined by user.
          • primary Boolean
            The user can have several calendars or subcalendars, but only one will be the main calendar.
          • display Boolean
            If set true, the subcalendar is visible in users calendar.
          • busy Boolean
            If set true, the subcalendar will be displayed as busy.
          • sync_suggestions Boolean
            Property of `calendarList` object, if set true - synchronize suggested dates with calendars. Default is true.

          Returns

          The updated CalendarList object if no error occurred.

          CODE SAMPLE

          curl --request PUT 'https://api.vyte.in/v2/users/5f2d4abf1e0662386371d475/calendars' \
          --header 'Authorization: vkjvi2bvfo54ssbybmcts0x42z1sbzm6t0mot8trh8i03reno0' \
          --header 'Content-Type: application/json' \
          --data-raw '
          { 
             "sync_suggestions": false,
             "calendars": [
                {"access_broken": false,
                 "primary": false},
                 {"access_broken": false,
                  "primary": false}
                  ]
                          }'
          

          # Delete the calendar of a user

          ENDPOINT Authorization apiKey

          DELETE /v2/users/:user_id/calendars/:calendar_id HTTP/1.1
          

          Path parameters

          • user_id string

            The id of the user whose availability you want to delete.

          • calendar_id string

            The id of the calendar whick you want to delete.

          Query parameters

          No parameters.

            Returns

            Returns the status if there is no error, and returns an error otherwise.

            curl --request DELETE 'https://api.vyte.in/v2/users/5f2d4abf1e0662386371d475/calendars/5f2d4abf1e0662386371d466' \
            --header 'Authorization: vkjvi2bvfo54ssbybmcts0x42z1sbzm6t0mot8trh8i03reno0'
            

            RESPONSE SAMPLE

            {
              "n": 1,
              "ok": 1
            }