Managing App Webhooks
Ductape enables product teams to manage webhook integrations across environments using the ductape.products.webhooks interface. Webhooks are essential for allowing third-party apps to notify your product of events in real time. Ductape acts as a middleware offering visibility, control, and flexibility in how webhooks are registered and used.
Full Registration
Use the enable method to register a webhook for multiple environments at once. This is ideal when your provider allows API-based registration or if you want to fully manage all environments centrally.
Required Fields
| Name | Type | Description |
|---|---|---|
product | string | Product slug |
access_tag | string | Unique access tag for the app |
webhook_tag | string | Identifier for the webhook |
envs | IProductBuilderRegisterWebhookEnvs[] | List of environment-specific configurations |
IProductBuilderRegisterWebhookEnvs
| Field | Type | Description |
|---|---|---|
slug | string | Environment slug (prd, stg, etc.) |
url | string | Receiver webhook endpoint |
method | HttpMethods | HTTP method used (POST, GET) |
auth | IActionRequest | Request authentication and structure |
Example
- TypeScript
- Java
- Go
- .NET
await ductape.products.webhooks.enable({
access_tag: "admin",
webhook_tag: "order_created",
envs: [
{
slug: "prd",
url: "https://api.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: {
headers: {
Authorization: "Bearer <<token>>"
},
query: {},
body: {},
params: {}
}
},
{
slug: "stg",
url: "https://staging.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: {
headers: {
Authorization: "Bearer <<token>>"
},
query: {},
body: {},
params: {}
}
}
]
});
ductape.products.webhooks.enable(Map.of(
"access_tag", "admin",
"webhook_tag", "order_created",
envs: [
Map.of(
"slug", "prd",
"url", "https://api.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: Map.of(
headers: Map.of(
"Authorization", "Bearer <<token>>"
),
query: Map.of(),
body: Map.of(),
params: Map.of()
)
),
Map.of(
"slug", "stg",
"url", "https://staging.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: Map.of(
headers: Map.of(
"Authorization", "Bearer <<token>>"
),
query: Map.of(),
body: Map.of(),
params: Map.of()
)
)
]
));
client.products.webhooks.enable({
"access_tag": "admin",
"webhook_tag": "order_created",
envs: [
{
"slug": "prd",
"url": "https://api.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: {
headers: {
"Authorization": "Bearer <<token>>"
},
query: {},
body: {},
params: {}
}
},
{
"slug": "stg",
"url": "https://staging.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: {
headers: {
"Authorization": "Bearer <<token>>"
},
query: {},
body: {},
params: {}
}
}
]
});
await ductape.products.webhooks.enable({
["access_tag"] = "admin",
["webhook_tag"] = "order_created",
envs: [
{
["slug"] = "prd",
["url"] = "https://api.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: {
headers: {
["Authorization"] = "Bearer <<token>>"
},
query: {},
body: {},
params: {}
}
},
{
["slug"] = "stg",
["url"] = "https://staging.example.com/webhooks/orders",
method: HttpMethods.POST,
auth: {
headers: {
["Authorization"] = "Bearer <<token>>"
},
query: {},
body: {},
params: {}
}
}
]
});
Generating a Registration Link
Use the generateLink method when your provider requires you to manually input the webhook URL in their dashboard. Ductape will generate a wrapped tracking link that routes through its middleware.
Required Fields
| Name | Type | Description |
|---|---|---|
product | string | Product slug |
access_tag | string | App's access tag |
webhook_tag | string | Identifier for the webhook |
env | string | Environment slug |
url | string | Original webhook endpoint |
method | HttpMethods | HTTP method (POST, GET, etc.) |
Example
- TypeScript
- Java
- Go
- .NET
const link = await ductape.products.webhooks.generateLink({
access_tag: "admin",
webhook_tag: "order_created",
url: "https://api.example.com/webhooks/orders",
method: HttpMethods.POST
});
console.log("Register this link in your provider dashboard:", link);
Map<String, Object> link = ductape.products.webhooks.generateLink(Map.of(
"access_tag", "admin",
"webhook_tag", "order_created",
"url", "https://api.example.com/webhooks/orders",
method: HttpMethods.POST
));
System.out.println("Register this link in your provider dashboard:", link);
link := client.products.webhooks.generateLink({
"access_tag": "admin",
"webhook_tag": "order_created",
"url": "https://api.example.com/webhooks/orders",
method: HttpMethods.POST
});
fmt.Println("Register this link in your provider dashboard:", link);
var link = await ductape.products.webhooks.generateLink({
["access_tag"] = "admin",
["webhook_tag"] = "order_created",
["url"] = "https://api.example.com/webhooks/orders",
method: HttpMethods.POST
});
Console.WriteLine("Register this link in your provider dashboard:", link);
Fetching Registered Webhooks
To see which webhooks are currently registered for an app, use the fetchAll method.
Example
- TypeScript
- Java
- Go
- .NET
const webhooks = await ductape.products.webhooks.fetchAll("admin");
Map<String, Object> webhooks = ductape.products.webhooks.fetchAll("admin");
webhooks := client.products.webhooks.fetchAll("admin");
var webhooks = await ductape.products.webhooks.fetchAll("admin");
Parameters
| Name | Type | Description |
|---|---|---|
accessTag | string | The access tag for the target app |
Returns
An array of webhook configurations associated with the given access tag.
Choosing the Right Method
| Method | Best Use Case |
|---|---|
| Full Registration | You can register webhooks programmatically across all environments at once. |
| Generate Registration Link | You need a single environment-specific link to paste into a provider UI. |