0

Creates an Upload request

by
Published Apr 8, 2025

Creates a new Upload request to Microsoft teams with the included phone numbers. Only one of civic_address_id or location_id must be provided, not both. The maximum allowed phone numbers for the numbers_ids array is 1000.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Creates an Upload request
7
 * Creates a new Upload request to Microsoft teams with the included phone numbers. Only one of civic_address_id or location_id must be provided, not both. The maximum allowed phone numbers for the numbers_ids array is 1000.
8
 */
9
export async function main(
10
	auth: Telnyx,
11
	id: string,
12
	body: {
13
		number_ids?: string[]
14
		usage?: 'calling_user_assignment' | 'first_party_app_assignment'
15
		additional_usages?: 'calling_user_assignment' | 'first_party_app_assignment'[]
16
		location_id?: string
17
		civic_address_id?: string
18
	}
19
) {
20
	const url = new URL(`https://api.telnyx.com/v2/external_connections/${id}/uploads`)
21

22
	const response = await fetch(url, {
23
		method: 'POST',
24
		headers: {
25
			'Content-Type': 'application/json',
26
			Authorization: 'Bearer ' + auth.apiKey
27
		},
28
		body: JSON.stringify(body)
29
	})
30
	if (!response.ok) {
31
		const text = await response.text()
32
		throw new Error(`${response.status} ${text}`)
33
	}
34
	return await response.json()
35
}
36