0

Create Recipient View

by
Published 21 days ago

Generate an embedded-signing URL for a recipient. The recipient must have a clientUserId set on the envelope.

Script docusign Verified

The script

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

3
/**
4
 * Create Recipient View
5
 * Generate an embedded-signing URL for a recipient. The recipient must have a clientUserId set on the envelope.
6
 */
7
export async function main(
8
  auth: RT.Docusign,
9
  envelope_id: string,
10
  recipient_view_request: {
11
    authenticationMethod: string
12
    clientUserId: string
13
    email: string
14
    recipientId?: string
15
    returnUrl: string
16
    userName: string
17
    pingFrequency?: string
18
    pingUrl?: string
19
  },
20
) {
21
  const url = new URL(
22
    `${auth.base_uri}/restapi/v2.1/accounts/${auth.account_id}/envelopes/${envelope_id}/views/recipient`,
23
  )
24

25
  const response = await fetch(url, {
26
    method: "POST",
27
    headers: {
28
      Authorization: `Bearer ${auth.token}`,
29
      "Content-Type": "application/json",
30
      Accept: "application/json",
31
    },
32
    body: JSON.stringify(recipient_view_request),
33
  })
34

35
  if (!response.ok) {
36
    throw new Error(`${response.status} ${await response.text()}`)
37
  }
38

39
  return await response.json()
40
}
41