REST Hook

REST Hooks allow you to subscribe to certain events in Capsule. When those events are triggered, Capsule will send a JSON payload to a URL that you specify, informing you of the change. These endpoints allow you to retrieve, subscribe and unsubscribe hooks. For a full description of the model see the REST Hook model definition.

List REST hooks

The collection of REST hooks currently subscribed on the account. If authenticated via a registered application, only REST hooks subscribed by that application will be returned.

GET
https://api.capsulecrm.com/api/v2/resthooks

Response

Returns HTTP status code 200. The body of the response will contain an object with a single property restHooks which is an array of REST Hook objects.

HTTP/1.1 200
{
  "restHooks" : [ {
    "id" : 100,
    "event" : "party/created",
    "targetUrl" : "https://cool.site/partycreatedhook",
    "embed" : "fields,tags,owner",
    "batched" : true
  } ]
}

Show REST hook

Show a specific REST hook. The REST hook is only visible to users authenticated via the registered application that subscribed it.

GET
https://api.capsulecrm.com/api/v2/resthooks/{restHookId}

Response

Returns HTTP status code 200. The body of the response will contain an object with a single property restHook which will contain a REST Hook object.

HTTP/1.1 200
{
  "restHook" : {
    "id" : 100,
    "event" : "party/created",
    "targetUrl" : "https://cool.site/partycreatedhook",
    "embed" : "fields,tags,owner",
    "batched" : true
  }
}

Subscribe REST hook

Subscribes to an event in Capsule. A maximum 20 REST hooks can be subscribed per account. The body must contain an object with a single property restHook which must be a REST Hook object. This operation requires that the User has an Administrator role on the account, and is authenticated via a registered application.

POST
https://api.capsulecrm.com/api/v2/resthooks
          {
  "restHook" : {
    "event" : "party/created",
    "targetUrl" : "https://cool.site/partycreatedhook",
    "description" : "An amazing hook that will change the world."
  }
}
        

Response

Returns HTTP status code 201. The body of the response will contain the REST hook as it was stored in Capsule.

HTTP/1.1 201
Location: https://api.capsulecrm.com/api/v2/resthooks/100
{
  "restHook" : {
    "id" : 100,
    "event" : "party/created",
    "targetUrl" : "https://cool.site/partycreatedhook",
    "embed" : "fields,tags,owner",
    "batched" : true
  }
}

Headers:

Name Type Description
Location String

The URL that identifies the new REST hook.

Unsubscribe REST hook

Unsubscribes a REST hook, stopping all events immediately. This operation requires that the user has an Administrator role on the account, and is authenticated via the same registered application that subscribed the REST hook to be deleted.

DELETE
https://api.capsulecrm.com/api/v2/resthooks/{restHookId}

Response

Returns HTTP status code 204. Returns an empty body if the REST hook was successfully unsubscribed.

HTTP/1.1 204