# Create timeline event using the Hubspot api

**URL:** <https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602>\
**Category:** APIs & Integrations\
**Created:** [November 8, 2016, 9:31pm UTC](https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602 "2016-11-08T21:31:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [November 8, 2016, 9:31pm UTC](https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602/1 "2016-11-08T21:31:49Z")

</div>

Hi everyone

I have been asked to send events to some contacts timeline automatically using a scheduled script.

It seems the oauth2 needs the user to use his browser to authenticate (and get the code)

Given I would need to authenticate within the script,  
does it exist another way ? For example using the api key ?

The documentation does not mention it.

---

<div class="post-metadata">

**Author:** ![Dadams](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dadams/32/21752_2.png) [@Dadams](https://community.hubspot.com/u/Dadams)\
**Post date:** [November 8, 2016, 10:58pm UTC](https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602/2 "2016-11-08T22:58:43Z")

</div>

Hi @Jim

Oauth requires a HubSpot user to log in and click the grant access button, after which you’d get a code that can be used to get the access token and refresh token. If you provide the refresh token to your script, it would be able to get access\_tokens to access the APIs going forward.

---

<div class="post-metadata">

**Author:** ![Sebastian\_Lozad](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sebastian_lozad/32/2679_2.png) [@Sebastian\_Lozad](https://community.hubspot.com/u/Sebastian_Lozad)\
**Post date:** [September 12, 2018, 9:48pm UTC](https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602/3 "2018-09-12T21:48:49Z")

</div>

Does this refresh\_token expire? Can I store it and use for all further calls to the api?

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [October 9, 2018, 6:37am UTC](https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602/4 "2018-10-09T06:37:31Z")

</div>

any update on above question. facing same issue.

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [October 9, 2018, 1:22pm UTC](https://community.hubspot.com/t/create-timeline-event-using-the-hubspot-api/11602/5 "2018-10-09T13:22:59Z")

</div>

Hi [@Sebastian\_Lozada](https://community.hubspot.com/u/sebastian_lozada) and [@yogen](https://community.hubspot.com/u/yogen),

The `refresh_token` does _not_ expire, so you can store it and use it to obtain a new `access_token` every 6 hours, per [this documentation](https://developers.hubspot.com/docs/methods/oauth2/refresh-access-token).
