{"_id":"5696f91c59a6692d003fad50","editedParams":true,"user":"55208129504fd6230022ae20","version":{"_id":"55208137623ff50d009b2bef","__v":14,"project":"55208137623ff50d009b2bec","createdAt":"2015-04-05T00:26:31.564Z","releaseDate":"2015-04-05T00:26:31.563Z","categories":["55208138623ff50d009b2bf0","55494a226a82a10d00817ae5","55494ba7ee219b0d001743c8","55494bc1ee219b0d001743cc","56ead8c1df765617008bccaf","573a2073dd007d1700cf288f","579695b1f64c9f0e007cd76c","57969e3dfa1ff60e006a1274","579a4592fd9f3c0e008e4f4a","57ab9afe54fa780e006c5430","57b784f5b7ebd60e009cb4a6","58f686818193090f008cec76","59e79fbd4cf31900341d50c6","5b2436973fd93f0003dcf99d"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":0,"category":{"_id":"55494a226a82a10d00817ae5","project":"55208137623ff50d009b2bec","version":"55208137623ff50d009b2bef","__v":15,"pages":["55494ad0ee219b0d001743bb","55494b05f452670d00ec0c29","55494b11ee219b0d001743bf","55494b20ee219b0d001743c1","55494b2bee219b0d001743c3","55494b4a6a82a10d00817af5","55494b686a82a10d00817af9","5549651ccd09b317005f8f50","55497273cd09b317005f8f86","554977f0c634cf2d001250a7","55b970eab42b610d00c9b2e3","5696f3688560a60d00e2c216","5696f91c59a6692d003fad50","5696f92c24490c3700170a2d","5696f9700b09a41900b24422"],"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2015-05-05T22:54:26.925Z","from_sync":false,"order":2,"slug":"public-api","title":"Public API"},"editedParams2":true,"githubsync":"","parentDoc":null,"project":"55208137623ff50d009b2bec","updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-01-14T01:25:48.046Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"settings":"","examples":{"codes":[{"code":"curl 'https://www.sendsonar.com/api/v1/webhooks' \\\n  -X POST \\\n  -H 'X-Token:YOUR_TOKEN' \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"webhook\": {\"name\": \"Cat\", \"active\": \"true\", \"settings\": {}, \"url\": \"http://meow.meow\", \"http_method\": \"POST\"}}'","language":"text"}]},"method":"post","results":{"codes":[{"name":"","code":"{\"id\":2,\"active\":true,\"settings\":{\"new_assigned_message\":\"true\",\"new_unassigned_message\":\"true\"},\"url\":\"https://kittenland.com\",\"http_method\":\"POST\",\"payload\":\"\",\"name\":\"Meow Webhook1\",\"created_at\":\"2015-07-25T20:19:09.213-07:00\",\"updated_at\":\"2015-08-08T16:46:20.364-07:00\"}","language":"json","status":200}]},"auth":"required","params":[{"_id":"5696f91c59a6692d003fad55","ref":"","in":"body","required":false,"desc":"Set the webhook as active or inactive","default":"false","type":"boolean","name":"active"},{"_id":"5696f91c59a6692d003fad54","ref":"","in":"body","required":false,"desc":"When to trigger the webhook (see below)","default":"","type":"array_object","name":"settings"},{"_id":"5696f91c59a6692d003fad53","ref":"","in":"body","required":false,"desc":"The endpoint the webhook should hit","default":"","type":"string","name":"url"},{"_id":"5696f91c59a6692d003fad52","ref":"","in":"body","required":false,"desc":"The http method the webhook should use","default":"","type":"string","name":"http_method"},{"_id":"5696f91c59a6692d003fad51","ref":"","in":"body","required":false,"desc":"Name of the webhook","default":"","type":"string","name":"name"}],"url":"/webhooks"},"isReference":true,"order":14,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Settings description\"\n}\n[/block]\n\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"new_assigned_message\",\n    \"0-1\": \"true/false\",\n    \"0-2\": \"Triggers webhook when a message comes from an assigned customer\",\n    \"h-0\": \"Setting\",\n    \"h-1\": \"Values\",\n    \"h-2\": \"Description\",\n    \"1-0\": \"new_unassigned_message\",\n    \"2-0\": \"customer_subscribed\",\n    \"3-0\": \"customer_unsubscribed\",\n    \"4-0\": \"outbound_message\",\n    \"1-1\": \"true/false\",\n    \"2-1\": \"true/false\",\n    \"3-1\": \"true/false\",\n    \"4-1\": \"true/false\",\n    \"1-2\": \"Triggers webhook when a message comes from an unassigned customer\",\n    \"2-2\": \"Triggers webhook when a customer gets subscribed\",\n    \"3-2\": \"Triggers webhook when a customer gets unsubscribed\",\n    \"4-2\": \"Triggers webhook when a user sends a message to a customer\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]\nExample of data that will be passed from a triggered webhook:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"JSON {\\n  action: 'new_assigned_message', \\n  text: 'Hey, can you help me with something on your site?', \\n  from_name: 'Sonar Customer', \\n  to_name: 'Your_Companys User', \\n  link: 'https://sendsonar.com/threads/homer_simpsons_thread', \\n  customer { \\n    first_name: 'Sonar', \\n    last_name: 'Customer', \\n    phone_number: '+12345678910' \\n  } \\n  user { \\n    first_name: 'Your_Companys', \\n    last_name: 'User', \\n    email: 'service_rep:::at:::company.com' \\n  } \\n} \",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nAll customers are subscribed by default. If you unsubscribe a customer, that customer won't get any messages until you subscribe this customer back.","excerpt":"","slug":"create-webhook","type":"endpoint","title":"Create Webhook"}

postCreate Webhook


Definition

{{ api_url }}{{ page_api_url }}

Parameters

Body Params

active:
booleanfalse
Set the webhook as active or inactive
settings:
array of objects
When to trigger the webhook (see below)
url:
string
The endpoint the webhook should hit
http_method:
string
The http method the webhook should use
name:
string
Name of the webhook

Examples


Result Format


Documentation

[block:api-header] { "type": "basic", "title": "Settings description" } [/block] [block:parameters] { "data": { "0-0": "new_assigned_message", "0-1": "true/false", "0-2": "Triggers webhook when a message comes from an assigned customer", "h-0": "Setting", "h-1": "Values", "h-2": "Description", "1-0": "new_unassigned_message", "2-0": "customer_subscribed", "3-0": "customer_unsubscribed", "4-0": "outbound_message", "1-1": "true/false", "2-1": "true/false", "3-1": "true/false", "4-1": "true/false", "1-2": "Triggers webhook when a message comes from an unassigned customer", "2-2": "Triggers webhook when a customer gets subscribed", "3-2": "Triggers webhook when a customer gets unsubscribed", "4-2": "Triggers webhook when a user sends a message to a customer" }, "cols": 3, "rows": 5 } [/block] Example of data that will be passed from a triggered webhook: [block:code] { "codes": [ { "code": "JSON {\n action: 'new_assigned_message', \n text: 'Hey, can you help me with something on your site?', \n from_name: 'Sonar Customer', \n to_name: 'Your_Companys User', \n link: 'https://sendsonar.com/threads/homer_simpsons_thread', \n customer { \n first_name: 'Sonar', \n last_name: 'Customer', \n phone_number: '+12345678910' \n } \n user { \n first_name: 'Your_Companys', \n last_name: 'User', \n email: 'service_rep@company.com' \n } \n} ", "language": "json" } ] } [/block] All customers are subscribed by default. If you unsubscribe a customer, that customer won't get any messages until you subscribe this customer back.