# User preference

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

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 preferences object

Attributes

  • belongs_to ObjectId

    The _id of user, whom these preferences belong to.

  • log.push_enabled boolean

    Preferences contains two types of preferences: email and push. Par default push are set to false. If log.push_enabled set to true, all push settings set to true.

  • prefs hash

    Here you can define user's preferences.

    + Show child attributes

    • prefs. email hash

      Settings for email.

      + Show child attributes

      • prefs.email. attending boolean

        Whether or not you will get emails about attendees of events you have created. Default is true.

      • prefs.email. declined boolean

        Whether or not you will get emails about declining events you have created. Default is true.

      • prefs.email. event_cancelled boolean

        Whether or not you will get emails about cancelling events by other users. Default is true.

      • prefs.email. event_cancelled_admin boolean

        Whether or not you will get emails about cancelling events you have created. Default is true.

      • prefs.email. event_confirmed boolean

        Whether or not you will get emails about confirming events by other users. Default is true.

      • prefs.email. event_confirmed_admin boolean

        Whether or not you will get emails about confirming events you have created and confirmed. Default is true.

      • prefs.email. new_event boolean

        Whether or not you will get emails about new events created by other (but not on your Vyte page). Default is true.

      • prefs.email. new_event_admin boolean

        Whether or not you will get emails about new events created by you. Default is true.

      • prefs.email. new_message boolean

        Whether or not you will get emails about messages for the events you have created or participate in. Default is true.

      • prefs.email. new_suggestion boolean

        Whether or not you will get emails about suggestions for the events you have created or participate in. Default is true.

      • prefs.email. new_suggestions_own boolean

        Whether or not you will get emails about suggestions made by you for the events you have created or participate in. Default is true.

      • prefs.email. vote_update boolean

        Whether or not you will get emails about votes for the events you have created. Default is true.

      • prefs.email. vote_confirmation boolean

        Whether or not you will get emails about votes made by you. Default is false.

      • prefs.email. vyteme_created_admin boolean

        Whether or not you will get emails about events created from your Vyte page. Default is true.

    + Show child attributes

    • prefs. push hash

      Settings for push notifications.

      + Show child attributes

      • prefs.push. attending boolean

        Whether or not you will get push notifications about attendees of events you have created. Default is false.

      • prefs.push. declined boolean

        Whether or not you will get push notifications about declining events you have created. Default is false.

      • prefs.push. event_cancelled boolean

        Whether or not you will get push notifications about cancelling events by other users. Default is false.

      • prefs.push. event_confirmed boolean

        Whether or not you will get push notifications about confirming events by other users. Default is false.

      • prefs.push. new_event boolean

        Whether or not you will get push notifications about new events created by other (but not on your Vyte page). Default is false.

      • prefs.push. new_message boolean

        Whether or not you will get push notifications about messages for the events you have created or participate in. Default is false.

      • prefs.push. new_suggestion boolean

        Whether or not you will get push notifications about suggestions for the events you have created or participate in. Default is false.

      • prefs.push. vote_update boolean

        Whether or not you will get push notifications about votes for the events you have created. Default is false.

      • prefs.push. vyteme_created_admin boolean

        Whether or not you will get push notifications about events created from your Vyte page. Default is false.

THE PREFERENCE OBJECT


{
  "belongs_to": "5f2d70c51e066227db71d493",
  "log":
	  {"push_enabled": true}
  "prefs":
    { "email":
      { "attending": true,
      "declined": true,
      "event_cancelled": true,
      "event_cancelled_admin": true,
      "event_confirmed": true,
      "event_confirmed_admin": true,
      "new_event": true,
      "new_event_admin": true,
      "new_message": true,
      "new_suggestion": true,
      "new_suggestion_own": true,
      "vote_update": true,
      "vote_confirmation": false,
      "vyteme_created_admin": true },
      
    "push":
      { "attending": false,
      "declined": false,
      "event_cancelled": false,
      "event_confirmed": false,
      "new_event": false,
      "new_message": false,
      "new_suggestion": false,
      "vote_update": false,
      "vyteme_created_admin": false } 
        }
      }

# Retrieve or create the preferences of a user

ENDPOINT Authorization apiKey

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

Path parameters

  • user_id string

    The id of the user whose preferences you want to retrieve. If there are no preferences, the object will be created with default settings.

Query parameters

No parameters.

    Returns

    A Prefs object if there is no error. Prefs doesn't contain belongs_to and log.push_enabled properties.

    CODE SAMPLE

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

    RESPONSE SAMPLE

    
    { "email":
          { "attending": true,
          "declined": true,
          "event_cancelled": true,
          "event_cancelled_admin": true,
          "event_confirmed": true,
          "event_confirmed_admin": true,
          "new_event": true,
          "new_event_admin": true,
          "new_message": true,
          "new_suggestion": true,
          "new_suggestion_own": true,
          "vote_update": true,
          "vote_confirmation": false,
          "vyteme_created_admin": true },
          
        "push":
          { "attending": false,
          "declined": false,
          "event_cancelled": false,
          "event_confirmed": false,
          "new_event": false,
          "new_message": false,
          "new_suggestion": false,
          "vote_update": false,
          "vyteme_created_admin": false } 
            }
    
    

    # Update the preferences of a user

    ENDPOINT Authorization apiKey

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

    Path parameters

    • user_id string

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

    Query parameters

    No parameters.

      Body parameters

      • prefs. email hash

        Settings for email.

        + Show child attributes

        • prefs.email. attending boolean

          Whether or not you will get emails about attendees of events you have created. Default is true.

        • prefs.email. declined boolean

          Whether or not you will get emails about declining events you have created. Default is true.

        • prefs.email. event_cancelled boolean

          Whether or not you will get emails about cancelling events by other users. Default is true.

        • prefs.email. event_cancelled_admin boolean

          Whether or not you will get emails about cancelling events you have created. Default is true.

        • prefs.email. event_confirmed boolean

          Whether or not you will get emails about confirming events by other users. Default is true.

        • prefs.email. event_confirmed_admin boolean

          Whether or not you will get emails about confirming events you have created and confirmed. Default is true.

        • prefs.email. new_event boolean

          Whether or not you will get emails about new events created by other (but not on your Vyte page). Default is true.

        • prefs.email. new_event_admin boolean

          Whether or not you will get emails about new events created by you. Default is true.

        • prefs.email. new_message boolean

          Whether or not you will get emails about messages for the events you have created or participate in. Default is true.

        • prefs.email. new_suggestion boolean

          Whether or not you will get emails about suggestions for the events you have created or participate in. Default is true.

        • prefs.email. new_suggestions_own boolean

          Whether or not you will get emails about suggestions made by you for the events you have created or participate in. Default is true.

        • prefs.email. vote_update boolean

          Whether or not you will get emails about votes for the events you have created. Default is true.

        • prefs.email. vote_confirmation boolean

          Whether or not you will get emails about votes made by you. Default is false.

        • prefs.email. vyteme_created_admin boolean

          Whether or not you will get emails about events created from your Vyte page. Default is true.

      + Show child attributes

      • prefs. push hash

        Settings for push notifications.

        + Show child attributes

        • prefs.push. attending boolean

          Whether or not you will get push notifications about attendees of events you have created. Default is false.

        • prefs.push. declined boolean

          Whether or not you will get push notifications about declining events you have created. Default is false.

        • prefs.push. event_cancelled boolean

          Whether or not you will get push notifications about cancelling events by other users. Default is false.

        • prefs.push. event_confirmed boolean

          Whether or not you will get push notifications about confirming events by other users. Default is false.

        • prefs.push. new_event boolean

          Whether or not you will get push notifications about new events created by other (but not on your Vyte page). Default is false.

        • prefs.push. new_message boolean

          Whether or not you will get push notifications about messages for the events you have created or participate in. Default is false.

        • prefs.push. new_suggestion boolean

          Whether or not you will get push notifications about suggestions for the events you have created or participate in. Default is false.

        • prefs.push. vote_update boolean

          Whether or not you will get push notifications about votes for the events you have created. Default is false.

        • prefs.push. vyteme_created_admin boolean

          Whether or not you will get push notifications about events created from your Vyte page. Default is false.

      Returns

      The updated Prefs object if no error occurred.

      CODE SAMPLE

      curl --request PUT 'https://api.vyte.in/v2/users/5f2d4abf1e0662386371d475/preferences' \
      --header 'Authorization: vkjvi2bvfo54ssbybmcts0x42z1sbzm6t0mot8trh8i03reno0' \
      --header 'Content-Type: application/json' \
      --data-raw '
          { "email":
            { "attending": false,
            "declined": false,
            "event_cancelled": false,
            "event_cancelled_admin": true,
            "event_confirmed": true,
            "event_confirmed_admin": true,
            "new_event": true,
            "new_event_admin": true,
            "new_message": true,
            "new_suggestion": true,
            "new_suggestion_own": true,
            "vote_update": true,
            "vote_confirmation": false,
            "vyteme_created_admin": true },
            
          "push":
            { "attending": false,
            "declined": false,
            "event_cancelled": false,
            "event_confirmed": false,
            "new_event": false,
            "new_message": false,
            "new_suggestion": false,
            "vote_update": false,
            "vyteme_created_admin": false } 
              }
          '
      

      RESPONSE SAMPLE

      
      { "email":
            { "attending": false,
            "declined": false,
            "event_cancelled": false,
            "event_cancelled_admin": true,
            "event_confirmed": true,
            "event_confirmed_admin": true,
            "new_event": true,
            "new_event_admin": true,
            "new_message": true,
            "new_suggestion": true,
            "new_suggestion_own": true,
            "vote_update": true,
            "vote_confirmation": false,
            "vyteme_created_admin": true },
            
          "push":
            { "attending": false,
            "declined": false,
            "event_cancelled": false,
            "event_confirmed": false,
            "new_event": false,
            "new_message": false,
            "new_suggestion": false,
            "vote_update": false,
            "vyteme_created_admin": false } 
              }