Site iconAxway Blog

Amplify Central: Add Headers to an Integration Webhook

how to add headers to an Integration Webhook

In a prior post, we discussed secrets for an Integration Webhook Authorization header.

However, what if your Webhook requires a different header, such as an API Key? Let’s look at how to add an API Key Header (or any non Authorization header, for that matter) to your Integration Webhook.

Modify your YAML

Recall that in this blog post we saw how we can use the Axway Central CLI and a YAML file (resources.yaml) to create an Integration Webhook.

For example, if I want to modify my existing Integration Webhook and send the following two API Keys with my Webhook:

"apikey": "1234",
"x-apikey": "5678"

I could add the following to my YAML file in the Webhook -> spec section:

headers:
  apikey: "1234"
  x-apikey: "5678"

The complete updated YAML file is shown below:

name: myintegration
kind: Integration
apiVersion: v1alpha1
title: Integration
tags:
- cloud
spec:
    description: This is an integration.
---
name: webhooksecret
kind: Secret
apiVersion: v1alpha1
title: API Key Secret for Webhook reference
tags:
- saas
- axway
metadata:
  scope:
    kind: Integration
    name: myintegration
spec:
    data:
      apikey: Password123
---
name: webhook
kind: Webhook
apiVersion: v1alpha1
title: Webhook to invoke requestbin.com
tags:
- prod
- saas
- axway
attributes:
  release: 1.0.0
metadata:
  scope:
    kind: Integration
    name: myintegration
spec:
    enabled: true
    url: https://en9c5wvi5vta4.x.pipedream.net
    headers:
      apikey: "1234"
      x-apikey: "5678"
    auth:
      secret:
        name: webhooksecret
        key: apikey
---
group: management
apiVersion: v1alpha1
kind: ResourceHook
name: environments-hook
title: Monitor Environment manualenv and all its resources
metadata:
  scope:
    kind: Integration
    name: myintegration
spec:
  triggers:
    - group: management
      kind: Environment
      name: manualenv
      type:
      - created
      - updated
      - deleted
    - group: management
      kind: "*"
      name: "*"
      type:
      - created
      - updated
      - deleted
      scope:
        kind: Environment
        name: manualenv
  webhooks:
    - webhook

Update Existing Integration Webhook

Now, I can update my previously created Integration Webhook as follows:

axway central apply -f resources.yaml

Note that if you don’t have an existing Integration Webhook already created, then you can create it using axway central create -f resources.yaml

When an event triggers the Webhook, the headers will be sent as part of the Webhook as shown below:

Webhook with Headers Sent to Requestbin

Summary

In this blog post, we saw how to create headers for our Integration Webhook and how to update an existing Integration Webhook using the Axway Central CLI.

Learn more about Amplify Central Integration Webhooks — API Publish Approval.

Exit mobile version