0

Delete Screening Package

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 screening package **Use Cases** - Partner does not want this package to be displayed in the UI for the client

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 Screening Package
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 screening package
14

15
**Use Cases**
16

17
- Partner does not want this package to be displayed in the UI for the client 
18

19
 */
20
export async function main(
21
	auth: Paylocity,
22
	companyId: string,
23
	packageId: string,
24
	testMode?: string
25
) {
26
	const url = new URL(
27
		`https://dc1prodgwext.paylocity.com/compliance/v1/companies/${companyId}/backgroundCheck/screeningPackages/${packageId}`
28
	)
29

30
	const response = await fetch(url, {
31
		method: 'DELETE',
32
		headers: {
33
			...(testMode ? { testMode: testMode } : {}),
34
			Authorization:
35
				'Bearer ' +
36
				(await getOAuthToken(auth, 'https://dc1prodgwext.paylocity.com/public/security/v1/token'))
37
		},
38
		body: undefined
39
	})
40
	if (!response.ok) {
41
		const text = await response.text()
42
		throw new Error(`${response.status} ${text}`)
43
	}
44
	return await response.json()
45
}
46

47
async function getOAuthToken(auth: Paylocity, tokenUrl: string): Promise<string> {
48
	const params = new URLSearchParams({
49
		grant_type: 'client_credentials',
50
		client_id: auth.clientId,
51
		client_secret: auth.clientSecret
52
	})
53

54
	const response = await fetch(tokenUrl, {
55
		method: 'POST',
56
		headers: {
57
			Authorization: 'Basic ' + btoa(`${auth.clientId}:${auth.clientSecret}`),
58
			'Content-Type': 'application/x-www-form-urlencoded'
59
		},
60
		body: params.toString()
61
	})
62

63
	if (!response.ok) {
64
		const text = await response.text()
65
		throw new Error(`OAuth token request failed: ${response.status} ${text}`)
66
	}
67

68
	const data = await response.json()
69
	return data.access_token
70
}
71