Create support tickets via API with email & name

Hey, we would like to create support tickets using the Ticket API via some UI solution on our internal site.

We’ve been able to set up private app and create basic tickets following documentation here.

We can create tickets with basic default & custom properties:

{
“hs_pipeline”: “0”,
“hs_pipeline_stage”: “1”,
“hs_ticket_priority”: “HIGH”,
“hs_ticket_category”:“GENERAL_INQUIRY”,

“content”: “Test”,
“subject”: “testoAUth”,
“content”: “I am creating a new ticket”
}

How can we also include contacts email address in tickets? Otherwise we might not know who reported this ticket. It can be either already existing contacts or new contacts that are not present in Hubspot yet, using already existing contact properties. I was hopeful to use something lightweight like this (like you would in a Marketing Form I guess?)

{
“hs_pipeline”: “0”,
“hs_pipeline_stage”: “1”,
“hs_ticket_priority”: “HIGH”,
“hs_ticket_category”:“GENERAL_INQUIRY”,

“content”: “Test”,
“subject”: “testoAUth”,
“content”: “I am creating a new ticket”

“email”: “marty.mcfly@example.com”,

“firstname”: “Marty”,

“lastname”: “McFly”
}

However this returns errors:

{
“status”: “error”,
“message”: “Property values were not valid: [{\“isValid\”:false,\“message\”:\“Property \\\“email\\\” does not exist\”,\“error\”:\“PROPERTY_DOESNT_EXIST\”,\“name\”:\“email\”}]”,
“correlationId”: “[[redacted]]”,
“category”: “VALIDATION_ERROR”

What we basically need is just a “Reported by” functionality…

Thanks for your support!

Hi @LVarrelmann

Thank you for reaching out.

I want to tag some of our experts on this - @himanshurauthan @tjoyce @JBeatty do you have any thoughts for @LVarrelmann on this?

Thank you!

Best

Tiphaine

Hi @LVarrelmann,

There are two primary ways forward with this. The first to use the associations API to associate the contact with the ticket. For this you can use the endpoint “/crm/v3/associations/{fromObjectType}/{toObjectType}/batch/create” though you will need the HubSpot ID of both the contact and the ticket. The tickets ID should be returned by your first create ticket API, and the contact ID can be found by searching for their email, or posibly creating it does not exist. Once this endpoint is called it will show as an associations on the ticket to the contact and vice verca.
The second solution would be to use the form api and create a ticket form. This form doesn’t actually have to exist as an embed anywhere and you would just use it for the form api. On the form you can include an option for contact name and email, and HubSpot will do all of the work for findind/creating the contact and assocating them with the ticket.

Personally I recommend going with the form api, as your system is not especially complicated, also with a form you can add hidden fields to it, with default values, which are treated the same when a submission is done through the form api.

Hi, i tried it with “the form api”.

I am calling this endpoint from php with curl:

https://api.hsforms.com/submissions/v3/integration/submit/portalid/formid

The submission is successfully sent into the form but the ticket creation fails

The form is also used on a page where all workflows and the ticket-creation does not fail. So, do i miss something when submitting with the api?

I solved my problem. Everything was fine except that i was sending the pipline stage and pipeline id formatted as string instead of an integer.

Hi @JBeatty

thank you so much for pointing me to Forms API, seems to be exactly what I’m looking for!

Since it’s listed in legacy documentation - are they plans to deprecate it in the short term (since new API is currently already in beta)? Do you have any insight into this? :slightly_smiling_face:

Thanks again & best,

Luka

Hi @LVarrelmann,

The forms “Submit data to a form” endpoint is currently not depreceated, nor do I know of any plans to, and if it were there would be ample notice before hand, so it is not something you should worry about.

Hello - I take the opportunity to answer to this channel - I’m using this functionality of submitting a contact and a ticket to a form as well, but when I submit, informations are actually sent to Hubspot, but no ticket is created.

I see this in the form section:

Does anybody know how to fix this?

Hi @MAdrai

Thank you for reaching out.

Can you confirm you’ve followed these steps to connect the form to the conversations inbox? If yes, is this happening for all submissions? Is this happening on incognito window and another browser?

Thank you!

Best

Tiphaine