0

Create Box Sign request

by
Published Oct 17, 2025

Creates a signature request. This involves preparing a document for signing and sending the signature request to signers.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * Create Box Sign request
7
 * Creates a signature request. This involves preparing a document for signing and
8
sending the signature request to signers.
9
 */
10
export async function main(
11
  auth: Box,
12
  body: {
13
    is_document_preparation_needed?: false | true;
14
    redirect_url?: string;
15
    declined_redirect_url?: string;
16
    are_text_signatures_enabled?: false | true;
17
    email_subject?: string;
18
    email_message?: string;
19
    are_reminders_enabled?: false | true;
20
    name?: string;
21
    prefill_tags?: {
22
      document_tag_id?: string;
23
      text_value?: string;
24
      checkbox_value?: false | true;
25
      date_value?: string;
26
    }[];
27
    days_valid?: number;
28
    external_id?: string;
29
    template_id?: string;
30
    external_system_name?: string;
31
  } & {
32
    source_files?: { id: string; etag?: string; type: "file" }[];
33
    signature_color?: "blue" | "black" | "red";
34
    signers?: {
35
      email?: string;
36
      role?: "signer" | "approver" | "final_copy_reader";
37
      is_in_person?: false | true;
38
      order?: number;
39
      embed_url_external_user_id?: string;
40
      redirect_url?: string;
41
      declined_redirect_url?: string;
42
      login_required?: false | true;
43
      password?: string;
44
      signer_group_id?: string;
45
      suppress_notifications?: false | true;
46
    }[];
47
    parent_folder?: { id: string; etag?: string; type: "folder" } & {
48
      sequence_id?: string & {};
49
      name?: string;
50
    } & {};
51
  },
52
) {
53
  const url = new URL(`https://api.box.com/2.0/sign_requests`);
54

55
  const response = await fetch(url, {
56
    method: "POST",
57
    headers: {
58
      "Content-Type": "application/json",
59
      Authorization: "Bearer " + auth.token,
60
    },
61
    body: JSON.stringify(body),
62
  });
63
  if (!response.ok) {
64
    const text = await response.text();
65
    throw new Error(`${response.status} ${text}`);
66
  }
67
  return await response.json();
68
}
69