# When a user signs up in Auth0, I want to create an account in my own database

**URL:** <https://community.auth0.com/t/when-a-user-signs-up-in-auth0-i-want-to-create-an-account-in-my-own-database/14556>\
**Category:** Get Help\
**Tags:** auth0\
**Created:** [August 22, 2018, 2:44pm UTC](https://community.auth0.com/t/when-a-user-signs-up-in-auth0-i-want-to-create-an-account-in-my-own-database/14556 "2018-08-22T14:44:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoism](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chaoism/32/8483_2.png) [@chaoism](https://community.auth0.com/u/chaoism)\
**Post date:** [August 22, 2018, 2:44pm UTC](https://community.auth0.com/t/when-a-user-signs-up-in-auth0-i-want-to-create-an-account-in-my-own-database/14556/1 "2018-08-22T14:44:30Z")

</div>

I’ve seen articles and discussion about how to use a separate database for auth0 authentication (whether it’s using the database directly or importing user from that database into Auth0’s db), but I haven’t seen the other way around.

We have an existing database that we use for some other operation, and we need to have every existing user on Auth0 to be on that database.

Currently I have the idea of using the `rule` and check if the user logs in for the first time. If that’s the case, go ahead and call an API endpoint that will trigger user creation.

say my endpoint is `https://some_domain/some_endpoint/create_user`, I use the template `Update User Profile in Firebase` and modify to the following

```auto
function (user, context, callback) {
    if (context.stats.loginsCount > 1) return callback(null, user, context);
    var url = 'https://some_domain/some_endpoint/create_user';
    var api_token = 'blahblahblah';
    var headers = { 
        'Authorization' : 'Token ' + api_token
    };
    request.post({
    "url": url,
    "useremail": user.email,
    "header": headers
    },
    function(err, response, body) {
    if (err) return callback(err);
    return callback(null, user, context);
  });
}

```

I tried to `Try this rule` and there’s no message whatsoever that shows success or failure (I doubt the endpoint was ever called since if I change the endpoint to something invalid, the process of `Try this rule` is still completed)

I’m wondering if this approach will work and how I can test it

---

<div class="post-metadata">

**Author:** ![chaoism](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chaoism/32/8483_2.png) [@chaoism](https://community.auth0.com/u/chaoism)\
**Post date:** [August 22, 2018, 6:04pm UTC](https://community.auth0.com/t/when-a-user-signs-up-in-auth0-i-want-to-create-an-account-in-my-own-database/14556/3 "2018-08-22T18:04:40Z")

</div>

I’ve decided to use an endpoint to deal with this instead. please check the question about that instead

> [@Call an API endpoint after a user signs up](http://community.auth0.com/t/call-an-api-endpoint-after-a-user-signs-up/14571):
>
> I am trying to create a script on Auth0 (using Hook?) that after a new user signs up, it will call an API endpoint to do something else. I’ve not yet successfully done it. I ran the test in Hook page, and the result shows 200, but my endpoint does not receive anything. If I take out the endpoint, I would expect a 500 or 400 error, but it still shows 200. Ultimately, how do I call an API after a new user signs up on Auth0? I am using XMLHttpRequest package. Is that correct?

---

<div class="post-metadata">

**Author:** ![kimcodes](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/kimcodes/32/81052_2.png) [@kimcodes](https://community.auth0.com/u/kimcodes)\
**Post date:** [September 13, 2018, 1:29pm UTC](https://community.auth0.com/t/when-a-user-signs-up-in-auth0-i-want-to-create-an-account-in-my-own-database/14556/4 "2018-09-13T13:29:16Z")

</div>


