0

Create User Position

by
Published Nov 5, 2024

Creates a new User Position.

Script motimate Verified

The script

Submitted by hugo697 Bun
Verified 581 days ago
1
//native
2
type Motimate = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Motimate,
8
	body: {
9
		imported?: false | true
10
		position_id?: number
11
		position_external_id?: string
12
		user_id?: number
13
		user_external_id?: string
14
	}
15
) {
16
	const url = new URL(`https://motimateapp.com/public_api/user_positions`)
17

18
	const response = await fetch(url, {
19
		method: 'POST',
20
		headers: {
21
			'Content-Type': 'application/json',
22
			Authorization: 'Bearer ' + auth.token
23
		},
24
		body: JSON.stringify(body)
25
	})
26

27
	if (!response.ok) {
28
		const text = await response.text()
29
		throw new Error(`${response.status} ${text}`)
30
	}
31

32
	return await response.json()
33
}
34