# api.accessToken.setCustomClaim and api.idToken.setCustomClaim Start of namesapace string

**URL:** <https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340>\
**Category:** Get Help\
**Tags:** jwt, api\
**Created:** [April 25, 2022, 3:25pm UTC](https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340 "2022-04-25T15:25:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ronan/32/34077_2.png) [@Ronan](https://community.auth0.com/u/Ronan)\
**Post date:** [April 25, 2022, 3:25pm UTC](https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340/1 "2022-04-25T15:25:52Z")

</div>

Hi,  
Why namespace in Actions must starts with https:// or http:// ?

This one works:

```javascript
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'https://test.api';
  if (event.authorization) {
    api.accessToken.setCustomClaim(`${namespace}/ip`, event.request.ip);
    api.accessToken.setCustomClaim(`${namespace}/hostname`, event.request.hostname);
    api.accessToken.setCustomClaim(`${namespace}/geoip`, event.request.geoip);
    api.idToken.setCustomClaim(`${namespace}/ip`, event.request.ip);
    api.idToken.setCustomClaim(`${namespace}/hostname`, event.request.hostname);
    api.idToken.setCustomClaim(`${namespace}/geoip`, event.request.geoip);
  }
};

```

but this one does not work:

```javascript
exports.onExecutePostLogin = async (event, api) => {
  const namespace = 'urn:test.api';
  if (event.authorization) {
    api.accessToken.setCustomClaim(`${namespace}/ip`, event.request.ip);
    api.accessToken.setCustomClaim(`${namespace}/hostname`, event.request.hostname);
    api.accessToken.setCustomClaim(`${namespace}/geoip`, event.request.geoip);
    api.idToken.setCustomClaim(`${namespace}/ip`, event.request.ip);
    api.idToken.setCustomClaim(`${namespace}/hostname`, event.request.hostname);
    api.idToken.setCustomClaim(`${namespace}/geoip`, event.request.geoip);
  }
};

```

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [April 25, 2022, 4:55pm UTC](https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340/4 "2022-04-25T16:55:46Z")

</div>

Hi @Ronan ,

Welcome to the Auth0 Community!

`Why namespace in Actions must starts with https:// or http:// ?`

In [this](https://auth0.com/docs/customize/actions/test-actions#unit-test-actions) Auth0 doc, there is example of action code with the declaration of the namespace variable:

`const namespace = "https://my-app.example.com";`

It looks to me that’s how we should declare this variable.

Hope it helps!

---

<div class="post-metadata">

**Author:** ![Ronan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ronan/32/34077_2.png) [@Ronan](https://community.auth0.com/u/Ronan)\
**Post date:** [April 26, 2022, 5:44am UTC](https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340/5 "2022-04-26T05:44:27Z")

</div>

Thank you for your answer but I already know this document. In this it is not written that http:// or https:// is a mandatory namespace. It is only a sample.  
That’s why in my message I gave a working code with https:// and a not working code.  
For example in the API audience I use some identifiers like “urn:api:identifier” because if an api is shared between multiple web sites it makes no sense to use an url.  
My question is still WHY because nowhere I saw the mandatory word, but perhaps I’m wrong.  
Ronan

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [April 26, 2022, 4:05pm UTC](https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340/6 "2022-04-26T16:05:05Z")

</div>

Thank you for the reply. I believe [this](https://auth0.com/docs/secure/tokens/json-web-tokens/create-namespaced-custom-claims) article provided more insights regarding your concern. Please let us know if any other queries.

---

<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:** [December 22, 2022, 9:39am UTC](https://community.auth0.com/t/api-accesstoken-setcustomclaim-and-api-idtoken-setcustomclaim-start-of-namesapace-string/82340/7 "2022-12-22T09:39:06Z")

</div>


