Webhook Recipes
Purpose
This page gives step-by-step setups for the senders integrators connect most often: GitHub, Jira Cloud, ServiceNow, Power Automate and Azure Logic Apps, and your own code — with signing examples in curl and OpenSSL, Node.js, Python and C#. It also shows the relay pattern for Azure Event Grid and Slack, which need a handshake the platform does not perform. Each recipe ends with a check on the Agent Triggers page.
Starting Agents From Webhooks explains the concepts — signatures, delivery ids, responses, and how the body reaches the agent. Read it first.
Common Preparation
Every recipe starts the same way, in the Portal:
- Make sure the hosted agent exists and is active, and that a run identity allowed for it exists under Security → Agent Run Identities (see Run Identities).
- Open Apps & Tools → Agent Triggers, choose New trigger, pick the tenant (global sessions), the agent and the kind Webhook.
- Write the instructions for one event, choose the run identity, and use Check identity — it should say Ready (see Check identity).
- Choose the Sender preset named in the recipe, review the delivery settings, and choose Save.
- For a signed webhook, copy the signing secret from the dialog that appears on saving — it is shown only once. Then open the trigger and copy the Webhook URL from its Delivery section.
The examples use https://apimapper.example.com as the platform's address and whsec_REPLACE_ME as the secret.
Check It Worked
Every recipe ends with the same check:
- Make the sender deliver once — most senders have a test or redeliver action.
- In Apps & Tools → Agent Triggers, open the Executions tab and filter by the agent and the channel Webhook. A new execution appears within seconds, and refreshes on its own while it is queued or running.
- Select it. Its summary shows the status, which ends
Completed; if it does not, the reason and failure kind say why — see Monitoring & Troubleshooting. Open the run, and its Overview tab shows the Input: the trigger's instructions and the event payload, marked untrusted. - If no execution appeared, look at the sender's own delivery log for the HTTP status, and match it against the
response table. A refusal after the URL was recognized is also in the
audit log as
agent.trigger.refused, with the reason.
GitHub
GitHub signs with X-Hub-Signature-256 and identifies each delivery with X-GitHub-Delivery.
- Trigger. Choose the GitHub preset: Hub signature, signature header
X-Hub-Signature-256, delivery id from theX-GitHub-Deliveryheader. Raise Largest body if your events are large — push events with many commits can exceed the 64 KB default. - Source ranges (optional). GitHub publishes its webhook source addresses in the
hookslist ofhttps://api.github.com/meta. They change from time to time; if you set them, keep them current. - GitHub. In the repository or organization: Settings → Webhooks → Add webhook.
- Payload URL: the trigger's webhook URL.
- Content type:
application/json. GitHub's default,application/x-www-form-urlencoded, is refused with415. - Secret: the trigger's signing secret.
- Which events: only the events the agent should act on, for example Pull requests.
- Instructions, for example: "A pull request event follows. If its action is
openedorsynchronize, review the changed files with the repository tools and post one summary comment. Otherwise do nothing and say so." - Check it worked. GitHub sends a
pingevent when the webhook is created; its Recent Deliveries tab shows the response and has Redeliver. A redelivery reuses the delivery id, so the platform answers200with the original execution rather than running again. Then follow Check It Worked.
Jira Cloud
Jira Cloud signs its webhooks only when they are registered through its REST API with a secret. Webhooks created in Jira's administration screens (System → WebHooks) are sent unsigned and cannot use the hub signature profile. For those, either register the webhook through the REST API instead, or put a relay in front (see Relaying Senders The Platform Cannot Accept Directly).
A signed Jira Cloud delivery carries X-Hub-Signature: sha256=… — note: not -256 — and a delivery id in
X-Atlassian-Webhook-Identifier.
Trigger. Choose the Jira Cloud preset: Hub signature, signature header
X-Hub-Signature, delivery id from theX-Atlassian-Webhook-Identifierheader.Jira. Register the webhook with Jira's REST API, as a Jira administrator, passing the trigger's URL, the events and a JQL filter, and the trigger's signing secret as the webhook's secret. For example:
curl -X POST "https://<your-site>.atlassian.net/rest/webhooks/1.0/webhook" \ -u "<admin-email>:<atlassian-api-token>" \ -H "Content-Type: application/json" \ -d '{ "name": "Agent: triage new incidents", "url": "https://apimapper.example.com/runtime/hooks/agents/<public-id>", "events": ["jira:issue_created"], "filters": { "issue-related-events-section": "project = OPS AND issuetype = Incident" }, "secret": "whsec_REPLACE_ME" }'Atlassian's registration APIs change over time; check its current documentation for the endpoint that applies to your site or app, and that it accepts a secret.
Instructions, for example: "A Jira issue event follows. Classify the incident's severity from its summary and description, and set the priority field with the Jira tool."
Check it worked. Create a matching issue, then follow Check It Worked. A
401means the delivery was unsigned or the secret differs; confirm the webhook was registered with the secret and that the trigger readsX-Hub-Signature.
ServiceNow (Outbound REST With A Bearer Token)
ServiceNow can obtain an OAuth token with client credentials and send it on an outbound REST message. Use the trigger's bearer mode.
- Identity provider. Register an application for ServiceNow in your identity provider (Microsoft Entra ID, Okta, Keycloak…) with a client secret, and make sure that provider is configured as a Trusted Identity Provider for the tenant, with the application's token audience and client id allowed (see Authentication).
- Trigger. Authentication: Bearer token from a trusted identity provider. Choose the provider, and put the
ServiceNow application's client id in Allowed client ids. For a delivery id, use the header
Idempotency-Key, or a JSON pointer to a field your payload always carries, such as/sys_id. - ServiceNow.
- System OAuth → Application Registry → New → Connect to a third party OAuth Provider: the client id and
secret from step 1, the provider's token URL, grant type Client Credentials, and the scope the provider
expects for the platform (for Entra ID,
<application-id-uri>/.default). - System Web Services → Outbound → REST Message → New: endpoint = the trigger's webhook URL, authentication
type OAuth 2.0 with that profile. Add an HTTP method
POSTwith headerContent-Type: application/json, and anIdempotency-Keyheader bound to a variable. - Call it from a Business Rule or a Flow Designer action, passing a JSON body built from the record and a key
that is unique per event — for example the record's
sys_idandsys_mod_countjoined, so each update is a new event but a resend of the same update is not.
- System OAuth → Application Registry → New → Connect to a third party OAuth Provider: the client id and
secret from step 1, the provider's token URL, grant type Client Credentials, and the scope the provider
expects for the platform (for Entra ID,
- Check it worked. Test the REST message from ServiceNow, then follow Check It Worked. A
401with a valid-looking token usually means the token's issuer, audience or client id does not match the trusted identity provider entry; decode the token and compare.
Power Automate And Azure Logic Apps
Both use the HTTP action and can authenticate it with Microsoft Entra ID. Use the trigger's bearer mode with an Entra ID trusted identity provider.
- Entra ID. Register an application (or, for Logic Apps, use the app's managed identity), and expose the platform's API to it as for any application caller — see Registering a client-credentials application for the Entra steps, which are the same for a sender.
- Trigger. Authentication: Bearer token from a trusted identity provider, the Entra ID provider, and the
application's client id (or the managed identity's) in Allowed client ids. Leave Required scopes empty: Entra
application tokens carry roles, not scopes. Delivery id: the
Idempotency-Keyheader. - The HTTP action.
- Method
POST, URI the trigger's webhook URL. - Headers
Content-Type: application/jsonandIdempotency-Keyset to a value unique per event — for example the triggering item's id. - Body the JSON the agent should see.
- Authentication: Active Directory OAuth (Power Automate) with the tenant, the audience — your platform API's application id URI — the client id and the secret; or Managed identity (Logic Apps) with that audience.
- Leave the action's retry policy on: it retries
429and5xx, and the idempotency key makes a retry safe.
- Method
- Check it worked. Run the flow once, then follow Check It Worked. The flow's run history
shows the response:
202with anexecutionId.
A Custom Sender
Use the Your own sender (ApiMapper v1) preset. Each example signs one delivery with the secret read from an
environment variable, and sends an Idempotency-Key that is unique per event. In every language the rules are the
same:
- the signing input is
{timestamp}.{body}— Unix seconds, a dot, the exact body bytes; - the key is the whole secret string,
whsec_included, as UTF-8; - the signature header is
v1=plus lowercase hex; - sign the bytes you send, and send them unchanged.
curl and OpenSSL
#!/usr/bin/env bash
set -euo pipefail
URL='https://apimapper.example.com/runtime/hooks/agents/<public-id>'
BODY='{"event":"invoice.overdue","id":"evt-20261031-0042","invoice":"INV-7781"}'
TS=$(date +%s)
SIG=$(printf '%s.%s' "$TS" "$BODY" | openssl dgst -sha256 -hmac "$WEBHOOK_SECRET" | sed 's/^.* //')
curl -sS -X POST "$URL" \
-H 'Content-Type: application/json' \
-H "X-ApiMapper-Timestamp: $TS" \
-H "X-ApiMapper-Signature: v1=$SIG" \
-H 'Idempotency-Key: evt-20261031-0042' \
--data-raw "$BODY"
printf '%s' adds no trailing newline, and --data-raw sends the body exactly as signed.
Node.js (18 or later)
With the TypeScript SDK (@codedprojects/api-mapper-client 1.3.0 or later, on Node.js 20 or later),
AgentWebhookSignature computes the header values — see
Signing A Webhook Delivery. Without it, node:crypto is enough:
import { createHmac } from "node:crypto";
const url = "https://apimapper.example.com/runtime/hooks/agents/<public-id>";
const secret = process.env.WEBHOOK_SECRET;
export async function deliver(event) {
const body = JSON.stringify(event); // serialize once; sign and send these bytes
const timestamp = Math.floor(Date.now() / 1000).toString();
const signature = createHmac("sha256", secret).update(`${timestamp}.${body}`, "utf8").digest("hex");
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-ApiMapper-Timestamp": timestamp,
"X-ApiMapper-Signature": `v1=${signature}`,
"Idempotency-Key": event.id
},
body
});
if (response.status === 429 || response.status === 503) {
const wait = Number(response.headers.get("Retry-After") ?? "30");
throw new Error(`Retry in ${wait}s`); // retry later with the same event id
}
if (!response.ok) {
throw new Error(`Refused: ${response.status} ${await response.text()}`);
}
return response.json(); // { executionId, status }
}
Python (3.9 or later, with requests)
With the Python SDK (api-mapper-client 1.3.0 or later), AgentWebhookSignature computes the header values — see
Signing A Webhook Delivery. Without it, the standard library is
enough:
import hashlib
import hmac
import json
import os
import time
import requests
URL = "https://apimapper.example.com/runtime/hooks/agents/<public-id>"
SECRET = os.environ["WEBHOOK_SECRET"]
def deliver(event: dict) -> dict:
body = json.dumps(event, separators=(",", ":")).encode("utf-8") # sign and send these bytes
timestamp = str(int(time.time()))
signature = hmac.new(SECRET.encode("utf-8"), timestamp.encode("ascii") + b"." + body, hashlib.sha256).hexdigest()
response = requests.post(
URL,
data=body, # not json=, which would serialize again
headers={
"Content-Type": "application/json",
"X-ApiMapper-Timestamp": timestamp,
"X-ApiMapper-Signature": f"v1={signature}",
"Idempotency-Key": event["id"],
},
timeout=30,
)
if response.status_code in (429, 503):
raise RuntimeError(f"Retry in {response.headers.get('Retry-After', '30')}s with the same event id")
response.raise_for_status()
return response.json() # {"executionId": ..., "status": ...}
C#
With the .NET SDK (CodedProjects.AI.ApiMapper.Client 1.3.0 or later), AgentWebhookSignature computes the header
values — see Signing A Webhook Delivery. Without it, the BCL is
enough:
using System.Globalization;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Text.Json;
static async Task<HttpResponseMessage> DeliverAsync(HttpClient http, string url, string secret, string eventId, object payload)
{
var body = JsonSerializer.SerializeToUtf8Bytes(payload); // sign and send these bytes
var timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(CultureInfo.InvariantCulture);
var signed = Encoding.UTF8.GetBytes(timestamp + ".").Concat(body).ToArray();
var signature = Convert.ToHexStringLower(HMACSHA256.HashData(Encoding.UTF8.GetBytes(secret), signed));
using var request = new HttpRequestMessage(HttpMethod.Post, url) { Content = new ByteArrayContent(body) };
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
request.Headers.Add("X-ApiMapper-Timestamp", timestamp);
request.Headers.Add("X-ApiMapper-Signature", "v1=" + signature);
request.Headers.Add("Idempotency-Key", eventId);
return await http.SendAsync(request);
}
Convert.ToHexStringLower needs .NET 9 or later; on older runtimes use Convert.ToHexString(...).ToLowerInvariant().
Check the sender
Run the sender once and expect 202 with an executionId; run it again with the same event id and expect 200 with
the same executionId. Then follow Check It Worked. A 401 almost always means the signed bytes
differ from the sent bytes, the secret was copied without its whsec_ prefix, or the sender's clock is more than five
minutes off.
Relaying Senders The Platform Cannot Accept Directly
Some senders require a handshake before they deliver anything, or sign in a format of their own:
- Azure Event Grid validates a webhook subscription by sending a validation event and expecting the code echoed back (or a validation URL visited).
- Slack sends a
url_verificationchallenge when an events URL is configured, signs with its ownX-Slack-Signaturescheme, and expects an answer within three seconds.
The platform does not implement these vendor protocols. Put a small relay in front instead: a function or flow that speaks the vendor's protocol, verifies the vendor's signature, and re-sends the event to the trigger with the ApiMapper v1 signature or a bearer token.
Event Grid / Slack --> Relay (Azure Function, Logic App, Lambda…) --> Webhook trigger
- answers the vendor's handshake
- verifies the vendor's signature
- signs with ApiMapper v1, or uses a bearer token
- passes the vendor's event id as Idempotency-Key
Azure Event Grid. The simplest relay is an Azure Function with an Event Grid trigger — the Functions runtime
performs the subscription validation for you — whose code posts each event to the trigger using one of the
custom sender examples, with the event's id as the Idempotency-Key. A Logic App with an
Event Grid trigger and an HTTP action with Managed identity authentication does the same without code, in bearer
mode.
Slack. The relay answers url_verification by returning the challenge value, verifies X-Slack-Signature
with your Slack signing secret, acknowledges Slack with 200 immediately, and then posts the event to the trigger
with the Slack event_id as the Idempotency-Key. Acknowledging first matters: the agent's run is asynchronous
anyway, and Slack retries a delivery it did not see acknowledged in time.
Keep the relay thin — no business logic — so the agent's instructions stay the one place that decides what an event means.
Check it worked. Trigger one event at the source, confirm the relay logged a 202 from the platform, then follow
Check It Worked.