Emma API Documentation

Webhooks

class audience.api.controllers.webhooks.WebhookController(app, request, response)

Contains web service functions for operating on webhooks.

list_webhooks(account_id)

GET /#account_id/webhooks

Get a basic listing of all webhooks associated with an account.

Returns: A list of webhooks that belong to the given account.
Sample Response [showhide]
	GET /100/webhooks

	[
	  {
		"url": "http://myemma.com", 
		"webhook_id": 100, 
		"method": "POST", 
		"account_id": 100, 
		"event": "mailing_finish"
	  }, 
	  {
		"url": "http://tech.myemma.com", 
		"webhook_id": 101, 
		"method": "POST", 
		"account_id": 100, 
		"event": "mailing_finish"
	  }
	]
	
get_webhook(account_id, webhook_id)

GET /#account_id/webhooks/#webhook_id

Get information for a specific webhook belonging to a specific account.

Returns: Details for a single webhook
Raises : Http404 if no webhook found
Sample Response [showhide]
	GET /100/webhooks/100

	{
	  "url": "http://myemma.com", 
	  "event": "mailing_finish", 
	  "method": "POST", 
	  "account_id": 100, 
	  "webhook_id": 100
	}
	
list_webhook_event_types(account_id)

GET /#account_id/webhooks/events

Get a listing of all event types that are available for webhooks.

Returns: A list of event types and descriptions
Sample Response [showhide]
	GET /100/webhooks/events

	[
	  {
		"event_name": "mailing_finish", 
		"webhook_event_id": 1, 
		"description": "Fired when a mailing is finished."
	  }, 
	  {
		"event_name": "mailing_start", 
		"webhook_event_id": 2, 
		"description": "Fired when a mailing starts."
	  }, 
	  {
		"event_name": "member_signup", 
		"webhook_event_id": 3, 
		"description": "Fired when a member signs up through a signup form."
	  }, 
	  {
		"event_name": "message_open", 
		"webhook_event_id": 4, 
		"description": "Fired when a message is opened."
	  }, 
	  {
		"event_name": "message_click", 
		"webhook_event_id": 5, 
		"description": "Fired when a link in a message is clicked."
	  }, 
	  {
		"event_name": "member_optout", 
		"webhook_event_id": 6, 
		"description": "Fired when a member opts out."
	  }, 
	  {
		"event_name": "message_share", 
		"webhook_event_id": 7, 
		"description": "Fired when a member shares a message."
	  }, 
	  {
		"event_name": "message_share_click", 
		"webhook_event_id": 8, 
		"description": "Fired when a someone follows a link a member has shared."
	  }, 
	  {
		"event_name": "import_finish", 
		"webhook_event_id": 9, 
		"description": "Fired when a member import completes."
	  }, 
	  {
		"event_name": "member_update", 
		"webhook_event_id": 10, 
		"description": "Fired when a member is updated."
	  }, 
	  {
		"event_name": "member_delete", 
		"webhook_event_id": 11, 
		"description": "Fired when a member is deleted."
	  }, 
	  {
		"event_name": "member_add_to_group", 
		"webhook_event_id": 12, 
		"description": "Fired when a member(s) is added to a group(s)."
	  }, 
	  {
		"event_name": "member_remove_from_group", 
		"webhook_event_id": 13, 
		"description": "Fired when a member(s) is removed from a group(s)."
	  }, 
	  {
		"event_name": "group_create", 
		"webhook_event_id": 14, 
		"description": "Fired when a group is created."
	  }, 
	  {
		"event_name": "group_delete", 
		"webhook_event_id": 15, 
		"description": "Fired when a group is deleted."
	  }, 
	  {
		"event_name": "group_update", 
		"webhook_event_id": 16, 
		"description": "Fired when a group is updated."
	  }, 
	  {
		"event_name": "member_status_update", 
		"webhook_event_id": 17, 
		"description": "Fired when a member's status changes."
	  }, 
	  {
		"event_name": "message_forward", 
		"webhook_event_id": 18, 
		"description": "Fired when a message is forwarded."
	  }
	]
	
create_webhook(account_id)

POST /#account_id/webhooks

Create an new webhook.

If method is ‘POST’, the data will be posted to the given URL as a blob of JSON. If the method is ‘GET’ the data will be added to the query string of your URL as a url encoded blob of JSON in a key called ‘payload’.

Parameters:
  • event (string) – The name of an event to register this webhook for
  • url (string) – The URL to call when the event happens
  • method (string) – The method to use when calling the webhook. Can be GET or POST. Defaults to POST.
  • user (string) – The user_id to use for authentication
Sample Response [showhide]
	POST /100/webhooks
	{
	  "url": "http://myemma.com/blog/", 
	  "event": "mailing_finish"
	}

	1024
	
update_webhook(account_id, webhook_id)

PUT /#account_id/webhooks/#webhook_id

Update an existing webhook. Takes the same params as create_webhook.

Returns: The id of the updated webhook, or False if the update failed.
Raises : Http404 if the webhook cannot be found.
Sample Response [showhide]
	PUT /100/webhooks/100
	{
	  "url": "http://tech.myemma.com/"
	}

	100
	
delete_webhook(account_id, webhook_id)

DELETE /#account_id/webhooks/#webhook_id

Deletes an existing webhook.

Returns: True if the webhook deleted successufully.
Raises : Http404 if no webhook found
Sample Response [showhide]
	DELETE /100/webhooks/101

	true
	

Related Topics

Interested in Emma?

Emma's email marketing makes communicating simple and stylish. Inquire now for more details.