Edits history of script submission #22308 for ' Void Envelope (docusign)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Void Envelope
     * Void an in-flight envelope with a required reason.
     */
    export async function main(
      auth: RT.Docusign,
      envelope_id: string,
      voided_reason: string,
    ) {
      const url = new URL(
        `${auth.base_uri}/restapi/v2.1/accounts/${auth.account_id}/envelopes/${envelope_id}`,
      )
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: `Bearer ${auth.token}`,
          "Content-Type": "application/json",
          Accept: "application/json",
        },
        body: JSON.stringify({ status: "voided", voidedReason: voided_reason }),
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 22 days ago