Get user roles with netlify ID - happy-hugle-97373a

With Netlify Identity, is there a way to get the users role list if the only info I have is their account’s Netlify ID?

I’m using Stripe to process payments. After a user purchases a new product, Stripe calls the handle-webhooks.js function on Netlify so I can update the users role. I know I can use

fetch(`${identity.url}/admin/users/${netlifyID}`, {
        method: "PUT",
        headers: {
          Authorization: `Bearer ${identity.token}`,
        body: JSON.stringify({
          app_metadata: {
            roles: ["free"],

to override the users role list, but I don’t want to override it, I want to append to it.

Hey @ghughes139 :wave:t2:

Welcome to The Forums :slight_smile:

GoTrue (the system behind Netlify Identity) is RESTful and resourceful, so to get a user’s info (including the app_metadata contained therein, just send a GET request with your Auth header — the response should be the user object JSON.