# Adding Rule to add user\_metadata when user logs in, don't want to use a domain as namespace

**URL:** <https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761>\
**Category:** Get Help\
**Created:** [January 25, 2021, 5:56pm UTC](https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761 "2021-01-25T17:56:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![martynleeball](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/martynleeball/32/14039_2.png) [@martynleeball](https://community.auth0.com/u/martynleeball)\
**Post date:** [January 25, 2021, 5:56pm UTC](https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761/1 "2021-01-25T17:56:56Z")

</div>

Hey, I have read the documentation but I don’t understand the purpose in the namespace within the rules. So this is my rule:

```auto
function addAttributes(user, context, callback) {
  const namespace = 'http://www.test.co.uk/';
  context.idToken[namespace + 'user_metadata'] = user.user_metadata;
  callback(null, user, context);
}

```

Which of course displays this when I login:

```auto
[
  "http://www.test.co.uk/user_metadata" => [...],
  "nickname" => "mlb",
  "name" => "Martyn Lee Ball",
  "picture" => "...",
  "updated_at" => "2021-01-25T17:13:50.873Z"
]

```

As you can see `http://www.test.co.uk/user_metadata` has been added and it contains the data, however all I want is `user_metadata`, not any crap at the start, so it would be:

```auto
[
  "user_metadata" => [...],
  "nickname" => "mlb",
  "name" => "Martyn Lee Ball",
  "picture" => "...",
  "updated_at" => "2021-01-25T17:13:50.873Z"
]

```

---

<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:** [January 25, 2021, 6:50pm UTC](https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761/3 "2021-01-25T18:50:41Z")

</div>

Hi @martynleeball,

Unfortunately, namespaces are required so that claims do not collide with any reserved claims or claims from other resources. You can read more about this here: [Create Custom Claims](https://auth0.com/docs/tokens/create-namespaced-custom-claims)

---

<div class="post-metadata">

**Author:** ![martynleeball](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/martynleeball/32/14039_2.png) [@martynleeball](https://community.auth0.com/u/martynleeball)\
**Post date:** [January 25, 2021, 6:54pm UTC](https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761/4 "2021-01-25T18:54:48Z")

</div>

And the namespace MUST be a URI?

---

<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:** [January 25, 2021, 6:58pm UTC](https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761/5 "2021-01-25T18:58:59Z")

</div>

It’s recommended to use a URI because 1) it follows the conventional namespace established by XML namespaces and 2) because URIs are unique, you will prevent any accidental collision. However, the namespaces can be something else other than a URI.

---

<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 9, 2021, 6:59pm UTC](https://community.auth0.com/t/adding-rule-to-add-user-metadata-when-user-logs-in-dont-want-to-use-a-domain-as-namespace/56761/6 "2021-02-09T18:59:03Z")

</div>

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