0

Update Training Type

by
Published Oct 17, 2025

Update an existing training type. The owner of the API key used must have access to training settings.

Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Update Training Type
4
 * Update an existing training type. The owner of the API key used must have access to training settings.
5
 */
6
export async function main(auth: RT.BambooHr, trainingTypeId: string = '0', body: Body) {
7
	const url = new URL(
8
		`https://${auth.companyDomain}.bamboohr.com/api/v1/training/type/${trainingTypeId}`
9
	)
10

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

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

33
export interface Body {
34
	/**
35
	 * Name of the training type.
36
	 */
37
	name: string
38
	/**
39
	 * The frequency is the (optional) amount of months between renewing trainings. Not valid if training are not renewable.
40
	 */
41
	frequency?: number
42
	/**
43
	 * Renewable is optional but if you are setting it to true you must pass a frequency.
44
	 */
45
	renewable?: boolean
46
	/**
47
	 * Category is optional and passing an empty value will remove the category from the training type. Passing a name will assign the training type to the new training category.
48
	 */
49
	category?: {
50
		/**
51
		 * Category ID
52
		 */
53
		id?: number
54
		/**
55
		 * Category Name
56
		 */
57
		name?: string
58
		/**
59
		 * Accuracy in meters of the clock in location
60
		 */
61
		accuracy?: number
62
		/**
63
		 * Address...
64
		 */
65
		address?: string
66
		[k: string]: unknown
67
	}
68
	/**
69
	 * Is this a required training?
70
	 */
71
	required: boolean
72
	/**
73
	 * Number of days before the training is due for new hires. Not valid unless training is required.
74
	 */
75
	dueFromHireDate?: number
76
	/**
77
	 * Optional URL that can be included with a training.
78
	 */
79
	linkUrl?: string
80
	/**
81
	 * Description for the training.
82
	 */
83
	description?: string
84
	/**
85
	 * Allows all employees who can view the training to be able to mark it complete.
86
	 */
87
	allowEmployeesToMarkComplete?: boolean
88
	[k: string]: unknown
89
}
90