Certificates Service (CS) Webhooks

Provides operations to manage certificates.

Index

Events

Event Description Payload Payload Description Remarks
ElectronicSeal_Activated Webhook raised when an electronic seal owner is activated. ElectronicSealActivatedPayload Describes information about the electronic seal owner.
ElectronicSeal_Deactivated Webhook raised when an electronic seal owner is deactivated. ElectronicSealDeactivatedPayload Describes information about the electronic seal owner.
ElectronicSealParent_Activated Webhook raised when an electronic seals parent owner is activated. ElectronicSealParentPayload Describes information about the electronic seals parent owner.
ElectronicSealParent_Deactivated Webhook raised when an electronic seals parent owner is deactivated. ElectronicSealParentPayload Describes information about the electronic seals parent owner.
ElectronicSealSignature_Completed Webhook raised when an electronic seal signature has completed. ElectronicSealSignatureCompletedPayload Describes information about the electronic seal signature.

^ Back to top

Payloads

ElectronicSealActivatedPayload

Defines the payload for electronic seals owners webhooks.

Property Description
Environment The provider environment used.
ParentOwnerId The parent owner identifier.
ProviderId The provider identifier.
OwnerId The owner identifier.
AuthorizerId The authorizer identifier.
AuthorizerSecret The authorizer secret.

^ Back to top

ElectronicSealDeactivatedPayload

Defines the payload for electronic seals owners webhooks.

Property Description
Environment The provider environment used.
ParentOwnerId The parent owner identifier.
ProviderId The provider identifier.
OwnerId The owner identifier.

^ Back to top

ElectronicSealParentPayload

Defines the payload for electronic seals parent owners webhooks.

Property Description
Environment The provider environment used.
ParentOwnerId The parent owner identifier.
ProviderId The provider identifier.

^ Back to top

ElectronicSealSignatureCompletedPayload

Defines the payload for electronic seals owners webhooks.

Property Description
Environment The provider environment used.
ParentOwnerId The parent owner identifier.
ProviderId The provider identifier.
OwnerId The owner identifier.
RequestId The unique identifier of the request.
RequestState The request state.

^ Back to top

Operations

The REST API provides endpoints that allow creating, updating, and deleting subscriptions to specific events.

Create Subscription

Creates a subscription for one or more webhooks events.

Parameters

Parameter Description Example
ClientId The unique identifier of the client application subscribing the webhook. MyApplication
EventNames A list containing the names of the events being subscribed. [ElectronicSealParent_Activated]
CallbackUrl The address of the endpoint that should receive the webhook callback. https://server.io/callback
Secret A shared secret, defined by the client application, that can be used to authenticate the callbacks. MySpecialSecret
DeadLettering.Enabled A value indicating whether the subscription should support dead-lettering. false
DeadLettering.Configuration The configuration that should be use for dead-lettering (when enabled). See Dead-lettering
Active A value indicating whether the subscription should be activated. true

Result

The subscription identifier, which can latter be used to update, delete it, etc.

Example (HTTP)

POST /api/v{version:apiVersion}/webhooks
content-type: application/json
body:
{
  "clientId": "{ClientId}",
  "eventNames": [
    "{EventName}
  ],
  "callbackUrl": "{CallbackUrl}",
  "secret": "{Secret}",
  "deadLettering": {
    "enabled": false,
    "configuration": null
  },
  "active": true
}

Example (Client Library)

CreateWebhookSubscriptionRequest request = new CreateWebhookSubscriptionRequest()
{
  (...)
};

try
{
  RestServiceResult<string> result = await this.ServiceClient.Webhooks.CreateSubscriptionAsync(request).ConfigureAwait(false);

  string subscriptionId = result.Value;

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Update Subscription

Updates an existing subscription.

Parameters

Parameter Description Example
SubscriptionId The identifier of the subscription that should be updated.
ClientId The unique identifier of the client application that subscribed the webhook. MyApplication
EventNames A list containing the names of the events being subscribed. [ElectronicSealParent_Activated]
CallbackUrl The address of the endpoint that should receive the webhook callback. https://server.io/callback
Secret A shared secret, defined by the client application, that can be used to authenticate the callbacks. MySpecialSecret
DeadLettering.Enabled A value indicating whether the subscription should support dead-lettering. false
DeadLettering.Configuration The configuration that should be use for dead-lettering (when enabled). See Dead-lettering
Active A value indicating whether the subscription should be activated. true

Example (HTTP)

PUT /api/v{version:apiVersion}/webhooks
content-type: application/json
body:
{
  "subscriptionId": "{SubscriptionId}",
  "clientId": "{ClientId}",
  "eventNames": [
    "{EventName}
  ],
  "callbackUrl": "{CallbackUrl}",
  "secret": "{Secret}",
  "deadLettering": {
    "enabled": false,
    "configuration": null
  },
  "active": true
}

Example (Client Library)

UpdateWebhookSubscriptionRequest request = new UpdateWebhookSubscriptionRequest()
{
  (...)
};

try
{
  RestServiceResult result = await this.ServiceClient.Webhooks.UpdateSubscriptionAsync(request).ConfigureAwait(false);

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Delete Subscription

Deletes an existing subscription.

Parameters

Parameter Description Example
ClientId The unique identifier of the client application that subscribed the webhook. MyApplication
SubscriptionId The identifier of the subscription that should be deleted.

Example (HTTP)

DELETE /api/v{version:apiVersion}/webhooks/{clientId}/{subscriptionId}

Example (Client Library)

try
{
  RestServiceResult result = await this.ServiceClient.Webhooks.DeleteSubscriptionAsync("{ClientId}", "{SubscriptionId}").ConfigureAwait(false);

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Get Webhooks Metadata

Retrieves metadata about all the webhooks available.

Result

The webhooks metadata.

[
  {
    "eventName": "{EventName}",
    "eventDescription": "{EventDescription}",
    "PayloadDescription": "{PayloadDescription}"
  }
]

Example (HTTP)

GET /api/v{version:apiVersion}/webhooks

Example (Client Library)

try
{
  RestServiceResult<IList<WebhookMetadata>> result = await this.ServiceClient.Webhooks.GetWebhooksMetadataAsync().ConfigureAwait(false);

  IList<WebhookMetadata> metadata = result.Value;

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Get Subscription

Retrieves a subscription.

Parameters

Parameter Description Example
ClientId The unique identifier of the client application that subscribed the webhook. MyApplication
SubscriptionId The identifier of the subscription that should be retrieved.

Result

The subscription information.

{
  "clientId": "{ClientId}",
  "subscriptionId": "{SubscriptionId}",
  "eventNames": ["{EventName1}", "{EventName2}"],
  "secret": "{Secret}",
  "callbackUrl": "{CallbackUrl}",
  "filters": {
    "{Filter1}": "{Value1}",
    "{Filter2}": "{Value2}"
  },
  "properties": {
    "{Property1}": "{Value1}",
    "{Property2}": "{Value2}"
  },
  "deadLettering": {
    "enabled": true,
    "configuration": "{Configuration}"
  },
  "active": true,
  "modifiedOn": {ModifiedOn},
  "lastRequest": {
    (...)
  },
  "lastResponse": {
    (...)
  }
}

Example (HTTP)

GET /api/v{version:apiVersion}/webhooks/{clientId}/{subscriptionId}

Example (Client Library)

try
{
  RestServiceResult<WebhookSubscription> result = await this.ServiceClient.Webhooks.GetSubscriptionAsync("{ClientId}", "{SubscriptionId}").ConfigureAwait(false);

  WebhookSubscription subscription = result.Value;

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Get Subscriptions

Retrieves all the subscriptions for a given client.

Parameters

Parameter Description Example
ClientId The unique identifier of the client application that subscribed the webhooks. MyApplication

Result

A list containing the subscriptions information (as in Get Subscription).

Example (HTTP)

GET /api/v{version:apiVersion}/webhooks/{clientId}

Example (Client Library)

try
{
  RestServiceResult<IList<WebhookSubscription>> result = await this.ServiceClient.Webhooks.GetSubscriptionsAsync("{ClientId}").ConfigureAwait(false);

  IList<WebhookSubscription> subscriptions = result.Value;

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Delete Subscriptions

Deletes all the subscriptions for a given client.

Parameters

Parameter Description Example
ClientId The unique identifier of the client application that subscribed the webhooks. MyApplication

Example (HTTP)

DELETE /api/v{version:apiVersion}/webhooks/{clientId}

Example (Client Library)

try
{
  RestServiceResult result = await this.ServiceClient.Webhooks.DeleteSubscriptionsAsync("{ClientId}").ConfigureAwait(false);

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Ping Subscription

Pings a subscription.

Parameters

Parameter Description Example
ClientId The unique identifier of the client application that subscribed the webhook. MyApplication
SubscriptionId The identifier of the subscription that should be invoked.

Example (HTTP)

POST /api/v{version:apiVersion}/webhooks/{clientId}/{subscriptionId}/ping

Example (Client Library)

try
{
  RestServiceResult result = await this.ServiceClient.Webhooks.PingSubscriptionAsync("{ClientId}", "{SubscriptionId}").ConfigureAwait(false);

  (...)
}
catch (RestRequestException ex)
{
  (...)
}

^ Back to top

Callbacks

When a webhook event occurs, the callback URL will be invoked for all active subscriptions.

This callback is a request to the endpoint configured in the subscription, including the webhook payload in the content.

Additionally, the following headers will be sent in the request, allowing the client application to identify the concrete event and authenticate the request.

Header Description Example
X-Webhook-Application The identifier of the application sending the callback. CS
X-Webhook-Event The identifier of the event that triggered the callback. ElectronicSealParent_Activated
X-Webhook-Delivery A unique identifier of the callback (it will be the same for all retries). 8f2cad06-73bd-4eb3-98ef-1a78b53506db
X-Webhook-Signature The HMAC SHA256 signature of the payload, computed using the secret provided by the client application when the subscription was created or last updated. sha256=4C3019F69CD9AA11ECF24EF3D9F10AB97CF3B0F0662F1718291615152E2213C3
X-Webhook-Properties The properties specified by the client application when the subscription was created or last updated. These properties can be used by the client application to pass state to the callbacks.

^ Back to top

Dead-lettering

If the webhooks server supports dead-lettering, then it can be enabled when creating or updating webhooks subscriptions.

This feature ensures the availability to the client application of all the events occurred, because, when the server is not able to deliver a webhook (for example, if the client is down), after retrying the configured number of times, it will store the event in the blobs storage account provided by the client configuration. The client can inspect this blob storage and recover all the missed events.

The configuration is provided using the DeadLettering.Configuration setting, when creating/updating a subscription. This should be a config string (a string in the form prop1=value;prop2=value) specifying how the server should connect to the storage account, using the following properties:

Notice that you can either specify the connection using ConnectionString OR ServiceUri, TenantId, ClientId, and ClientSecret.

The values passed in for ConnectionString, ServiceUri, TenantId, ClientId, and ClientSecret need to be escaped, by replacing the following chars:

Each dead-letter will be a JSON file stored in the blob container and named <EventName>-<Timestamp>-<RandomString>.

^ Back to top