apitrustpilot

How to send Trustpilot invitations through Trustpilot API?


In our app we are using this API call to retrieve our average rating score and display it on our website:

https://api.trustpilot.com/v1/business-units/{{BUSINESS_UNIT_ID}}/?apikey={{API_KEY}}

This works great.


Now if we want to send an invitation to rate our services to one of our customers, we use a very similar API call:

https://invitations-api.trustpilot.com/v1/private/business-units/{{BUSINESS_UNIT_ID}}/invitations?apikey={{API_KEY}}

Unfortunately, this doesn't work. We are getting this error:

{"fault":{"faultstring":"Invalid access token","detail":{"errorcode":"oauth.v2.InvalidAccessToken"}}}

What are we missing here?

We can't see why our API key works for the first call, but not for the second.

Thanks for any help.


Solution

  • In the first API call you are calling a public endpoint. For all public endpoints API key is enough because you are not accessing restricted data.

    For your second API call (the invitations one), you are calling a private endpoint. For all private APIs you need to authenticate yourself using the OAuth2 flow and include the access token in your request.

    You can read more about the flow at: https://developers.trustpilot.com/authentication