# Calling an API to a custome created one on the dashboard?

**URL:** <https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881>\
**Category:** Get Help\
**Created:** [June 24, 2022, 3:00pm UTC](https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881 "2022-06-24T15:00:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![m3.code](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/m3.code/32/33197_2.png) [@m3.code](https://community.auth0.com/u/m3.code)\
**Post date:** [June 24, 2022, 3:00pm UTC](https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881/1 "2022-06-24T15:00:50Z")

</div>

Hi everyone,

I was following his tutorial to make an API call with the auth0/react package:

> **[Auth0 React SDK Quickstarts: Call an API](https://auth0.com/docs/quickstart/spa/react/02-calling-an-api)**
>
> This tutorial demonstrates how to make API calls to the Auth0 Management API.

The default here is the Auth0 Management API. IS it possible to make a call to an API I created?  
I tried adapting the fields (audience, scope…) and also tried to adapt the field ’ `userDetailsByIdUrl`’. For this one, should it be the equivalent of  
`audience/v2/users/${user?.sub}`  
or leave it as  
`https://${domain}/api/v2/users/${user?.sub}`  
?

Because I defined the permissions I needed in the API I created, but everytime, I get an error ‘401 - Bad Audience’ and always the case of ‘No user meta\_data found’, although I am sure in the auth0 dashboard to have created some metadata for the logged-in user.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 27, 2022, 10:59pm UTC](https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881/3 "2022-06-27T22:59:42Z")

</div>

Hey there @m3.code!

> [@m3.code](#):
>
> IS it possible to make a call to an API I created?

Yes, it is definitely possible to make a call to an API that you’ve created. It will need to be [registered](https://auth0.com/docs/get-started/auth0-overview/set-up-apis) in your dashboard. There’s actually an example of this in the sample app - If you run `npm run dev` the example API will be served at `http://localhost:3001` :

> <https://github.com/auth0-samples/auth0-react-samples/blob/master/Sample-01/api-server.js>

And for example your `auth_config.json` might look like:

```auto
{
  "domain": "YOUR_DOMAIN.auth0.com",
  "clientId": "CLIENT_ID",
  "audience": "http://localhost:3001",
  "scope": "read:something"
}

```

Where `http://localhost:3001` has been registered as the Identifier of an API in my Auth0 dashboard.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![m3.code](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/m3.code/32/33197_2.png) [@m3.code](https://community.auth0.com/u/m3.code)\
**Post date:** [June 28, 2022, 5:00am UTC](https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881/4 "2022-06-28T05:00:19Z")

</div>

Hey @ty.frith Thank you for your answer.

Unless I don’t understand how, which is very well possible, I don’t see the correlation between what I am trying to achieve and your answer?

The article I am referencing adds code in a React component to try to access some user\_metadata, that has been manually entered through the dashboard.  
They’re using the default Auth0 Management API, while I was thinking to use one that I created for example, because I added some permissions to it, and linked this API to the SPA App I am trying to run.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [June 30, 2022, 11:11pm UTC](https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881/5 "2022-06-30T23:11:50Z")

</div>

No problem, happy to help where I can!

What I shared is just an example of a SPA + API (non Auth0) set up - I recommend checking out the following doc which outlines the SPA + API architectural scenario:

> **[Single-Page Applications (SPA) with API](https://auth0.com/docs/get-started/architecture-scenarios/spa-api)**
>
> Explains the architecture scenario where a single-page application (SPA) talks to an API using OpenID Connect (OIDC), and the OAuth 2.0 Implicit Grant Flow, to authenticate users with Auth0.

Regarding user metadata, you might want to look into adding this to an access/ID token and going about it that way - Some more on that here:

> **[Sample Use Cases: Scopes and Claims](https://auth0.com/docs/get-started/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token)**
>
> Learn how to use scopes and claims with applications and APIs.

Let us know if you have any follow up questions!

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [July 15, 2022, 11:12pm UTC](https://community.auth0.com/t/calling-an-api-to-a-custome-created-one-on-the-dashboard/85881/6 "2022-07-15T23:12:42Z")

</div>

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