Some background:
- We are currently building a Yext app that will allow us to add attributes to a user’s Entities.
- I have The OAuth flow up and running.
What I’m missing is how I use the API to fetch data and modify data for a user. I understand how to use the API, but what I’m not sure about is how I get the account id. Example URL:
https://api.yext.com/v2/accounts/me/customfields?api_key=XXXXXXXXXX&v=20210304
- Right now I have
me
in the accounts path. How do I get the user’s account id? I see the appSpecificAccountId
in the OAuth response, but that doesn’t seem to work.
- If my application is performing a “background” data sync (server to server) do I need the
access_token
? If so, for what?
Thank you.
1 Like
Hi @Damian_Esteban ,
I had the same question a couple of months ago
Here is what the API Support Team told me:
So we suggest just using “me” instead of Account IDs because they automatically leverage the correct account depending on the API key being used and they are a little more secure to pass (since this account ID info won’t be in the Request URL).
The use of Account IDs in the Request URL is more utilized for our Partner accounts that have multiple sub-accounts that utilize the same API key.
Hope this helps
Best, Stefan
Stefan -
Thank you, that helps. But I’m still not clear on the API key exactly - does every account have a different one? And if so, do I get it with the access_token
?
…because they automatically leverage the correct account depending on the API key being used …
Thank you.
When you create a new app in developer console, you are prompted to create an API key for your app. This API key is what authorizes your app to interact with Yext APIs.
To start, the API key is only authorized on your developer account - the account you’ve created the App and API key in.
When another user installs your app to their account, the API key is then authorized on that account as part of the installation flow.
The API key will have Read/Write or Read Only permissions on endpoint groups as specified by you in the App Settings UI.
Hope this helps!
Thank you, it almost does. Let’s say I want to get all locations for a particular account. How do I specify that I want to get locations from that specific account?
Thank you.
Hi @Damian_Esteban ,
OK, so things are getting clearer now (or so I hope).
Are you a partner administering a couple of (sub-)accounts by any chance?
I know of two ways to figure out the “accountId” value:
If you are a Yexter with access to the “Admin” tool, you can just look it up.
The “accountId” value you need for your API request is the value labelled “Partner ID” in the “Account Overview” screen:
If you do not have access to “Admin”, you can query the “Accounts: List” endpoint of the “Administrative API”.
The response will include this value too, labelled as “accountId”
Kind regards
Stefan
Yes, I’m a partner, and users will install my Yext application. I need to be able to update their entities with custom fields, and sync their Yext data with our platform. So in this case I would use the Administrative API?
Thank you.
My real question is this:
How can I fetch / update a customer’s entities (a customer that has installed the app) if I only receive the appSpecificAccountId
(which the documentation says not to use) and the access_token
? Do I only need the Entity ID?
Hi @Damian_Esteban ,
I now understand you are a partner with a Yext partner account and are managing a couple of customers, each with a Yext sub-account related to your partner account.
To manage the entities in customer_1’s Knowledge Graph you need to send requests to the Knowledge API providing the API key you have created in your partner account and the accountId assigned to customer_1’s sub-account (instead of “me”).
To manage customer_2’s entities you have to use your API key again (i.e. the same one as above), but the accountId assigned to customer_2’s sub-account (instead of “me”).
You can query the Admin API to retrieve the accountIds of your customers’ sub-accounts.
Does that makes sense?
Feel free to reach out to the API Support team for further clarification.
Best,
Stefan
1 Like
You can query the Admin API to retrieve the accountIds of your customers’ sub-accounts.
Stefan -
Thank you so much, I have been trying to get a straight answer about this for weeks. I really appreciate it.
Thank you.
Sincerely,
Damian
1 Like
Hey Damian,
I just wanted to chime in just to make sure this thread has accurate information.
This article might be helpful if you haven’t read it already. Here are some key points.
A few important points:
- When you create an App you get an API Key and a Client ID.
- Using the Client ID you can generate an authorization code by redirecting to the
/oauth2/authorize
endpoint
- With this authorization code you can generate an access token using the
/oauth2/accesstoken
endpoint. Note you will use your API Key in the client_secret
field of this request.
- When calling standard Yext APIs (e.g. /entities) with OAuth you should use the
access_token
NOT the api_key
. The API Key is only used for getting an access token when you are using OAuth. In your API requests pass in access_token
as the param instead of api_key. For example:
https://api.yext.com/v2/accounts/me/entities?access_token=&v=
Here is a diagram of the steps that also might be helpful.
Let me know if you have any additional questions,
Max
3 Likes
Thank you so much! This is finally the answer I’ve been looking for. I really appreciate it.