# Auth0 actions api not defined

**URL:** <https://community.auth0.com/t/auth0-actions-api-not-defined/69450>\
**Category:** Get Help\
**Tags:** api, auth0\
**Created:** [September 10, 2021, 5:51pm UTC](https://community.auth0.com/t/auth0-actions-api-not-defined/69450 "2021-09-10T17:51:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashsubedi.ae](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ashsubedi.ae/32/14581_2.png) [@ashsubedi.ae](https://community.auth0.com/u/ashsubedi.ae)\
**Post date:** [September 10, 2021, 5:51pm UTC](https://community.auth0.com/t/auth0-actions-api-not-defined/69450/1 "2021-09-10T17:51:50Z")

</div>

Hi Everyone,  
One newbie question regarding the usage of Action:  
Here is the code I have:  
exports.onExecutePostUserRegistration = async (event, api) =\> {  
api.user.setUserMetadata(“registeredPolicy”, “NO”);  
console.log(api.user);  
};

What should I do to define api?  
Test Results  
Error:  
{  
“message”: “Cannot read property ‘user’ of undefined”,  
“name”: “TypeError”  
}

---

<div class="post-metadata">

**Author:** ![ashsubedi.ae](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ashsubedi.ae/32/14581_2.png) [@ashsubedi.ae](https://community.auth0.com/u/ashsubedi.ae)\
**Post date:** [September 10, 2021, 8:40pm UTC](https://community.auth0.com/t/auth0-actions-api-not-defined/69450/2 "2021-09-10T20:40:44Z")

</div>

I see onExecutePostUserRegistration doesn’t have api

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [September 10, 2021, 8:57pm UTC](https://community.auth0.com/t/auth0-actions-api-not-defined/69450/4 "2021-09-10T20:57:10Z")

</div>

Hi @ashsubedi.ae!

I understand you have trouble getting custom Actions to work.

Having looked closely at your custom action script, it appears that you are using a Post User Registration action. Unfortunately, it’s not possible to enrich the user’s profile’s metadata post user registration.

In this case, I recommend enriching the user’s profile using a [Post Login trigger](https://auth0.com/docs/actions/triggers/post-login#enrich-the-user-profile) instead. The Post Login Action will allow you to accomplish your desired behavior.

Please let me know if you have any questions. I would be happy to help.

---

<div class="post-metadata">

**Author:** ![ashsubedi.ae](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ashsubedi.ae/32/14581_2.png) [@ashsubedi.ae](https://community.auth0.com/u/ashsubedi.ae)\
**Post date:** [September 10, 2021, 9:17pm UTC](https://community.auth0.com/t/auth0-actions-api-not-defined/69450/5 "2021-09-10T21:17:43Z")

</div>

Thank you @rueben.tiow  
One quick question please, I am using Owin Quick Start guide for [Asp.net](http://Asp.net) and I need to update the user app\_metadata from code and not from Rules/Actions.  
Could you provide me any links or guides in order to do so? Thanks

---

<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:** [September 25, 2021, 9:17pm UTC](https://community.auth0.com/t/auth0-actions-api-not-defined/69450/6 "2021-09-25T21:17:47Z")

</div>

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