I am trying trying to create a new event using the Timeline Events API, but I keep getting an error: "You don’t have access to this application."
I followed all the steps (creating an EventType, defined event properties, and defined template) in the following tutorial: link
Here were my prerequisite steps to use the Timeline Events API.
I created a developer account and set that up.
I created an application.
I got a special code by doing the following things.
First, I created the following URL with my new client ID: link
After visiting that link, I was given the option of choosing an account (either the main account or my developer account). I chose my main account (my Enterprise account) since that's the account that I am building the application to use the Timeline Events for.
After choosing my main account, I was redirected to link
Then, I used that code to get an access_token from Hubspot. Here's the PHP code for that. I had to set it up on my server and visit a page to activate it.
Now, for the final step, I am trying to use the access token to create a timeline event for a contact in my main enterprise account. I followed all the steps (creating an EventType, defined event properties, and defined template) in the following tutorial: https://developers.hubspot.com/docs/methods/timeline/timeline-overview
Here's the PHP code I am using for the final step. If anyone is interested, I have this set up in a PHP function, and it runs when I visit a certain URL.
A couple questions about $hubEventUrl. In this tutorial (link), it says that "You must use an OAuth access token to create an event. API keys are not supported." However, if I don't include the hapikey in the $hubEventUrl, I get an error. I assumed I needed to use my developer account's hapikey, but I noticed my Enterprise account also has a hapikey.
Do I use my developer account's hapikey or my Enterprise account's hapikey?
Also, same question for the userId. Do I use my developer account user's ID, or my Enterprise account user's ID? I have tried both, but I get the same error ""You don’t have access to this application."
Just as a side note, this is a lot of work just to use the Timeline Events API. Is there an easier way?
So the fundamental issue you're running into is that when you make a request to the 'Create or update a timeline event' endpoint, you're getting an error with a message that says "You don't have access to this application?" Let's start with the specific error, and the specific request you're making.
To create an event, you should make a request to the following URL:
PUT https://api.hubapi.com/integrations/v1/{{YOUR_APP_ID}}/timeline/event
with the following headers:
Content-Type: application/json
Authorization: Bearer xxxxxxxxxxxx
And at least the following fields in the body:
{
"id":"3", // This is the ID of this specific instance of this event
"objectId":1, // This is the ID of the object (e.g. contact) that this event is associated with
"eventTypeId":"123" // This is the ID of the event type used to create this event.
}
You should not include any hapikey; only the OAuth access token you received after completing the auth flow. If that doesn't work, can you reach back out with the following details:
The full raw request you made, and the raw response (without authorization details)
You appId and the Hub ID of your production portal