# How to create, update, delete and search users using API call

**URL:** <https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953>\
**Category:** Get Help\
**Tags:** api, management-api, auth0\
**Created:** [February 16, 2021, 4:25pm UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953 "2021-02-16T16:25:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![vignesh.ramesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vignesh.ramesh/32/12799_2.png) [@vignesh.ramesh](https://community.auth0.com/u/vignesh.ramesh)\
**Post date:** [February 16, 2021, 4:25pm UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953/1 "2021-02-16T16:25:09Z")

</div>

Hi,

Right now we are creating, updating and deleting users from Auth0 dashboard but going forward we need to implement that in our website so that our customers can create users on their own. I know that we can use management API to achieve this but since I am new to Auth0 can I get a detailed steps of how to implement this. Our application is a single page NodeJs application and right now I am using the custom API for authentication. Can I use the existing custom API to achieve my requirement ? or should I use Auth0 Management API (System API to achieve this) if that is the case how can I use it with my existing custom API.

Since I am new to Auth0 it will be very helpful to me If I get proper idea of the implementation to be done

---

<div class="post-metadata">

**Author:** ![cibrax](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/cibrax/32/27644_2.png) [@cibrax](https://community.auth0.com/u/cibrax)\
**Post date:** [February 16, 2021, 6:37pm UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953/2 "2021-02-16T18:37:34Z")

</div>

Hi Vignesh,

You first need to register an Application in the Auth0 Dashboard representing your web application (if you don’t have one), and configure it as Machine to Machine. That will let your app to negotiate an access token for the Management API using Client Credentials (server side without user intervention). After that, go and authorize that application (under the APIs tab in the application settings) to use the Auth0 management API (https://.us.auth0.com/api/v2/).

Once you have that configured, you can use the Client Credential Flow passing the Client ID/Secret and API audience. For example,

```
        var request = new HttpRequestMessage(HttpMethod.Post, $"https://{domain}/oauth/token");

        request.Content = new FormUrlEncodedContent(new[]

        {

            new KeyValuePair<string, string>("client_id", clientId),

            new KeyValuePair<string, string>("client_secret", clientSecret),

            new KeyValuePair<string, string>("audience", $"https://{domain}/api/v2/"),

            new KeyValuePair<string, string>("grant_type", "client_credentials")

        }); 

```

That will give you back an access token that you can use to consume the management API (bearer token). For example, for calling this endpoint, [Auth0 Management API v2](https://auth0.com/docs/api/management/v2#!/Users/post_users)

---

<div class="post-metadata">

**Author:** ![vignesh.ramesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vignesh.ramesh/32/12799_2.png) [@vignesh.ramesh](https://community.auth0.com/u/vignesh.ramesh)\
**Post date:** [February 17, 2021, 12:29pm UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953/3 "2021-02-17T12:29:56Z")

</div>

Hi @cibrax ,

Thanks for the reply and it helped me to figure out how to achieve my requirement. One last doubt I am having is I am using the below piece of code to get the Auth0 token

```auto
var request = require("request");

var options = { method: 'POST',
  url: 'https://auth0.com/oauth/token',
  headers: { 'content-type': 'application/json' },
  body: '{"client_id":"xxx","client_secret":"xxxx","audience":"https://auth0.com/api/v2/","grant_type":"client_credentials"}' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

```

And my response to it looks like below

```auto
{"access_token":"xxxxxxxxxxxx","scope":"xxxxxxx","expires_in":86400,"token_type":"Bearer"}

```

But I only want the access token from it so that I can pass it in authentication header for my management API. I tried using the following option `body.access_token` it gives me output as `undefined` can you please help me with this. So that I can use only the access\_token

---

<div class="post-metadata">

**Author:** ![vignesh.ramesh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/vignesh.ramesh/32/12799_2.png) [@vignesh.ramesh](https://community.auth0.com/u/vignesh.ramesh)\
**Post date:** [February 17, 2021, 1:17pm UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953/4 "2021-02-17T13:17:35Z")

</div>

Hi @cibrax ,

I tried axios call instead of normal request and now I am able to access the token. Thanks for the support 🙂 All Good

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 17, 2021, 1:26pm UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953/5 "2021-02-17T13:26:06Z")

</div>

Perfect! Glad to hear that!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [February 25, 2021, 10:19am UTC](https://community.auth0.com/t/how-to-create-update-delete-and-search-users-using-api-call/57953/6 "2021-02-25T10:19:03Z")

</div>


