0

Create an organization webhook

by
Published Oct 17, 2025

Create an organization webhook.

Script qovery Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Create an organization webhook
4
 * Create an organization webhook.
5
 */
6
export async function main(auth: RT.Qovery, organizationId: string, body: Body) {
7
	const url = new URL(`https://api.qovery.com/organization/${organizationId}/webhook`)
8

9
	const response = await fetch(url, {
10
		method: 'POST',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Token ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface Body {
32
	/**
33
	 * Define the type of the webhook. `SLACK` is a special webhook type to push notifications directly to slack. The `target_url` must be a Slack compatible endpoint.
34
	 */
35
	kind: 'STANDARD' | 'SLACK'
36
	/**
37
	 * Set the public HTTP or HTTPS endpoint that will receive the specified events.
38
	 * The target URL must starts with `http://` or `https://`
39
	 *
40
	 */
41
	target_url: string
42
	/**
43
	 * Make sure you receive a payload to sign the Qovery request with your secret.
44
	 * Qovery will add a HTTP header `Qovery-Signature: <Your Secret>` to every webhook requests sent to your target URL.
45
	 *
46
	 */
47
	target_secret?: string
48
	description?: string
49
	/**
50
	 * Turn on or off your endpoint.
51
	 */
52
	enabled?: boolean
53
	events: (
54
		| 'DEPLOYMENT_STARTED'
55
		| 'DEPLOYMENT_CANCELLED'
56
		| 'DEPLOYMENT_FAILURE'
57
		| 'DEPLOYMENT_SUCCESSFUL'
58
	)[]
59
	/**
60
	 * Specify the project names you want to filter to.
61
	 * This webhook will be triggered only if the event is coming from the specified Project IDs.
62
	 * Notes: 1. Wildcard is accepted E.g. `product*`. 2. Name is case insensitive.
63
	 *
64
	 */
65
	project_names_filter?: string[]
66
	/**
67
	 * Specify the environment modes you want to filter to.
68
	 * This webhook will be triggered only if the event is coming from an environment with the specified mode.
69
	 *
70
	 */
71
	environment_types_filter?: ('DEVELOPMENT' | 'PREVIEW' | 'PRODUCTION' | 'STAGING')[]
72
	[k: string]: unknown
73
}
74