0

Delete Webhook for Candidate Screening Order

by
Published Oct 17, 2025

> 🚧 Partner Restricted > All background check API endpoints are restricted to background check providers that have signed a Paylocity technology partnership agreement. Please reach out to [email protected] if you would like to discuss partnership opportunities. **Summary Description** Deletes the webhook

Script paylocity Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Paylocity = {
3
	clientId: string
4
	clientSecret: string
5
}
6
/**
7
 * Delete Webhook for Candidate Screening Order
8
 * > 🚧 Partner Restricted
9
> All background check API endpoints are restricted to background check providers that have signed a Paylocity technology partnership agreement. Please reach out to Techpartnerships@paylocity.com if you would like to discuss partnership opportunities.
10

11
**Summary Description**
12

13
Deletes the webhook
14

15

16
 */
17
export async function main(auth: Paylocity, callbackId: string, testMode?: string) {
18
	const url = new URL(
19
		`https://dc1prodgwext.paylocity.com/compliance/v1/companies/b6001/backgroundCheck/candidateScreeningOrders/subscription/${callbackId}`
20
	)
21

22
	const response = await fetch(url, {
23
		method: 'DELETE',
24
		headers: {
25
			...(testMode ? { testMode: testMode } : {}),
26
			Authorization:
27
				'Bearer ' +
28
				(await getOAuthToken(auth, 'https://dc1prodgwext.paylocity.com/public/security/v1/token'))
29
		},
30
		body: undefined
31
	})
32
	if (!response.ok) {
33
		const text = await response.text()
34
		throw new Error(`${response.status} ${text}`)
35
	}
36
	return await response.json()
37
}
38

39
async function getOAuthToken(auth: Paylocity, tokenUrl: string): Promise<string> {
40
	const params = new URLSearchParams({
41
		grant_type: 'client_credentials',
42
		client_id: auth.clientId,
43
		client_secret: auth.clientSecret
44
	})
45

46
	const response = await fetch(tokenUrl, {
47
		method: 'POST',
48
		headers: {
49
			Authorization: 'Basic ' + btoa(`${auth.clientId}:${auth.clientSecret}`),
50
			'Content-Type': 'application/x-www-form-urlencoded'
51
		},
52
		body: params.toString()
53
	})
54

55
	if (!response.ok) {
56
		const text = await response.text()
57
		throw new Error(`OAuth token request failed: ${response.status} ${text}`)
58
	}
59

60
	const data = await response.json()
61
	return data.access_token
62
}
63