Identity API docs

Hi,
I’m looking to attach additional data to a user through Netlify Identity on signup. I saw mention of the identity-signup.js function I can run, but since I’d like to be able to test locally, I went the route of firing off an additional function that is called after signup.

I came across Netlify Identity for paid subscriptions which has an example of attaching additional app_metadata, but I’m unfortunately unable to replicate the example with a valid Bearer token from the logged-in user, and always get a 401 User not allowed message. Is there a limitation locally from hitting the endpoint? This is what my example looks like:

    // Create protected data that we'll pass along to Netlify Identity to update for the user
const attributes = {
  app_metadata: {
    authorization: {
      roles: ['customer'],
    },
    stripeId: stripeCustomer.id,
  },
}

// Request to Netlify Identity to update user
// @NOTE This is still failing data: { code: 401, msg: 'User not allowed' }
const [updateUserError] = await to(
  axios({
    method: 'put',
    url: `${headers.url}/admin/users/${data.id}`,
    params: JSON.stringify(attributes),
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
      Authorization: headers.authorization,
    },
  })
)

Are there official API docs?

Hi @zslabs, welcome to the community!!

Since Netlify Identity uses gotrue, you can consider this the API docs for your Identity instance https://github.com/netlify/gotrue#gotrue---user-management-for-apis.

You can also use gotrue-js to accomplish most of what you will need to do. Note that any Admin actions need to be done in Lambda Functions, which means I don’t think those will work locally.

Let me know if that helps answer your questions.

Thanks for the reply and link to the documentation! Ultimately I’ll be ditching Netlify Identity as local development is a necessity for a few other tie-ins I need, but would love to keep tickets like this one open to be updated in the future if this changes. Thanks again!

1 Like

hi @zslabs - of course! We’d also love to hear more specifics about what you might need that we’re not currently providing. We always have an open ear for all kinds of feature requests. We can’t always promise we’ll implement, but we can promise we’ll listen :+1:

:wave: Thanks for the reply as well! My use-case was locally testing creating a Stripe user along with each new registration. I know there’s the identity-signup.js file, but with having to push it up each time to test, it was enough friction for me to move to Firebase for auth.

I see. Did the cli (netlify dev: https://github.com/netlify/cli/blob/master/docs/netlify-dev.md) not work well for you? That should allow you to locally test your site along with other netlify-related features like redirects and functions.