Creating a New Timeline Event: What Am I Missing?



Please see the complete post with all the links included here: Hubspot only allows new users to add 2 links to new posts.

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.

$headers = array();
$headers[] = 'Content-Type: application/x-www-form-urlencoded;charset=utf-8';

$hubEventUrl  = **link**;
$fields = "grant_type=authorization_code";
$fields .= "&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$fields .= "&client_secret=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$fields .= "&redirect_uri=";
$fields .= "&code=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$hubEventUrl);
curl_setopt($ch,CURLOPT_POST, 5);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);



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:

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.

$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

$hubEventUrl  = '**link**;

$json = '{"id": "101921", "userEmail":"","email":""}';

$fields = "id=101921";
$fields .= "&eventTypeId=279606"; 
$fields .= "&";
$fields .= "&";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$hubEventUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch,CURLOPT_POST, 4);
curl_setopt($ch,CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);




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.

  1. Do I use my developer account's hapikey or my Enterprise account's hapikey?
  2. 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?

Thanks, in advance!


Hi @dwebrich,

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:


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