Creating a New Hubspot Timeline Event: What Am I Missing?

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:

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:

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

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  = "";
$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  = ';

$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 (, 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!

Leave a Reply

Your email address will not be published. Required fields are marked *