APIs & Integrations

karkaletsis
Member

Create a ticket from API

I am using API to create a ticket by posting the following JSON to https://api.hubapi.com/crm/v3/objects/tickets

{
"properties": {
"hs_pipeline": "0",
"hs_pipeline_stage": "1",
"hs_ticket_priority": "HIGH",
"subject": "troubleshoot report",
"content": "test email content τεστ",
"project": "TEST POSTMAN"
}
}
 
How can I pass in JSON the creator email to automatically create the assosiation with contact?
0 Upvotes
2 Replies 2
coldrickjack
Top Contributor

Create a ticket from API

HI @karkaletsis,

 

You need to include an association array in your request. This contains the ID of the CRM object that you'd like to associate to the ticket. For instance if I had a contact with ID "951" I could create the ticket and associate using the following request:

 

POST https://api.hubapi.com/crm/v3/objects/tickets
HEADER AUTHORIZATION: BEARER TOKEN
BODY
{
    "properties": {
        "hs_pipeline": "0",
        "hs_pipeline_stage": "1",
        "hs_ticket_priority": "HIGH",
        "subject": "troubleshoot report"
    },
    "associations": [
        {
            "to": {
                "id": 951
            },
            "types": [
                {
                    "associationCategory": "HUBSPOT_DEFINED",
                    "associationTypeId": 16
                }
            ]
        }
    ]
}
RESPONSE
{
    "id": "1685582803",
    "properties": {
        "createdate": "2023-08-28T15:48:35.312Z",
        "hs_helpdesk_sort_timestamp": "2023-08-28T15:48:35.312Z",
        "hs_last_message_from_visitor": "false",
        "hs_lastmodifieddate": "2023-08-28T15:48:35.312Z",
        "hs_object_id": "1685582803",
        "hs_object_source": "INTEGRATION",
        "hs_object_source_id": "1914406",
        "hs_pipeline": "0",
        "hs_pipeline_stage": "1",
        "hs_ticket_id": "1685582803",
        "hs_ticket_priority": "HIGH",
        "subject": "troubleshoot report"
    },
    "createdAt": "2023-08-28T15:48:35.312Z",
    "updatedAt": "2023-08-28T15:48:35.312Z",
    "archived": false
}

 

You can use the CRM Search API to check to see if the contact exists in the CRM prior to making the above request. If they do their ID will be returned which you can use for the association. If they do not you can create a contact and use the returned ID to create the association.

 

Good luck with the project!

0 Upvotes
Rkc
Member

Create a ticket from API

Thank you. i Got exactly what i want KaBoom

0 Upvotes