0

Get Partner Campaigns Shared By User

by
Published Apr 8, 2025

Get all partner campaigns you have shared to Telnyx in a paginated fashion This endpoint is currently limited to only returning shared campaigns that Telnyx has accepted. In other words, shared but pending campaigns are currently omitted from the response from this endpoint.

Script telnyx Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Telnyx = {
3
	apiKey: string
4
}
5
/**
6
 * Get Partner Campaigns Shared By User
7
 * Get all partner campaigns you have shared to Telnyx in a paginated fashion
8

9
This endpoint is currently limited to only returning shared campaigns that Telnyx
10
has accepted. In other words, shared but pending campaigns are currently omitted
11
from the response from this endpoint.
12
 */
13
export async function main(
14
	auth: Telnyx,
15
	page: string | undefined,
16
	recordsPerPage: string | undefined
17
) {
18
	const url = new URL(`https://api.telnyx.com/v2/partnerCampaign/sharedByMe`)
19
	for (const [k, v] of [
20
		['page', page],
21
		['recordsPerPage', recordsPerPage]
22
	]) {
23
		if (v !== undefined && v !== '' && k !== undefined) {
24
			url.searchParams.append(k, v)
25
		}
26
	}
27
	const response = await fetch(url, {
28
		method: 'GET',
29
		headers: {
30
			Authorization: 'Bearer ' + auth.apiKey
31
		},
32
		body: undefined
33
	})
34
	if (!response.ok) {
35
		const text = await response.text()
36
		throw new Error(`${response.status} ${text}`)
37
	}
38
	return await response.json()
39
}
40