# Store Auth0 User Reference to External DB

**URL:** <https://community.auth0.com/t/store-auth0-user-reference-to-external-db/57497>\
**Category:** Get Help\
**Tags:** api, external-system, auth0, user-creation\
**Created:** [February 6, 2021, 6:56pm UTC](https://community.auth0.com/t/store-auth0-user-reference-to-external-db/57497 "2021-02-06T18:56:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![damand](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/damand/32/12778_2.png) [@damand](https://community.auth0.com/u/damand)\
**Post date:** [February 6, 2021, 6:56pm UTC](https://community.auth0.com/t/store-auth0-user-reference-to-external-db/57497/1 "2021-02-06T18:56:44Z")

</div>

Hello,

I want to store the user reference once the user validates their email. So when a user clicks on the validation link in their email, I wanted to create a reference of that user to my external DB, like Auth0 ID or something.

Is there a way to achieve that?

Thanks

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [February 8, 2021, 3:31pm UTC](https://community.auth0.com/t/store-auth0-user-reference-to-external-db/57497/3 "2021-02-08T15:31:53Z")

</div>

Hi @damand,

There are a few ways you could do this.

You can send the user ID to your own API in a Post-User Registration Hook or a Rule.

If your app only has a database connection (i.e. email/password login), you can use a [Post-User Registration Hook](https://auth0.com/docs/hooks/extensibility-points/post-user-registration) to send the user ID to an external API.

However, the Post-User Registration Hook will only fire for database connections. If your app has multiple types of connections such as social connections (“Sign in with Google”) and a database connection (email/password), then you can use a [Rule](https://auth0.com/docs/rules) to do the same thing.

Here is an FAQ that explains how to call an external API from within a rule: [How do I call my API from a rule?](https://community.auth0.com/t/how-do-i-call-my-api-from-a-rule/41309)

Within the rule, you can make sure that the call to your API only occurs the first time a user logs in by adding this to the top of the rule:

```auto
    const count = context.stats && context.stats.loginsCount ? context.stats.loginsCount : 0;
    if (count > 1) {
        return callback(null, user, context);
    }

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [February 23, 2021, 3:32pm UTC](https://community.auth0.com/t/store-auth0-user-reference-to-external-db/57497/4 "2021-02-23T15:32:27Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
