Is it possible to create timeline events with token types other than string?

We use the NPM library @hubspot/api-client to create timeline events on CRM objects, such as Contacts (crm.timeline.eventsApi.createBatch()).

Our event templates include tokens which have types other than string, for instance ‘Numeric’ and ‘Date’. But the Hubspot api client does not appear to have a way to send event tokens in formats other than string. The token data is included in the payload as

'tokens': {
 [key: string]: string;
 };

Does anyone know if there is a way to send tokens with other types?

I was able to get this working. It seems that only the Hubspot definition of the type needs to be correct. If I pass a number as a token, then it appears to be coerced into a string, but then converted back to a number by Hubspot. A Date type is just a Unix epoch as a number.

True heroes update their posts with solutions. Thanks for taking the time to do that @KKauper :raising_hands: — Jaycee

Hi @KKauper , that lines up with how timeline extensions behave today. Even though the TypeScript definitions in the client force everything into a string for the payload, HubSpot’s event engine will cast the token back into the type declared in the event template as long as the incoming value is compatible with it (Accounts Dashboard | HubSpot )

So numbers become numbers again, and date tokens just need a Unix epoch (ms) to be parsed correctly.

The main thing is that the template’s internal token type drives the storage format, not the client’s type hint. As long as you send something the template can coerce, the rendered event shows the right type. Out of curiosity, do you need these tokens for analytics or just for formatting the event card?

When these external events also power downstream reporting, Stacksync keeps the related CRM records in step so your timeline always reflects consistent source-of-truth data.