Table of contents
Webhooks
Download API definition:
PATCH https://dev-api.bentley.com/webhooks/{webhookId}

Updates the specified webhook.

Activation

To activate a webhook, make a PATCH request with the active property set to true. By default, newly created webhooks are inactive by default and must be activated to start recieving events.

The following is a sample PATCH request to activate a webhook.

PATCH https://api.bentley.com/webhooks/{webhookId}

{
  "active": true
}

Deactivation

To deactivate a webhook, make a PATCH request with the active property set to false. Once deactivated, your webhook will stop receiving events.

The following is a sample PATCH request to deactivate a webhook.

PATCH https://api.bentley.com/webhooks/{webhookId}

{
  "active": false
}

Authentication

The Webhooks API V2 can only be called by Service Applications. This request requires an Authorization header with a valid Bearer token with the webhooks:modify scope. For more information on Service Applications and how to obtain an access token can be found here. A list of your Service Applications can be found here.

Authorization

The Service Application must have the webhooks_maintainer permission assigned at the iTwin level or be an Organization Administrator for the Organization that owns a given iTwin.

An Organization Administrator must have at least one of the following roles assigned in User Management: Account Administrator, Co-Administrator, or CONNECT Services Administrator. For more information about User Management please visit our Bentley Communities Licensing, Cloud, and Web Services wiki page.

Request parameters

Name
Required?
Description
webhookId
Yes

Request headers

Name
Required?
Description
Authorization
Yes

OAuth access token with itwin-platform scope

Accept
Yes

Setting to application/vnd.bentley.itwin-platform.v2+json is recommended.

Request body

Update Webhook Request

Name
Type
Required?
Description
secret
String
No

Optional. If none is passed one will be generated

active
Boolean
No

An indicator showing webhook activity. If true, webhook is actively forwarding the events. If false, webhook events are stopped.

callbackUrl
String
No

URL where webhook events are sent.

eventTypes
String[]
No

List of event types the webhook is subscribed to.

Example

json
{
    "callbackUrl": "https://some-callback.example.com",
    "secret": "custom-secret",
    "active": true,
    "eventTypes": [
        "iModels.iModelDeleted.v1",
        "iModels.iModelCreated.v1",
        "iModels.namedVersionCreated.v1",
        "iModels.changesReady.v1",
        "accessControl.memberAdded.v1",
        "accessControl.memberRemoved.v1",
        "accessControl.roleAssigned.v1",
        "accessControl.roleUnassigned.v1",
        "iTwins.iTwinCreated.v1",
        "iTwins.iTwinDeleted.v1",
        "synchronization.jobCompleted.v1",
        "transformations.jobCompleted.v1",
        "realityModeling.jobCompleted.v1",
        "realityAnalysis.jobCompleted.v1",
        "realityConversion.jobCompleted.v1",
        "changedElements.jobCompleted.v1"
    ]
}

Response 200 OK

OK

json
{
    "id": "e6989b43-53ab-45e2-a610-560c6f7e879e",
    "scope": "Account",
    "scopeId": "5c9d64cf-d22f-4149-ad08-c24ff395c3a0",
    "active": false,
    "callbackUrl": "https://some-callback.example.com",
    "eventTypes": ["iModels.iModelDeleted.v1"],
    "created": "2023-10-02T14:55:00.463Z",
    "modified": "2023-10-06T20:03:15.562Z"
}

Response 401 Unauthorized

This response indicates that request lacks valid authentication credentials. Access token might not been provided, issued by the wrong issuer, does not have required scopes or request headers were malformed.

json
{
    "error": {
        "code": "HeaderNotFound",
        "message": "Header Authorization was not found in the request. Access denied."
    }
}

Response 404 Not Found

Specified webhook was not found.

json
{
    "error": {
        "code": "WebhookNotFound",
        "message": "Requested webhook is not available."
    }
}

Response 422 Unprocessable Entity

Invalid request to create new account webhook. Make sure request had required properties and does not pass in readonly properties.

json
{
    "error": {
        "code": "InvalidUpdateWebhookRequest",
        "message": "Cannot update a webhook. Make sure the request body is valid.",
        "details": [{
            "code": "InvalidRequestBody",
            "message": "Invalid request body.",
            "target": "callbackUrl"
        }]
    }
}

Response 429 Too many requests

This response indicates that the client sent more requests than allowed by this API for the current tier of the client.

json
{
    "error": {
        "code": "RateLimitExceeded",
        "message": "The client sent more requests than allowed by this API for the current tier of the client."
    }
}

Response headers

Name
Description
retry-after

Number of seconds to wait until client is allowed to make more requests.

Update Webhook Request

Webhook update request.

Name
Type
Description
secret
String

Optional. If none is passed one will be generated

active
Boolean

An indicator showing webhook activity. If true, webhook is actively forwarding the events. If false, webhook events are stopped.

callbackUrl
String

URL where webhook events are sent.

eventTypes
String[]

List of event types the webhook is subscribed to.

webhook-scope

Scope of the webhook. Possible values: 'Account', 'iTwin'.

Name
Type
Description
Account
String
iTwin
String

Webhook

Common property representation of a webhook.

Name
Type
Description
id
String

Globally unique identifier of the webhook.

scopeId
String

Globally unique identifier of the acount of the webhook.

active
Boolean

An indicator showing webhook activity. If true, webhook is actively forwarding the events. If false, webhook events are stopped.

callbackUrl
String

URL where webhook events are sent.

eventTypes
String[]

List of event types the webhook is subscribed to.

created
String

When the webhook was created.

modified
String

When the webhook was modified.

Error

Contains error information.

Name
Type
Description
code
String

One of a server-defined set of error codes.

message
String

A human-readable representation of the error.

target
String, null

The target of the error.

Error Response

Gives details for an error that occurred while handling the request. Note that clients MUST NOT assume that every failed request will produce an object of this schema, or that all of the properties in the response will be non-null, as the error may have prevented this response from being constructed.

Name
Type
Description
error

Error information.