0

List Recipients

by
Published 21 days ago

List recipients of an envelope along with their current signing status and optional tabs.

Script docusign Verified

The script

Submitted by hugo989 Bun
Verified 22 days ago
1
//native
2

3
/**
4
 * List Recipients
5
 * List recipients of an envelope along with their current signing status and optional tabs.
6
 */
7
export async function main(
8
  auth: RT.Docusign,
9
  envelope_id: string,
10
  include_tabs: boolean | undefined,
11
  include_extended: boolean | undefined,
12
) {
13
  const url = new URL(
14
    `${auth.base_uri}/restapi/v2.1/accounts/${auth.account_id}/envelopes/${envelope_id}/recipients`,
15
  )
16
  if (include_tabs !== undefined) {
17
    url.searchParams.append("include_tabs", String(include_tabs))
18
  }
19
  if (include_extended !== undefined) {
20
    url.searchParams.append("include_extended", String(include_extended))
21
  }
22

23
  const response = await fetch(url, {
24
    method: "GET",
25
    headers: {
26
      Authorization: `Bearer ${auth.token}`,
27
      Accept: "application/json",
28
    },
29
  })
30

31
  if (!response.ok) {
32
    throw new Error(`${response.status} ${await response.text()}`)
33
  }
34

35
  return await response.json()
36
}
37