Constructor
new Webhooks(client)
Parameters:
| Name | Type | Description | 
|---|---|---|
client | 
            
            BoxClient | The Box API Client that is responsible for making calls to the API | 
- Source:
 
Members
(nullable) primarySignatureKey :string
    Primary signature key to protect webhooks against attacks.
    Type:
- string
 
- Source:
 
(nullable) secondarySignatureKey :string
    Secondary signature key to protect webhooks against attacks.
    Type:
- string
 
- Source:
 
(readonly) triggerTypes :WebhookTriggerType
    Enum of valid webhooks event triggers
    Type:
Properties:
| Name | Type | Description | 
|---|---|---|
FILE | 
            
            WebhookTriggerType | |
COMMENT | 
            
            WebhookTriggerType | |
TASK_ASSIGNMENT | 
            
            WebhookTriggerType | |
METADATA_INSTANCE | 
            
            WebhookTriggerType | |
FOLDER | 
            
            WebhookTriggerType | |
WEBHOOK | 
            
            WebhookTriggerType | |
COLLABORATION | 
            
            WebhookTriggerType | |
SHARED_LINK | 
            
            WebhookTriggerType | |
SIGN_REQUEST | 
            
            WebhookTriggerType | 
- Source:
 
(static, nullable) primarySignatureKey :string
    Primary signature key to protect webhooks against attacks.
    Type:
- string
 
- Source:
 
(static, nullable) secondarySignatureKey :string
    Secondary signature key to protect webhooks against attacks.
    Type:
- string
 
- Source:
 
Methods
create(targetID, targetType, notificationURL, triggerTypes, callbackopt) → {Promise.<Object>}
    Create a new webhook on a given Box object, specified by type and ID.
API Endpoint: '/webhooks'
Method: POST
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
targetID | 
            
            string | Box ID of the item to create webhook on | |
targetType | 
            
            ItemType | Type of item the webhook will be created on | |
notificationURL | 
            
            string | The URL of your application where Box will notify you of events triggers | |
triggerTypes | 
            
            Array.<WebhookTriggerType> | Array of event types that trigger notification for the target | |
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the new webhook information if it was acquired successfully | 
- Source:
 
Returns:
    A promise resolving to the new webhook object
- Type
 - Promise.<Object>
 
create(targetID, targetType, notificationURL, triggerTypes, callbackopt) → {Promise.<Object>}
    Create a new webhook on a given Box object, specified by type and ID.
API Endpoint: '/webhooks'
Method: POST
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
targetID | 
            
            string | Box ID of the item to create webhook on | |
targetType | 
            
            ItemType | Type of item the webhook will be created on | |
notificationURL | 
            
            string | The URL of your application where Box will notify you of events triggers | |
triggerTypes | 
            
            Array.<WebhookTriggerType> | Array of event types that trigger notification for the target | |
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the new webhook information if it was acquired successfully | 
- Source:
 
Returns:
    A promise resolving to the new webhook object
- Type
 - Promise.<Object>
 
delete(webhookID, callbackopt) → {Promise.<void>}
    Delete a specified webhook by ID
API Endpoint: '/webhooks/:webhookID'
Method: DELETE
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
webhookID | 
            
            string | ID of webhook to be deleted | |
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Empty response body passed if successful. | 
- Source:
 
Returns:
    A promise resolving to nothing
- Type
 - Promise.<void>
 
delete(webhookID, callbackopt) → {Promise.<void>}
    Delete a specified webhook by ID
API Endpoint: '/webhooks/:webhookID'
Method: DELETE
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
webhookID | 
            
            string | ID of webhook to be deleted | |
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Empty response body passed if successful. | 
- Source:
 
Returns:
    A promise resolving to nothing
- Type
 - Promise.<void>
 
get(webhookID, optionsopt, callbackopt) → {Promise.<Object>}
    Returns a webhook object with the specified Webhook ID
API Endpoint: '/webhooks/:webhookID'
Method: GET
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
webhookID | 
            
            string | ID of the webhook to retrieve | |
options | 
            
            Object | 
                
                    <optional> | 
            
            
            Additional options for the request. Can be left null in most cases. | 
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the webhook information if it was acquired successfully | 
- Source:
 
Returns:
    A promise resolving to the webhook object
- Type
 - Promise.<Object>
 
get(webhookID, optionsopt, callbackopt) → {Promise.<Object>}
    Returns a webhook object with the specified Webhook ID
API Endpoint: '/webhooks/:webhookID'
Method: GET
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
webhookID | 
            
            string | ID of the webhook to retrieve | |
options | 
            
            Object | 
                
                    <optional> | 
            
            
            Additional options for the request. Can be left null in most cases. | 
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the webhook information if it was acquired successfully | 
- Source:
 
Returns:
    A promise resolving to the webhook object
- Type
 - Promise.<Object>
 
getAll(optionsopt, callbackopt) → {Promise.<Object>}
    Get a list of webhooks that are active for the current application and user.
API Endpoint: '/webhooks'
Method: GET
    Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
            
            Object | 
                
                    <optional> | 
            
            
            Additional options for the request. Can be left null in most cases.
                Properties
  | 
        |||||||||||||||
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the list of webhooks if successful, error otherwise | 
- Source:
 
Returns:
    A promise resolving to the collection of webhooks
- Type
 - Promise.<Object>
 
getAll(optionsopt, callbackopt) → {Promise.<Object>}
    Get a list of webhooks that are active for the current application and user.
API Endpoint: '/webhooks'
Method: GET
    Parameters:
| Name | Type | Attributes | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | 
            
            Object | 
                
                    <optional> | 
            
            
            Additional options for the request. Can be left null in most cases.
                Properties
  | 
        |||||||||||||||
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the list of webhooks if successful, error otherwise | 
- Source:
 
Returns:
    A promise resolving to the collection of webhooks
- Type
 - Promise.<Object>
 
update(webhookID, updates, callbackopt) → {Promise.<Object>}
    Update a webhook
API Endpoint: '/webhooks/:webhookID'
Method: PUT
    Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
webhookID | 
            
            string | The ID of the webhook to be updated | |||||||||||||
updates | 
            
            Object | Webhook fields to update
                Properties
  | 
        |||||||||||||
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the updated webhook information if successful, error otherwise | 
- Source:
 
Returns:
    A promise resolving to the updated webhook object
- Type
 - Promise.<Object>
 
update(webhookID, updates, callbackopt) → {Promise.<Object>}
    Update a webhook
API Endpoint: '/webhooks/:webhookID'
Method: PUT
    Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
webhookID | 
            
            string | The ID of the webhook to be updated | |||||||||||||
updates | 
            
            Object | Webhook fields to update
                Properties
  | 
        |||||||||||||
callback | 
            
            function | 
                
                    <optional> | 
            
            
            Passed the updated webhook information if successful, error otherwise | 
- Source:
 
Returns:
    A promise resolving to the updated webhook object
- Type
 - Promise.<Object>
 
(static) setSignatureKeys(primaryKey, secondaryKeyopt) → {void}
    Sets primary and secondary signatures that are used to verify the Webhooks messages
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
primaryKey | 
            
            string | The primary signature to verify the message with | |
secondaryKey | 
            
            string | 
                
                    <optional> | 
            
            
            The secondary signature to verify the message with | 
- Source:
 
Returns:
- Type
 - void
 
(static) setSignatureKeys(primaryKey, secondaryKeyopt) → {void}
    Sets primary and secondary signatures that are used to verify the Webhooks messages
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
primaryKey | 
            
            string | The primary signature to verify the message with | |
secondaryKey | 
            
            string | 
                
                    <optional> | 
            
            
            The secondary signature to verify the message with | 
- Source:
 
Returns:
- Type
 - void
 
(static) validateMessage(body, headers, primaryKeyopt, secondaryKeyopt, maxMessageAgeopt) → {boolean}
    Validate a webhook message by verifying the signature and the delivery timestamp
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
body | 
            
            string | Object | The request body of the webhook message | |
headers | 
            
            Object | The request headers of the webhook message | |
primaryKey | 
            
            string | 
                
                    <optional> | 
            
            
            The primary signature to verify the message with. If it is sent as a parameter, it overrides the static variable primarySignatureKey | 
secondaryKey | 
            
            string | 
                
                    <optional> | 
            
            
            The secondary signature to verify the message with. If it is sent as a parameter, it overrides the static variable primarySignatureKey | 
maxMessageAge | 
            
            int | 
                
                    <optional> | 
            
            
            The maximum message age (in seconds). Defaults to 10 minutes | 
- Source:
 
Returns:
    - True or false
- Type
 - boolean
 
(static) validateMessage(body, headers, primaryKeyopt, secondaryKeyopt, maxMessageAgeopt) → {boolean}
    Validate a webhook message by verifying the signature and the delivery timestamp
    Parameters:
| Name | Type | Attributes | Description | 
|---|---|---|---|
body | 
            
            string | Object | The request body of the webhook message | |
headers | 
            
            Object | The request headers of the webhook message | |
primaryKey | 
            
            string | 
                
                    <optional> | 
            
            
            The primary signature to verify the message with. If it is sent as a parameter, it overrides the static variable primarySignatureKey | 
secondaryKey | 
            
            string | 
                
                    <optional> | 
            
            
            The secondary signature to verify the message with. If it is sent as a parameter, it overrides the static variable primarySignatureKey | 
maxMessageAge | 
            
            int | 
                
                    <optional> | 
            
            
            The maximum message age (in seconds). Defaults to 10 minutes | 
- Source:
 
Returns:
    - True or false
- Type
 - boolean