Skip to main content
Contributor II
March 21, 2025
Solved

Get current logged in user data

  • March 21, 2025
  • 6 replies
  • 148 views

Hi 

I want to get current user login data by oauth. Which API give my a user data?
I want user/company/location id to distinct the user authentication.

Thanks 

    Best answer by retention

    @pilottest0007 - Again, I don’t think you can get the users of an Account, but it can get all the accounts of a User.  So if “User A” has access to 3 different Klaviyo Accounts, it will show you that in the array.  However, you can’t get all the users of a Klaviyo Account (and their roles).  Nor can you find out who is currently logged in.

    As for your second question, you can use the Profiles API to Get/Update custom properties of a Profile that can contain any arbitrary key/value you want to store (e.g. fav_color = “red”).  You can see everything you can access in a profile in this overview guide here:

    6 replies

    retention
    Partner - Platinum
    2025 Champion
    March 21, 2025

    Hi ​@pilottest0007, welcome to the community,

    When you say ‘current user login” - are you referring to a Klaviyo user that’s logged into Klaviyo?  If so, I don’t think there are any API endpoints to manage Klaviyo users at the moment.  The only information about the Klaviyo account itself is the “Accounts API” - but that doesn’t tell you who logged in via Oauth, just the details about the account.  

    Joseph Hsieh // retentioncommerce.com // X: @retention
    Problem Solver III
    March 22, 2025

    To get user data (user, company, and location ID) via OAuth, follow these steps:

     

    1. OAuth Flow:

    - Authenticate the user via OAuth and get the access token.

    - Use the token to make API requests to retrieve user data.

     

    2. API Endpoints for Common Platforms:

     

    - Shopify:

      - Customer Data: `/admin/api/2021-07/customers.json`

      - Location Data: `/admin/api/2021-07/locations.json`

     

      Example:

      ```json

      {

        "id": 123456,

        "company": "ABC Corp",

        "location_id": "78910",

        "email": "john@example.com"

      }

      ```

     

    - Google:

      - Use the Google People API: `https://people.googleapis.com/v1/people/me?personFields=names,emailAddresses,organizations`

     

      Example:

      ```json

      {

        "names": [{"displayName": "John Doe"}],

        "emailAddresses": [{"value": "john.doe@gmail.com"}],

        "organizations": [{"name": "Google"}]

      }

      ```

     

    - Klaviyo:

      - Use Profiles API: `/api/profiles/`

     

      Example:

      ```json

      {

        "id": "12345",

        "company": "ABC Corp",

        "location": "New York",

        "email": "john.doe@example.com"

      }

      ```

     

    3. Next Steps:

    1. Authenticate via OAuth.

    2. Get an Access Token.

    3. Use the Token to retrieve user data (company, location, etc.) from the relevant API.

     

    Let me know if you need further clarification!

    Contributor II
    March 24, 2025

    Thank you for your response. I used the Accounts API, but it returned the data in an array format. I tried using the "Add-on Account" option to retrieve a list of accounts, but it only returned a single account (Company/Main/Admin account) at index 0 for both emails.

    So now, I am using the Accounts API and assuming that the company account is always at index 0.

    Please let me know if I am on the wrong track.

    Note: I need only Company/Main/Admin account for my App settings page. 

    Contributor II
    March 24, 2025

    I have another question regarding custom fields. Is there an API or feature to add/get custom fields for profiles, similar to a CRM?

    Additionally, is there a way to retrieve a list of all fields related to profiles, lists, or other models? I need this information to map my app's fields with existing and custom fields.

    Looking forward to your guidance.

    retention
    Partner - Platinum
    retentionAnswer
    2025 Champion
    March 24, 2025

    @pilottest0007 - Again, I don’t think you can get the users of an Account, but it can get all the accounts of a User.  So if “User A” has access to 3 different Klaviyo Accounts, it will show you that in the array.  However, you can’t get all the users of a Klaviyo Account (and their roles).  Nor can you find out who is currently logged in.

    As for your second question, you can use the Profiles API to Get/Update custom properties of a Profile that can contain any arbitrary key/value you want to store (e.g. fav_color = “red”).  You can see everything you can access in a profile in this overview guide here:

    Joseph Hsieh // retentioncommerce.com // X: @retention
    Contributor II
    March 25, 2025

    Here is an example of Custom Fields used in other platforms. This is an example of Pipedrive CRM that allows us to add custom fields in leads persons etc. Also, they provide an API to geta  list of All custom fields: 

    https://developers.pipedrive.com/docs/api/v1/DealFields 
    https://developers.pipedrive.com/docs/api/v1/PersonFields

     

    Does Klaviyo provide the same?
    I want to get the list of custom fields how I will get this using API?

     

    image.png image.png