0

Get Onboarding Status

by
Published Oct 17, 2025

> 🚧 Partner Restricted > > The Partner Onboarding API is only available to approved partners who have signed a Paylocity Technology Partnership Agreement.

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
 * Get Onboarding Status
8
 * > 🚧 Partner Restricted
9
> 
10
> The Partner Onboarding API is only available to approved partners who have signed a Paylocity Technology Partnership Agreement.
11
 */
12
export async function main(
13
	auth: Paylocity,
14
	filter: string | undefined,
15
	limit: string | undefined,
16
	offset: string | undefined,
17
	includeTotalCount: string | undefined,
18
	testMode?: string
19
) {
20
	const url = new URL(
21
		`https://dc1prodgwext.paylocity.com/apiHub/security/v1/companies/b6001/clientOnboardings`
22
	)
23
	for (const [k, v] of [
24
		['filter', filter],
25
		['limit', limit],
26
		['offset', offset],
27
		['includeTotalCount', includeTotalCount]
28
	]) {
29
		if (v !== undefined && v !== '' && k !== undefined) {
30
			url.searchParams.append(k, v)
31
		}
32
	}
33
	const response = await fetch(url, {
34
		method: 'GET',
35
		headers: {
36
			...(testMode ? { testMode: testMode } : {}),
37
			Authorization:
38
				'Bearer ' +
39
				(await getOAuthToken(auth, 'https://dc1prodgwext.paylocity.com/public/security/v1/token'))
40
		},
41
		body: undefined
42
	})
43
	if (!response.ok) {
44
		const text = await response.text()
45
		throw new Error(`${response.status} ${text}`)
46
	}
47
	return await response.json()
48
}
49

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

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

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

71
	const data = await response.json()
72
	return data.access_token
73
}
74