0

Expire a combined submission

by
Published Dec 20, 2024
Script docspring Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Docspring = {
3
	tokenId: string
4
	tokenSecret: string
5
}
6
/**
7
 * Expire a combined submission
8
 *
9
 */
10
export async function main(auth: Docspring, combined_submission_id: string) {
11
	const url = new URL(
12
		`https://api.docspring.com/api/v1/combined_submissions/${combined_submission_id}`
13
	)
14

15
	const token = btoa(auth.tokenId + ':' + auth.tokenSecret)
16

17
	const response = await fetch(url, {
18
		method: 'DELETE',
19
		headers: {
20
			Authorization: `Basic ${token}`
21
		},
22
		body: undefined
23
	})
24
	if (!response.ok) {
25
		const text = await response.text()
26
		throw new Error(`${response.status} ${text}`)
27
	}
28
	return await response.text()
29
}
30