> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://help.trustmary.com/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# Survey answer webhooks (developers)


# Enable webhooks for your surveys

On the [settings](https://app.trustmary.com/settings) page scroll down to **Webhooks** and click on **Add new**. Add a name, add the endpoint, and select which events you want to subscribe to. You can also create the webhook through the API.

![](https://storage.crisp.chat/users/helpdesk/website/b8083cc0c8b32000/settingswebhooks_365gk3.png)

### Attributes

**survey_id** string
* Unique identifier for the survey.

**survey_name** string
* Name of the survey.

**answer_id** string
* Unique identifier for the given answer.

**answer_values** object
* Contains all the answers that the user gave.

**nps** integer
* Answer data of question "How likely are you to recommend our service to a friend or colleague?" On a scale of 0-10.

**custom** object
* If your survey had custom questions their answers will be listed here as key value pairs. Keys are question ids, values can be answer ids, strings or arrays if the question had multiple selection answers.

**feedback** string
* Answer data of question "What is the primary reason for your score?"

**comment** string
* Answer todata ofquestion "Do you want to give your feedback publicly?". This answer is used as the public recommendation.

**name** string
* Answer data of question "Your name"

**email** string
* Answer data of question "E-mail (not displayed)"

**location** string
* Answer data of question "Location"

**organization** string
* Answer data of question "Organization"

**imageFilename** string
* Answer data of question "Profile picture". This picture can be accessed, with parameters w=width and h=height from https://d3hwc7twidb4ye.cloudfront.net/w128-h128-c/survey/[imageFilename]

**publicConsent** string
* Answer data of question "I want to publish my feedback. I have read the [Companys] privacy policy". Will be "true" or "".

**noPublicConsent** string
* Answer data of question "I don't want to publish my feedback". Will be "true" or "".

**created_at** ISO 8601 with timezone
* Time when the first page was submitted.

**organization_id** string
* Unique identifier for the organization.

**contact** contact_object
* Contains a [contact_object](https://help.trustmary.com/en/article/contacts-developers-hbtxm2/) if answer link contained an identifier.

```json
{     
	"answer": {
    	"survey_id": "tmetCfXyD",
        "survey_name": "Survey Name",
        "answer_id": "1lwBnVbM4",
        "created_at": "2021-01-26T11:46:01.815Z",
        "answer_url": "https://app.trustmary.com/survey/tmetCfXyD/responses?				answer_id=1lwBnVbM4",
        "contactName": "Person Name",
        "contactEmail": "person@example.com",
        "contactPhone": "+35850123456789",
        "contactConsent": "true",
        "noNegativeContact": false,
        "nps": 10,
        "question_NdfJASMGj": [
        	"Toyota",
            "Mercedes"           
       ],           
       	"feedback": "I gave 10 because the product is awesome!\n",
        "question__VmZtTZ1_": "I have a silver car.",
        "question_x5MS9K6Wm": "My car has 4 wheels.",
   },
   "contact": {},
   "review": {             
   			"review_id": "zkHIUR2NZ",
            "source": "trustmary",
            "published": false,
            "eid": "1lwBnVbM4",
            "published_at": null,
            "created_at": "2021-01-26T11:46:22.088Z",
            "deleted_at": null,
            "updated_at": "2021-01-26T11:46:22.088Z",
            "reviewNps": 8,
            "personName": "Person Name",
            "commentText": "I really loved the product!" 
     },     "organization_id": "5S1I9ACyt",
     		"event": "surveyAnswerComplete"
}
```


# Get Webhooks

```json
GET /webhooks

```

### Returning

```json
{    
	"webhooks": [        
    	{       "id": "jaIdsaj2Yw",
        		"name": "Webhook example",
                "hookUrl": "https://hooks.zapier.com/hooks/catch/1231123/asdk123/",
                "events": [
                  	"surveyAnswerComplete"            
                 ],            
                 "created_at": "2021-01-18T12:01:30.262Z",
                 "disabled": null        
            },        
            {            
              	 "id": "asd1231dv",
                 "name": "Webhook created by Zapier",
                 "hookUrl": "https://hooks.zapier.com/hooks/standard/490123/as1231280398098123/",
                 "events": [                
                 	"surveyAnswerComplete"            
                 ],            
                 "created_at": "2021-09-27T07:21:07.394Z",
                 "disabled": false        
         }   
    ]
}
```


# Create Webhook

```json
POST /webhooks
```

### Body

```json
{  
	"name": "Nimi",
    hookUrl: "https://webhook.site/fddb13f8-5589-4f05-8b0c-d39730547443",
    events: ["surveyAnswerComplete"]
}
```


# Remove Webhook

```json
DELETE /webhooks/:webhook_id
```


# Get webhook example data

```json
GET /webhooks/example
```

