# Webhooks

Webhooks are used to notify external systems of changes within Struct PIM through a web request

## Get a webhook

> \#Available from v.3.11.0

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}},"schemas":{"Struct.App.Api.Models.Webhook.WebhookModel":{"type":"object","properties":{"Uid":{"type":"string","description":"Unique id of webhook","format":"uuid"},"Title":{"type":"string","description":"Title of webhook","nullable":true},"Url":{"type":"string","description":"Url for the webhook to request when triggered","nullable":true},"Active":{"type":"boolean","description":"Activate / deactivate webhook"},"EnabledEvents":{"type":"array","items":{"type":"string"},"description":"Events this webhook shall act on","nullable":true},"AdvancedSettings":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.EventSettings"},"description":"Advanced settings for events supporting this","nullable":true},"RequestHeaders":{"type":"array","items":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader"},"description":"Request headers to be added to webhook requests","nullable":true}},"additionalProperties":false,"description":"Model representing a webhook"},"Struct.App.Api.Models.Webhook.EventSettings":{"type":"object","properties":{"EventSettingsType":{"type":"string","nullable":true,"readOnly":true}},"additionalProperties":false},"Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader":{"type":"object","properties":{"Name":{"type":"string","description":"Name of the header","nullable":true},"Value":{"type":"string","description":"Value of the header","nullable":true}},"additionalProperties":false,"description":"Represents a request header to be added to webhook requests"}}},"paths":{"/v1/webhooks/{uid}":{"get":{"tags":["Webhooks"],"summary":"Get a webhook","description":"#Available from v.3.11.0","parameters":[{"name":"uid","in":"path","description":"Uid of webhook","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel"}}}}}}}}}
```

## DELETE /v1/webhooks/{uid}

> Delete a webhook

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}}},"paths":{"/v1/webhooks/{uid}":{"delete":{"tags":["Webhooks"],"summary":"Delete a webhook","parameters":[{"name":"uid","in":"path","description":"Uid of webhook to delete","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"OK"}}}}}}
```

## GET /v1/webhooks

> Get all configured webhooks

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}},"schemas":{"Struct.App.Api.Models.Webhook.WebhookModel":{"type":"object","properties":{"Uid":{"type":"string","description":"Unique id of webhook","format":"uuid"},"Title":{"type":"string","description":"Title of webhook","nullable":true},"Url":{"type":"string","description":"Url for the webhook to request when triggered","nullable":true},"Active":{"type":"boolean","description":"Activate / deactivate webhook"},"EnabledEvents":{"type":"array","items":{"type":"string"},"description":"Events this webhook shall act on","nullable":true},"AdvancedSettings":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.EventSettings"},"description":"Advanced settings for events supporting this","nullable":true},"RequestHeaders":{"type":"array","items":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader"},"description":"Request headers to be added to webhook requests","nullable":true}},"additionalProperties":false,"description":"Model representing a webhook"},"Struct.App.Api.Models.Webhook.EventSettings":{"type":"object","properties":{"EventSettingsType":{"type":"string","nullable":true,"readOnly":true}},"additionalProperties":false},"Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader":{"type":"object","properties":{"Name":{"type":"string","description":"Name of the header","nullable":true},"Value":{"type":"string","description":"Value of the header","nullable":true}},"additionalProperties":false,"description":"Represents a request header to be added to webhook requests"}}},"paths":{"/v1/webhooks":{"get":{"tags":["Webhooks"],"summary":"Get all configured webhooks","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel"}}}}}}}}}}
```

## POST /v1/webhooks

> Create a new webhook

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}},"schemas":{"Struct.App.Api.Models.Webhook.WebhookModel":{"type":"object","properties":{"Uid":{"type":"string","description":"Unique id of webhook","format":"uuid"},"Title":{"type":"string","description":"Title of webhook","nullable":true},"Url":{"type":"string","description":"Url for the webhook to request when triggered","nullable":true},"Active":{"type":"boolean","description":"Activate / deactivate webhook"},"EnabledEvents":{"type":"array","items":{"type":"string"},"description":"Events this webhook shall act on","nullable":true},"AdvancedSettings":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.EventSettings"},"description":"Advanced settings for events supporting this","nullable":true},"RequestHeaders":{"type":"array","items":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader"},"description":"Request headers to be added to webhook requests","nullable":true}},"additionalProperties":false,"description":"Model representing a webhook"},"Struct.App.Api.Models.Webhook.EventSettings":{"type":"object","properties":{"EventSettingsType":{"type":"string","nullable":true,"readOnly":true}},"additionalProperties":false},"Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader":{"type":"object","properties":{"Name":{"type":"string","description":"Name of the header","nullable":true},"Value":{"type":"string","description":"Value of the header","nullable":true}},"additionalProperties":false,"description":"Represents a request header to be added to webhook requests"}}},"paths":{"/v1/webhooks":{"post":{"tags":["Webhooks"],"summary":"Create a new webhook","requestBody":{"description":"Webhook to create","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel"}}}},"responses":{"200":{"description":"OK"}}}}}}
```

## PUT /v1/webhooks

> Update a webhook

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}},"schemas":{"Struct.App.Api.Models.Webhook.WebhookModel":{"type":"object","properties":{"Uid":{"type":"string","description":"Unique id of webhook","format":"uuid"},"Title":{"type":"string","description":"Title of webhook","nullable":true},"Url":{"type":"string","description":"Url for the webhook to request when triggered","nullable":true},"Active":{"type":"boolean","description":"Activate / deactivate webhook"},"EnabledEvents":{"type":"array","items":{"type":"string"},"description":"Events this webhook shall act on","nullable":true},"AdvancedSettings":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.EventSettings"},"description":"Advanced settings for events supporting this","nullable":true},"RequestHeaders":{"type":"array","items":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader"},"description":"Request headers to be added to webhook requests","nullable":true}},"additionalProperties":false,"description":"Model representing a webhook"},"Struct.App.Api.Models.Webhook.EventSettings":{"type":"object","properties":{"EventSettingsType":{"type":"string","nullable":true,"readOnly":true}},"additionalProperties":false},"Struct.App.Api.Models.Webhook.WebhookModel_RequestHeader":{"type":"object","properties":{"Name":{"type":"string","description":"Name of the header","nullable":true},"Value":{"type":"string","description":"Value of the header","nullable":true}},"additionalProperties":false,"description":"Represents a request header to be added to webhook requests"}}},"paths":{"/v1/webhooks":{"put":{"tags":["Webhooks"],"summary":"Update a webhook","requestBody":{"description":"Webhook to update","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookModel"}}}},"responses":{"200":{"description":"OK"}}}}}}
```

## GET /v1/webhooks/{webhookUid}/requests

> Get requests made from a webhook. Note that webhook requests are only stored for 14 days

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}},"schemas":{"Struct.App.Api.Models.Webhook.WebhookRequestSearchResult":{"type":"object","properties":{"WebhookRequests":{"type":"array","items":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookRequestModel"},"description":"Webhook requests that matched the criteria","nullable":true},"Page":{"type":"integer","description":"Page of the search request","format":"int32"},"TotalHits":{"type":"integer","description":"Total number of hits in the search","format":"int32"}},"additionalProperties":false,"description":"Model containing response from a webhook request search"},"Struct.App.Api.Models.Webhook.WebhookRequestModel":{"type":"object","properties":{"Uid":{"type":"string","description":"Unique id of this webhook request (Passed in the X-Request-UID header of the request)","format":"uuid"},"WebhookUid":{"type":"string","description":"Unique id of the webhook that triggered the request (Passed in the X-Hook-UID header of the request)","format":"uuid"},"WebhookUrl":{"type":"string","description":"Url that was called","nullable":true},"EventKey":{"type":"string","description":"The key of the event that triggered the event (Passed in the X-Event-Key header of the request)","nullable":true},"EventTimestamp":{"type":"string","description":"Timestamp of the event that triggered the webhook request","format":"date-time"},"RequestTimestamp":{"type":"string","description":"Timestamp of when the webhook request was made","format":"date-time"},"RequestHeaders":{"type":"object","additionalProperties":{"type":"string"},"description":"The request headers sent in the webhook request","nullable":true},"RequestBody":{"type":"string","description":"The request body sent in the webhook request","nullable":true},"ElapsedMilliseconds":{"type":"integer","description":"The time in ms it took to get a response from the recipient of the request","format":"int64"},"ResponseCode":{"type":"integer","description":"The response code of the webhook request","format":"int32"},"ResponseHeaders":{"type":"object","additionalProperties":{"type":"string"},"description":"The response headers received from the request","nullable":true},"ParentWebhookRequestUid":{"type":"string","description":"Uid of parent webhook request (only has value, if this is a retry of a failed webhook request)","format":"uuid","nullable":true},"IsRetry":{"type":"boolean","description":"Indicates whether this request is a retry of a previously failed request","readOnly":true}},"additionalProperties":false,"description":"Model representing a webhook request"}}},"paths":{"/v1/webhooks/{webhookUid}/requests":{"get":{"tags":["Webhooks"],"summary":"Get requests made from a webhook. Note that webhook requests are only stored for 14 days","parameters":[{"name":"webhookUid","in":"path","description":"Uid of webhook","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"since","in":"query","description":"return webhook requests newer than this timestamp","schema":{"type":"string","format":"date-time"}},{"name":"onlyFailed","in":"query","description":"Only return failed webhook requests","schema":{"type":"boolean"}},{"name":"page","in":"query","description":"Page to get (1 is first page)","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookRequestSearchResult"}}}}}}}}}
```

## GET /v1/webhooks/{webhookUid}/requests/{requestUid}

> Get a specific request made from a webhook. Note that webhook requests are only stored for 14 days

```json
{"openapi":"3.0.1","info":{"title":"Struct PIM Public API","version":"1.0"},"tags":[{"name":"Webhooks","description":"Webhooks are used to notify external systems of changes within Struct PIM through a web request"}],"security":[{"ApiKey":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","description":"","name":"Authorization","in":"header"}},"schemas":{"Struct.App.Api.Models.Webhook.WebhookRequestModel":{"type":"object","properties":{"Uid":{"type":"string","description":"Unique id of this webhook request (Passed in the X-Request-UID header of the request)","format":"uuid"},"WebhookUid":{"type":"string","description":"Unique id of the webhook that triggered the request (Passed in the X-Hook-UID header of the request)","format":"uuid"},"WebhookUrl":{"type":"string","description":"Url that was called","nullable":true},"EventKey":{"type":"string","description":"The key of the event that triggered the event (Passed in the X-Event-Key header of the request)","nullable":true},"EventTimestamp":{"type":"string","description":"Timestamp of the event that triggered the webhook request","format":"date-time"},"RequestTimestamp":{"type":"string","description":"Timestamp of when the webhook request was made","format":"date-time"},"RequestHeaders":{"type":"object","additionalProperties":{"type":"string"},"description":"The request headers sent in the webhook request","nullable":true},"RequestBody":{"type":"string","description":"The request body sent in the webhook request","nullable":true},"ElapsedMilliseconds":{"type":"integer","description":"The time in ms it took to get a response from the recipient of the request","format":"int64"},"ResponseCode":{"type":"integer","description":"The response code of the webhook request","format":"int32"},"ResponseHeaders":{"type":"object","additionalProperties":{"type":"string"},"description":"The response headers received from the request","nullable":true},"ParentWebhookRequestUid":{"type":"string","description":"Uid of parent webhook request (only has value, if this is a retry of a failed webhook request)","format":"uuid","nullable":true},"IsRetry":{"type":"boolean","description":"Indicates whether this request is a retry of a previously failed request","readOnly":true}},"additionalProperties":false,"description":"Model representing a webhook request"}}},"paths":{"/v1/webhooks/{webhookUid}/requests/{requestUid}":{"get":{"tags":["Webhooks"],"summary":"Get a specific request made from a webhook. Note that webhook requests are only stored for 14 days","parameters":[{"name":"webhookUid","in":"path","description":"Uid of webhook","required":true,"schema":{"type":"string","format":"uuid"}},{"name":"requestUid","in":"path","description":"Uid of webhook request","required":true,"schema":{"type":"string","format":"uuid"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Struct.App.Api.Models.Webhook.WebhookRequestModel"}}}}}}}}}
```
