Edit

Share via


Azure API Management as an Event Grid source

This article provides the properties and schema for Azure API Management events. For an introduction to event schemas, see Azure Event Grid event schema. It also gives you links to articles to use API Management as an event source.

Available event types

API Management emits the following event types:

Event type Description
Microsoft.ApiManagement.UserCreated Raised when a user is created.
Microsoft.ApiManagement.UserUpdated Raised when a user is updated.
Microsoft.ApiManagement.UserDeleted Raised when a user is deleted.
Microsoft.ApiManagement.APICreated Raised when an API is created.
Microsoft.ApiManagement.APIUpdated Raised when an API is updated.
Microsoft.ApiManagement.APIDeleted Raised when an API is deleted.
Microsoft.ApiManagement.ProductCreated Raised when a product is created.
Microsoft.ApiManagement.ProductUpdated Raised when a product is updated.
Microsoft.ApiManagement.ProductDeleted Raised when a product is deleted.
Microsoft.ApiManagement.APIReleaseCreated Raised when an API release is created.
Microsoft.ApiManagement.APIReleaseUpdated Raised when an API release is updated.
Microsoft.ApiManagement.APIReleaseDeleted Raised when an API release is deleted.
Microsoft.ApiManagement.SubscriptionCreated Raised when a subscription is created.
Microsoft.ApiManagement.SubscriptionUpdated Raised when a subscription is updated.
Microsoft.ApiManagement.SubscriptionDeleted Raised when a subscription is deleted.
Microsoft.ApiManagement.GatewayCreated Raised when a self-hosted gateway is created.
Microsoft.ApiManagement.GatewayDeleted Raised when a self-hosted gateway is updated.
Microsoft.ApiManagement.GatewayUpdated Raised when a self-hosted gateway is deleted.
Microsoft.ApiManagement.GatewayAPIAdded Raised when an API is added to a self-hosted gateway.
Microsoft.ApiManagement.GatewayAPIRemoved Raised when an API is removed from a self-hosted gateway.
Microsoft.ApiManagement.GatewayCertificateAuthorityCreated Raised when a certificate authority is updated for a self-hosted gateway.
Microsoft.ApiManagement.GatewayCertificateAuthorityDeleted Raised when a certificate authority is deleted for a self-hosted gateway.
Microsoft.ApiManagement.GatewayCertificateAuthorityUpdated Raised when a certificate authority is updated for a self-hosted gateway.
Microsoft.ApiManagement.GatewayHostnameConfigurationCreated Raised when a hostname configuration is created for a self-hosted gateway.
Microsoft.ApiManagement.GatewayHostnameConfigurationDeleted Raised when a hostname configuration is deleted for a self-hosted gateway.
Microsoft.ApiManagement.GatewayHostnameConfigurationUpdated Raised when a hostname configuration is updated for a self-hosted gateway.
Microsoft.ApiManagement.GatewayTokenNearExpiry (preview) Raised when a self-hosted gateway access token is near expiry.
Microsoft.ApiManagement.GatewayTokenExpired (preview) Raised when a self-hosted gateway access token is expired.
Microsoft.ApiManagement.CircuitBreaker.Opened (preview) Raised when a backend circuit breaker is opened.
Microsoft.ApiManagement.CircuitBreaker.Closed (preview) Raised when a backend circuit breaker is closed.

Example event

The following example shows the schema of a product created event. The schema of other API Management resource created events is similar.

[{
  "id": "81dac958-49cf-487e-8805-d0baf0ee485a",
  "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}",
  "subject": "/products/myproduct",
  "data": {
    "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/products/myproduct"
  },
  "Type": "Microsoft.ApiManagement.ProductCreated",
  "Time": "2021-07-02T00:38:44.3978295Z",
  "specversion":"1.0"
}]

The following example shows the schema of a user deleted event. The schema of other API Management resource deleted events is similar.

[{
  "id": "81dac958-49cf-487e-8805-d0baf0ee485a",
  "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}",
  "subject": "/users/apimuser-contoso-com",
  "data": {
    "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/users/apimuser-contoso-com"
  },
  "Type": "Microsoft.ApiManagement.UserDeleted",
  "Time": "2021-07-02T00:38:44.3978295Z",
  "specversion":"1.0"
}]

The following example shows the schema of an API updated event. The schema of other API Management resource updated events is similar.

[{
  "id": "95015754-aa51-4eb6-98d9-9ee322b82ad7",
  "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}",
  "subject": "/apis/myapi;Rev=1",
  "data": {
    "resourceUri": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}/apis/myapi;Rev=1"
  },
  "Type": "Microsoft.ApiManagement.APIUpdated",
  "Time": "2021-07-12T23:13:44.9048323Z",
  "specversion":1.0
}]

The following example shows the schema of a circuit breaker opened event.

{
  "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}",
  "subject": "/backends/{backend-name}/circuit-breaker/rules/{rule-name}",
  "type": "Microsoft.ApiManagement.CircuitBreaker.Opened",
  "time": "2025-04-02T00:47:47.8536532Z",
  "id": "92c502f2-a966-42a7-a428-d3b319844544",
  "data": {
    "backendName": "{backend-name}",
    "circuitBreaker": {
      "rules": {
        "{rule-name}": {
          "tripDuration": "00:00:01"
        }
      }
    }
  },
  "specVersion": "1.0"
}

The following example shows the schema of a gateway token expired event. The schema of a gateway token near expiry event is similar, but substitutes an expiresAtUtc property for the expiredAtUtc property.

{
  "source": "/subscriptions/{subscription-id}/resourceGroups/{your-rg}/providers/Microsoft.ApiManagement/service/{your-APIM-instance}",
  "subject": "/gateways/{gateway-name}/{instance-name}",
  "type": "Microsoft.ApiManagement.GatewayTokenExpired",
  "time": "2025-04-02T00:47:47.8536532Z",
  "id": "92c502f2-a966-42a7-a428-d3b319844544",
  "data": {
    "gatewayInfo": {
      "gatewayId": "{gateway-name}",
      "instanceId": "{instance-name}"
    },
    "tokenInfo": {
      "expiredAtUtc": "2025-02-25T08:56:00.0000000Z"
    }
  },
  "specVersion": "1.0"
}

Event properties

An event has the following top-level data:

Property Type Description
source string Full resource path to the event source. This field isn't writeable. Event Grid provides this value.
subject string Publisher-defined path to the event subject.
type string One of the registered event types for this event source.
time string The time the event is generated based on the provider's UTC time.
id string Unique identifier for the event.
data object API Management event data.
specversion string CloudEvents schema specification version.

Data object properties

Control plane events

The data object has the following properties for control plane events such as creating, updating, and deleting API Management resources.

Property Type Description
resourceUri string The fully qualified ID of the resource that the compliance state change is for, including the resource name and resource type. Uses the format, /subscriptions/<SubscriptionID>/resourceGroups/<ResourceGroup>/Microsoft.ApiManagement/service/<ServiceName>/<ResourceType>/<ResourceName>

Circuit breaker events

The data object has the following properties for circuit breaker events.

Property Type Description
backendNme string The name (ID) of the backend entity in which the circuit breaker is configured.
circuitBreaker object The circuit breaker configured in the backend, consisting of a rules object specifying the rule that tripped the backed. The rule has a tripDuration property in hh:mm:ss format specifying the duration for which the circuit breaker is tripped.

Self-hosted gateway authentication token events

The data object has the following properties for self-hosted gateway authentication token events.

Property Type Description
gatewayInfo object The self-hosted gateway information, consisting of the following string properties:

* gatewayId - The fully qualified ID of the gateway resource
* instanceId - Unique instance ID of the deployed gateway
tokenInfo object The token information, consisting of one of the following properties in the provider's UTC time:

* expiresAtUtc - for GatewayTokenNearExpiry event, or
* expiredAtUtc - for GatewayTokenExpired event

Tutorials and how-tos

Title Description
Send events from API Management to Event Grid How to subscribe to API Management events using Event Grid.

Next steps