POST /v1/spaces/:space_id/webhooks
HTTP Verb: POST
Available statuses: 201 Created, 422 Unprocessable Entity
Object: Webhook
Location: n/a
Formats: XML, JSON
Create a Webhook.
See also Webhook object fields reference and Update a Webhook.
Params
To create a webhook, a data body must be provided. Data can be provided in three formats: XML, JSON and query string. To specify data type of XML or JSON add the Content-type: application/(json|xml) header to request headers, if you want to provide query string simply skip the Content-type header.
All params should be sent in the webhook namespace, e.g.:
XML
<webhook>
<title>My new webhook</title>
...
</space>
JSON
{"webhook":{"title":"My new webhook",...}}
Query string
webhook[title]=Webhook&...
Check the full list of available params on webhook object fields reference
Examples
Request XML, using cURL utility:
curl -i -H "Authorization: Bearer _token" -d "webhook[title]=MyWebhook&webhook[authentication_type]=1&webhook[external_url]=https://www.assembla.com&webhook[http_method]=1" https://api.assembla.com/v1/spaces/myspace/webhooks.xml
Response:
HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Fri, 26 Sep 2014 06:28:17 GMT
Content-Type: application/xml; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: https://api.assembla.com/v1/spaces/myspace/webhooks/11
<?xml version="1.0" encoding="UTF-8"?>
<webhook>
<id type="integer">11</id>
<title>MyWebhook</title>
<enabled type="boolean">false</enabled>
<authentication-type type="integer">1</authentication-type>
<app-api-key nil="true"/>
<app-secret nil="true"/>
<app-request-token-url nil="true"/>
<app-access-token-url nil="true"/>
<app-authorize-url nil="true"/>
<app-authorize-query nil="true"/>
<access-token nil="true"/>
<access-token-secret nil="true"/>
<external-url>https://www.google.com</external-url>
<http-method type="integer">1</http-method>
<content-type nil="true"/>
<content nil="true"/>
<created-at type="datetime">2014-09-26T06:28:17+00:00</created-at>
<updated-at type="datetime">2014-09-26T06:28:17+00:00</updated-at>
</webhook>
Request JSON, using cURL utility:
curl -i -H "Authorization: Bearer _token" -d "webhook[title]=MyWebhook&webhook[authentication_type]=1&webhook[external_url]=https://www.assembla.com&webhook[http_method]=1" https://api.assembla.com/v1/spaces/myspace/webhooks.json
Response:
HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Fri, 26 Sep 2014 06:29:11 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: https://api.assembla.com/v1/spaces/myspace/webhooks/13
...
{
"id": 13,
"title": "MyWebhook",
"enabled": false,
"authentication_type": 1,
"app_api_key": null,
"app_secret": null,
"app_request_token_url": null,
"app_access_token_url": null,
"app_authorize_url": null,
"app_authorize_query": null,
"access_token": null,
"access_token_secret": null,
"external_url": "https://www.assembla.com",
"http_method": 1,
"content_type": null,
"content": null,
"created_at": "2014-09-26T06:29:11+00:00",
"updated_at": "2014-09-26T06:29:11+00:00"
}
JSON is formatted here for readability, in a real response JSON body is inline with no indentation.
Note: pay attention to Location header, this is the URL where newly created resource is located, you can GET on this URL to access this resource.
Description for each field: webhook object fields reference