# @\_edusign/api 中文文档

规范地址：https://npmcn.com/package/%40_edusign/api/

版本：1\.12\.0
npm 元数据更新时间：2025-04-25T14:59:36.003Z
中文译文更新时间：2026-11-06T08:45:34.236Z
软件包许可：ISC

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40_edusign/api
原文对照：https://npmcn.com/package/%40_edusign/api/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：446 kB，77 个文件
- 模块格式：CommonJS
- TypeScript 类型：包内自带
- 运行依赖：6 个
- 首次发布：2023-08-07T17:48:26.090Z
- 最新版本发布：2025-04-25T14:59:35.783Z
- 近 30 天下载量：3732（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：55（近 12 个月 0 个）

## 中文简介

Edusign ext API 为访问您的数据提供了简单的方式. 无论是课程,老师,还是学生. 您将使用库方法访问存储在 REST API 中的数据 .

## 安装

```sh
npm install @_edusign/api
```

也可以使用：`pnpm add @_edusign/api`、`yarn add @_edusign/api`、`bun add @_edusign/api`

## README

# Edusig 库

Edusign ext API 为访问您的数据提供了简单的方式. 无论是课程,老师,还是学生. 您将使用库方法访问存储在 REST API 中的数据 .

也可以使用此库来构建应用程序的块 [https://developers.edusign.com/docs/edusign-application-blocks-tool (中文(简体) )](https://developers.edusign.com/docs/edusign-application-blocks-tool)

## 安装库 :

-   国家预防机制

```typescript
npm i @_edusign/api
```

-   菲律宾

```typescript
pnpm add @_edusign/api
```

-   雅伦

```typescript
yarn add @_edusign/api
```

## 导入库 :

在Edusign仪表板中必须生成一个API密钥. 以下是关于如何生成 API 密钥的文章 : [https://developers.edusign.com/docs/api-参考资料](https://developers.edusign.com/docs/api-reference)

```typescript
import edusign from "@_edusign/api";

// Create a single edusign client for interacting with Edusign API
const edusignAPI = new edusign.Edusign("API_KEY", "production");
```

您可以检查此文档以查看 API 可能性 : [https://developers.edusign.com/ 参考资料](https://developers.edusign.com/reference)

您可以在您的 Edusign 账户( 学生、 教授、 团体、 文件、 调查...) 中遵循同样的方案

## 使用量

以下是一个实例片段列表

```typescript
// get all courses
const getAllCourses = () => {
  // params:  page: 2, start: "2020-01-20T15:00:00" (optional), end: "2020-01-20T18:00:00" (optional, filters: "filters" (optional, groupId: "groupId" (optional, studentId: "studentId" (optional
  // ⚠️ page param is currently not mandatory but strongly recommended
  const courses = (
    await edusignAPI
      .courses()
      .getAll(
        2,
        "2020-01-20T15:00:00",
        "2020-01-20T18:00:00",
        "filters",
        "groupId",
        "studentId"
      )
  ).result;
  return courses;
};
getAllCourses();

// get course by Id
const getCourseById = (Id) => {
  const course = (await edusignAPI.courses().get(Id)).result;
  return course;
};
getCourseById("courseId");

// create course
const createCourse = () => {
  const newCourse = {
    NAME: "Growth hacking (mandatory)",
    DESCRIPTION: "Course about growth hacking",
    START: "2020-01-20T15:00:00", //  (ISO 8601 datetime)
    END: "2020-01-20T18:00:00", //  (ISO 8601 datetime)
    PROFESSOR: "dfgh6789Uhghj",
    PROFESSOR_SIGNATURE: "", // signature URL if the teacher has signed
    PROFESSOR_2: "dfgh6789Uhghj",
    PROFESSOR_SIGNATURE_2: "", // signature URL if the teacher 2 has signed
    PROFESSOR_3: "", // courses can have an infinite number of teachers, ordered by the number at the end of the key
    PROFESSOR_SIGNATURE_3: "",
    CLASSROOM: "B102",
    SCHOOL_GROUP: ["ghj865fgh897Tgh"],
    MAX_STUDENTS: 23, // maximum number of students that can be enrolled in the course , optional field
    ZOOM: true / false, // Create a zoom meeting and invite all the student to this meeting. /!\ Beta & Only works if you have set up zoom in the settings
    API_ID: "", // API ID,
    SURVEY_ID: "amsk22ovssga19f", // ID of a survey template (optional)
    SURVEY_1_AUTOMATIC_SEND_DATE: "2022-02-23T09:20:00", // automatic sending date of the survey to the participants of the course (optional)
    TEACHER_SURVEY: "amsk22ovssga19f", // ID of a survey template for the teacher (optional)
  };

  const course = (await edusignAPI.courses().add(newCourse)).result;
  return course;
};
createCourse();

// update course
const updateCourse = () => {
  let updateCourse = {
    ID: "45678jhg78",
    NAME: "Growth hacking (mandatory)",
    DESCRIPTION: "Course about growth hacking",
    START: "2020-01-20T15:00:00", //  (ISO 8601 datetime)
    END: "2020-01-20T18:00:00", //  (ISO 8601 datetime)
    PROFESSOR: "dfgh6789Uhghj",
    PROFESSOR_SIGNATURE: "", // signature URL if the teacher has signed
    PROFESSOR_2: "", // second teacher if needed
    PROFESSOR_SIGNATURE_2: "", // signature URL if the teacher 2 has signed
    PROFESSOR_3: "", // courses can have an infinite number of teachers, ordered by the number at the end of the key
    PROFESSOR_SIGNATURE_3: "",
    CLASSROOM: "B102", // 255 chars max.
    SCHOOL_GROUP: ["ghj865fgh897Tgh"],
    SURVEY_ID: "amsk22ovssga19f", // ID of a survey template
    SURVEY_1_AUTOMATIC_SEND_DATE: "2022-02-23T09:20:00", // optional automatic sending date of the survey to the participants of the course
    ZOOM: true / false, // Create a zoom meeting and invite all the student to this meeting. /!\ Only works if you have set up zoom in the settings
    API_ID: "", // API ID
  };

  const updatedCourse = (await edusignAPI.courses().edit(updateCourse)).result;
  return updatedCourse;
};
updateCourse();

// delete course
const deleteCourse = (id) => {
  const deleteCourse = (await edusignAPI.courses().delete(id)).result;
  return deleteCourse;
};
deleteCourse("courseId");
```

## 支持的 API

### 缺额

-   加有正当理由缺席

```typescript
import fs from "fs";

const fileContent = fs.readFileSync("filePath");
const base64Data = Buffer.from(fileContent).toString("base64"); // output in string format

const newJustifiedAbsence = {
  STUDENT_ID: "advhfjsaa77zc",
  COURSE_ID: "ddjdzn8222hhk",
  TYPE: 1, // 1 = Sick Leave, 2 = Death of a loved one, 3 = Funeral, 4 = Medical Appointment, 5 = Job interview, 6 = In enterprise, 7 = Other
  COMMENT: "The student sent us a medical certificate",
  FILE: {
    DATA: base64Data, // base64 of the PDF file
    NAME: "file_name.pdf", // name of the file
  },
  API_ID: "", // External ID
  API_TYPE: "", // External Type
};

edusignAPI.absences().addJustified(newJustifiedAbsence);
```

-   在两个日期之间添加有正当理由的缺席

```typescript
import fs from "fs";

const fileContent = fs.readFileSync("filePath");
const base64Data = Buffer.from(fileContent).toString("base64"); // output in string format

const newJustifiedAbsenceBetweenTwoDates = {
  STUDENT_ID: "advhfjsaa77zc",
  TYPE: 1, // 1 = Sick Leave, 2 = Death of a loved one, 3 = Funeral, 4 = Medical Appointment, 5 = Job interview, 6 = In enterprise, 7 = Other
  COMMENT: "The student sent us a medical certificate",
  FILE: {
    DATA: base64Data, // base64 of the PDF file
    NAME: "file_name.pdf", // name of the file
  },
  DATE_START: "2021-01-01T10:00:00.000Z",
  DATE_END: "2021-01-30T10:00:00.000Z",
  API_ID: "", // External ID
  API_TYPE: "", // External Type
};

edusignAPI.absences().addJustifiedBetweenDates(newJustifiedAbsenceBetweenTwoDates);
```

-   得到所有合理的缺席

```typescript
// params : page : 1, studentId?: 'studentId (optional), courseId?: 'courseId' (optional)
// ⚠️ page param is currently not mandatory but strongly recommended
edusignAPI
  .absences()
  .getAllJustified({ page: 1, studentId: "studentId", courseId: "courseId" });
```

-   以 Id 为理由缺席

```typescript
edusignAPI.absences().getById("absenceId");
```

-   编辑有正当理由的缺席

```typescript
import fs from "fs";

const fileContent = fs.readFileSync("filePath");
const base64Data = Buffer.from(fileContent).toString("base64"); // output in string format

const updateJustifiedAbsence = {
  TYPE: 1, // 1 = Sick Leave, 2 = Death of a loved one, 3 = Funeral, 4 = Medical Appointment, 5 = Job interview, 6 = In enterprise, 7 = Other
  COMMENT: "The student sent us a medical certificate",
  FILE: {
    DATA: base64Data, // base64 of the PDF file
    NAME: "file_name.pdf", // name of the file
  },
  DATE_START: "2021-01-01T10:00:00.000Z",
  DATE_END: "2021-01-30T10:00:00.000Z",
  API_ID: "", // External ID
  API_TYPE: "", // External Type
};

edusignAPI.absences().editJustified("absenceId", updateJustifiedAbsence);
```

-   删除有正当理由的缺席

```typescript
edusignAPI.absences().deleteJustified("absenceId");
```

### 缺席原因

-   添加缺席原因

```typescript
const newAbsenceReason = {
  NAME: "Sick leave",
  ID: 101, // not mandatory, the desired ID of the reason. If it is not supplied, an incremental ID is defined. If the ID linked to the pattern is hidden, we restore it.
};

edusignAPI.absences().addReason(newAbsenceReason);
```

-   得到所有缺席的理由

```typescript
edusignAPI.absences().getAllReasons();
```

-   HIDE 缺席的原因

```typescript
edusignAPI.absences().hideAbsenceReason("absenceId");
```

### 课程

-   添加课程

```typescript
const newCourse = {
  NAME: "Growth hacking (mandatory)",
  DESCRIPTION: "Course about growth hacking",
  START: "2020-01-20T15:00:00", //  (ISO 8601 datetime)
  END: "2020-01-20T18:00:00", //  (ISO 8601 datetime)
  PROFESSOR: "dfgh6789Uhghj",
  PROFESSOR_SIGNATURE: "", // signature URL if the teacher has signed
  PROFESSOR_2: "dfgh6789Uhghj",
  PROFESSOR_SIGNATURE_2: "", // signature URL if the teacher 2 has signed
  PROFESSOR_3: "", // courses can have an infinite number of teachers, ordered by the number at the end of the key
  PROFESSOR_SIGNATURE_3: "",
  CLASSROOM: "B102",
  SCHOOL_GROUP: ["ghj865fgh897Tgh"],
  MAX_STUDENTS: 23, // maximum number of students that can be enrolled in the course , optional field
  ZOOM: true / false, // Create a zoom meeting and invite all the student to this meeting. /!\ Beta & Only works if you have set up zoom in the settings
  API_ID: "", // API ID,
  SURVEY_ID: "amsk22ovssga19f", // ID of a survey template (optional)
  SURVEY_1_AUTOMATIC_SEND_DATE: "2022-02-23T09:20:00", // automatic sending date of the survey to the participants of the course (optional)
  TEACHER_SURVEY: "amsk22ovssga19f", // ID of a survey template for the teacher (optional)
};

edusignAPI.courses().add(newCourse);
```

-   在课程中添加学生

```typescript
edusignAPI.courses().addStudent("courseId", "studentId");
```

-   上所有课程

```typescript
// params:  page: 2, filters: { start: "2020-01-20T15:00:00" (optional), end: "2020-01-20T18:00:00" (optional, filters: "filters" (optional, groupId: "groupId" (optional, studentId: "studentId" (optional }
// ⚠️ page param is currently not mandatory but strongly recommended
edusignAPI
  .courses()
  .getAll(
    2,
    {
      start: "2020-01-20T15:00:00",
      end : "2020-01-20T18:00:00",
      filters: "filters",
      groupId: "groupId",
      studentId: "studentId"
    }
  );
```

-   沿着路走

```typescript
edusignAPI.courses().get("courseId");
```

-   由 API Id 引导

```typescript
edusignAPI.courses().getIdByApiId("course_API_Id");
```

-   按时间戳走

```typescript
edusignAPI.courses().getTimeStamps("courseId");
```

-   编辑课程

```typescript
let updateCourse = {
  ID: "45678jhg78",
  NAME: "Growth hacking (mandatory)",
  DESCRIPTION: "Course about growth hacking",
  START: "2020-01-20T15:00:00", //  (ISO 8601 datetime)
  END: "2020-01-20T18:00:00", //  (ISO 8601 datetime)
  PROFESSOR: "dfgh6789Uhghj",
  PROFESSOR_SIGNATURE: "", // signature URL if the teacher has signed
  PROFESSOR_2: "", // second teacher if needed
  PROFESSOR_SIGNATURE_2: "", // signature URL if the teacher 2 has signed
  PROFESSOR_3: "", // courses can have an infinite number of teachers, ordered by the number at the end of the key
  PROFESSOR_SIGNATURE_3: "",
  CLASSROOM: "B102", // 255 chars max.
  SCHOOL_GROUP: ["ghj865fgh897Tgh"],
  SURVEY_ID: "amsk22ovssga19f", // ID of a survey template
  SURVEY_1_AUTOMATIC_SEND_DATE: "2022-02-23T09:20:00", // optional automatic sending date of the survey to the participants of the course
  ZOOM: true / false, // Create a zoom meeting and invite all the student to this meeting. /!\ Only works if you have set up zoom in the settings
  API_ID: "", // API ID
};

edusignAPI.courses().edit(updateCourse, true, "surveyId");
```

-   删除课程

```typescript
edusignAPI.courses().delete("courseId");
```

-   按组获取当前工作表

```typescript
edusignAPI.courses().getPresentialSheetByGroup("groupId", "startDate", "endDate");
```

-   生成指针代码

```typescript
edusignAPI.courses().generatePinCode("courseId");
```

-   获取 QR 代码

```typescript
edusignAPI.courses().getQRCode("courseId", "professorId");
```

-   校验 QRCde

```typescript
edusignAPI.courses().verifyQRCode("courseId", "code");
```

-   从课程中获取学生签名链接

```typescript
edusignAPI.courses().getStudentsSignatureLinksFromCourse("courseId");
```

-   在日期之间取得学生签名链接

```typescript
edusignAPI.courses().getStudentsSignatureLinksBetweenDates("startDate", "endDate");
```

-   从课程中获取老师签名链接

```typescript
edusignAPI.courses().getTeacherSignatureLinksFromCourse("courseId");
```

-   锁定课程 : 锁定课程后, 您可以从课程对象中获取出勤表 PDF URL .

```typescript
edusignAPI.courses().lock("courseId");
```

-   解锁课程

```typescript
edusignAPI.courses().unlock("courseId");
```

-   重新装入课程的学生

```typescript
edusignAPI.courses().reloadStudents("courseId");
```

-   从给定的课程中删除学生

```typescript
edusignAPI.courses().removeStudent("courseId", "studentId");
```

-   发送签名邮件

```typescript
edusignAPI.courses().sendSignatureEmails("courseId", "studentId");
```

-   设置与企业资源规划一起发送的缺失

```typescript
edusignAPI.courses().setAbsenceSentWithERP("courseId");
```

### 文档

-   添加文档

```typescript
const newDocument = {
    "admin_id": "osg53hexfy1w9n1",
    "recipients": [
        // Each array of recipients represents a document that will be sent. All recipient arrays must be identical (same number of recipients in the same order), only the IDs must be different from one array to another
        // document 1
        [
            {
                "category": "student",
                "id": "behzfkrghergethgr"
            },
            {
                "category": "professor",
                "id": "bhesfsbgksqgrehge"
            },
            {
                "category": "professor",
                "id": "fivzjfzbfeehfhfea"
            }
        ],
        // document 2
        [
            {
                "category": "student",
                "id": "vdnfgkdghergkerghe"
            },
            {
                "category": "professor",
                "id": "cehjzferbgekrgjhr"
            },
            {
                "category": "professor",
                "id": "vbnfelvfbpdbjrbge"
            }
        ]
    ],
    "inputs": [
        {
            "category": "student", // Allowed values: "admin", "student", "external", "professor"
            "type": "INPUT_TO_FILL", // Allowed values : "INPUT_TO_FILL", "CHECKBOX_TO_FILL", "PARAPHE", "SIGNATURE"
            "index": 0,
            "label": "Numéro de sécurité sociale", // Text used as the name of the input and who is displayed as a placeholder on the document. This field is required only for input of type "INPUT_TO_FILL"
            "position": {
                "page": 1,
                "x": 100,
                "y": 200
            }
        },
        {
            "category": "student",
            "type": "SIGNATURE",
            "index": 0,
            "position": {
                "page": 2,
                "x": 100,
                "y": 200
            }
        },
        {
            "category": "professor",
            "type": "SIGNATURE",
            "index": 0, // example : the first professor on the recipient array is index 0, the second professor is index 1 etc
            "position": {
                "page": 2,
                "x": 200,
                "y": 50
            }
        },
        {
            "category": "professor",
            "type": "SIGNATURE",
            "index": 1,
            "position": {
                "page": 2,
                "x": 300,
                "y": 300
            }
        },
        {
            "category": "admin",
            "type": "INPUT_TO_FILL",
            "index": 0,
            "label": "Mention",
            "value": "Lu et approuvé"
            "position": {
                "page": 2,
                "x": 50,
                "y": 50
            }
        },
        {
            "category": "admin",
            "type": "SIGNATURE",
            "index": 0,
            "value": "https://upload.wikimedia.org/wikipedia/commons/9/9c/Signature_de_Amine_Zribi.jpg"
            "position": {
                "page": 2,
                "x": 200,
                "y": 400
            }
        },
    ],
    "sendDocumentToSignByEmail": true // This field is used to choose if the document should be sent by email to all recipients to allow them to sign it. Default: true
    "sendDocumentByEmailWhenCompleted": true, // This field is used to choose if the document should be sent by email to all recipients once it is fully signed. Default: true
    "signatureValidationMethod": "email", // Allowed values: "email", "sms", "none" (none make the signature validation optional). Default: "email"
    "signWithOrder": false, // This field allows to send the document to the recipients one after the other only when the previous recipient has signed
    "expirationDate": "2023-01-01T00:00:00+01:00", // This field allows you to define a date from which it will no longer be possible to sign the document
    "attachedDocuments": [ // This field allows you to link additional documents (not signable)
        {
            "name": "mon super annexe",
            "url": "https://www.africau.edu/images/default/sample.pdf"
        }
    ],
    "sendCustomDocumentEmail": {
        "subject": "",
        "body": ""
    },
    "sendCustomSignatureReminderEmail": {
        "subject": "",
        "body": "",
        "amount": 3,
        "interval": 24 // in hours
    },
    "sendCustomEmailWhenDocumentCompleted": {
        "subject": "",
        "body": ""
    },
    "document": {
        "name": "Convention de formation 2023",
        "base64": "xxxxxxxx"
    }
};

edusignAPI.documents().add(newDocument);
```

-   从模板中添加文档

```typescript
const newDocumentWithTemplate = {
    "admin": {
        "id": "osg53hexfy1w9n1",
        "inputs": { // You can use both the label (name) or ID of the input as key
            "Signature": "https://upload.wikimedia.org/wikipedia/commons/9/9c/Signature_de_Amine_Zribi.jpg",
            "263917": "01/01/2023",
            "fin formation": "31/12/2023",
            "741293": "40",
            "durée de la formation": "12 mois",
            "modalité de paiement": "par carte bancaire"
        }
    },
    "recipients": [
        // Each array of recipients represents a document that will be sent. All recipient arrays must be identical (same number of recipients in the same order), only the IDs must be different from one array to another
        // document 1
        [
            {
                "category": "student", // Allowed values: "student", "external", "professor"
                "id": "0prgik79vcfjo1wb"
            },
            {
                "category": "professor",
                "id": "r5oppiecwxd13paj"
            }
        ],
        // document 2
        [
            {
                "category": "student",
                "id": "0prgik79vcfjo1wb"
            },
            {
                "category": "professor",
                "id": "cr8apy17yl82675"
            }
        ]
    ],
    "sendDocumentToSignByEmail": true // This field is used to choose if the document should be sent by email to all recipients to allow them to sign it. Default: true
    "sendDocumentByEmailWhenCompleted": true, // This field is used to choose if the document should be sent by email to all recipients once it is fully signed. Default: true
    "signatureValidationMethod": "email", // Allowed values: "email", "sms", "none" (none make the signature validation optional). Default: "email"
    "signWithOrder": false, // This field allows to send the document to the recipients one after the other only when the previous recipient has signed
    "expirationDate": "2023-01-01T00:00:00+01:00", // This field allows you to define a date from which it will no longer be possible to sign the document
    "attachedDocuments": [ // This field allows you to link additional documents (not signable)
        {
            "name": "mon super annexe",
            "url": "https://www.africau.edu/images/default/sample.pdf"
        }
    ],
    "sendCustomDocumentEmail": {
        "subject": "",
        "body": ""
    },
    "sendCustomSignatureReminderEmail": {
        "subject": "",
        "body": "",
        "amount": 3,
        "interval": 24 // in hours
    },
    "sendCustomEmailWhenDocumentCompleted": {
        "subject": "",
        "body": ""
    }
};

edusignAPI.documents().addFromTemplate("templateId", newDocumentWithTemplate);
```

-   获取所有文档

```typescript
// optional params getHtml: false, offset: 0, limit: 500, recipientId: 'recipientId', state: 'pending', createdAfter: '2021-01-01T00:00:00', createBefore: '2021-01-01T00:00:00'
edusignAPI.documents().getAll({
  getHtml: false,
  offset: 0,
  limit: 500,
  recipientId: "recipientId",
  state: "pending",
  createdAfter: "2021-01-01T00:00:00",
  createBefore: "2021-01-01T00:00:00",
});
```

-   由 ID 获取文档

```typescript
edusignAPI.documents().get("documentId");
```

-   删除文档

```typescript
edusignAPI.documents().delete("documentId");
```

-   在教授日期之间生成课程摘要

```typescript
edusignAPI
  .documents()
  .generateCourseSummaryBetweenDatesForProfessor(
    "professorId",
    "startDate",
    "endDate"
  );
```

-   在学生之间生成课程摘要

```typescript
edusignAPI
  .documents()
  .generateCourseSummaryBetweenDatesForStudent(
    "studentId",
    "startDate",
    "endDate",
    "groupId"
  );
```

### 文档目录

-   获取全部目录

```typescript
edusignAPI.documents().getAllDirectories();
```

-   由 ID 获取目录

```typescript
edusignAPI.documents().getDirectory("directoryId");
```

### 文件模板

-   获取全部文档模板

```typescript
edusignAPI.documentTemplates().getAll();
```

-   由 Id 获取文档模板

```typescript
edusignAPI.documentTemplates().get("documentTemplateId");
```

-   通过文件 Id 添加文档模板

```typescript
edusignAPI.documentTemplates().getByDocumentId("documentId");
```

-   删除文档模板

```typescript
edusignAPI.documentTemplates().delete("documentTemplateId");
```

### 外部人员

-   添加外部

```typescript
const newExternal = {
  FIRSTNAME: "Kurt",
  LASTNAME: "Cobain",
  EMAIL: "kurtcobain@gmail.com",
  COMPANY: "", // 36 chars max.
  TYPE: 0, // 0: unknown, 1 = maitre d'apprentissage, ... // Mandatory
  PHONE: "0637625172",
  API_ID: "32895Y",
  API_TYPE: "test",
};

edusignAPI.externals().add(newExternal);
```

-   获取所有外部

```typescript
// optional params keyword The keyword to search FIRSTNAME, LASTNAME, and EMAIL
// ⚠️ keyword param is currently not mandatory but strongly recommended
edusignAPI.externals().getAll(keyword);
```

-   由 Id 获取外部

```typescript
edusignAPI.externals().get("externalId");
```

-   通过电子邮件获取外部

```typescript
edusignAPI.externals().byEmail("externalEmail@test.com");
```

-   编辑外部

```typescript
const updateExternal = {
  ID: "adj82jdflb01k",
  FIRSTNAME: "Kurt",
  LASTNAME: "Cobain",
  EMAIL: "kurtcobain@gmail.com",
  COMPANY: "",
  TYPE: 0, // 0: unknown, 1 = maitre d'apprentissage, 2 = RH... // Mandatory
  PHONE: "0637625172",
  API_ID: "32895Y",
  API_TYPE: "test",
};

edusignAPI.externals().edit(updateExternal);
```

-   由 Id 删除外部

```typescript
edusignAPI.externals().delete("externalId");
```

### 组

-   添加组

```typescript
const newGroup = {
        NAME: "Master Digital 2020-2022",
        DESCRIPTION: "Whatever you want",
        STUDENTS: ["ad876fgh7","gh76th76FG","n876GBnvPPM", ...],
        PARENT: "", // If this group is a sub-group, add the id of the parent group
        API_ID: "jfgjihgfsc97s", // API ID (if needed)
        API_TYPE: "" // Name of the connector linked to
    };

edusignAPI.groups().add(newGroup);
```

-   获取所有组

```typescript
// params page:2
// ⚠️ page param is currently not mandatory but strongly recommended
edusignAPI.groups().getAll(2);
```

-   由 Id 组合

```typescript
edusignAPI.groups().get("groupId");
```

-   由 api Id 组合

```typescript
edusignAPI.groups().getIdByApiId("groupApiId");
```

-   按名称获取组

```typescript
edusignAPI.groups().getName("groupName");
```

-   编辑组

```typescript
const updateGroup = {
       ID: "sdfgh67dg67",
       NAME: "Master Digital 2020-2022",
       DESCRIPTION: "Whatever you want",
       STUDENTS: ["gh876fgh7","gh76th76FG","n876GBnvPPM", ...],
       PARENT: "" // If this group is a sub-group, add the id of the parent group
   }
edusignAPI.groups().edit(updateGroup);
```

-   删除组

```typescript
edusignAPI.groups().delete("groupId");
```

### 经常

-   春季卡

```typescript
edusignAPI.iot().springCard("nfc_auth_key", "nfc_mac_address", "nfc_card_Id");
```

### 教授

-   添加教授

```typescript
const newProfessor = {
  FIRSTNAME: "Bob",
  LASTNAME: "Dylan",
  EMAIL: "bobdylan@gmail.com",
  SPECIALITY: "Marketing",
  API_ID: "f0js9Uj", // API ID of the teacher (can be used to make a link with your service)
  API_TYPE: "hyperplanning", // Name of the connector associated with the API ID (do not use if you don't know)
  TAGS: ["tag1", "tag2", "..."],
  VARIABLES: [
    // Table of additional data for the professor, must have been created first in the Interface of Edusign
    {
      NAME: "Identifiant",
      VALUE: "ar82U1kk",
      RESSOURCE_TYPE: "professor",
    },
  ],
};

edusignAPI.professors().add(newProfessor);
```

-   找所有教授来

```typescript
// params page:2
// ⚠️ page param is currently not mandatory but strongly recommended
edusignAPI.professors().getAll(1);
```

-   找博士来

```typescript
edusignAPI.professors().get("professorId");
```

-   通过 API Id 获得教授

```typescript
edusignAPI.professors().getIdByApiId("professorId");
```

-   通过电子邮件找教授

```typescript
edusignAPI.professors().byEmail("professorEmail@test.com");
```

-   编辑教授

```typescript
const updateProfessor = {
  ID: "567yhgf567",
  FIRSTNAME: "Paul",
  LASTNAME: "McCartney",
  EMAIL: "paulmccartney@gmail.com",
  SPECIALITY: "Marketing",
  API_ID: "f0js9Uj", // API ID of the teacher (can be used to make a link with your service)
  API_TYPE: "hyperplanning", // Name of the connector associated with the API ID (do not use if you don't know)
  TAGS: ["tag1", "tag2", "..."],
  VARIABLES: [
    // Table of additional data for the professor, must have been created first in the Interface of Edusign
    {
      NAME: "Identifiant",
      VALUE: "ar82U1kk",
      RESSOURCE_TYPE: "professor",
    },
  ],
};

edusignAPI.professors().edit(updateProfessor);
```

-   删除教授

```typescript
edusignAPI.professors().delete("professorId"); // ⚠️ WARNING! Never delete a teacher who is used in a group or a course!
```

### 教授变量

-   添加教授变量

```typescript
edusignAPI
  .professors()
  .addNewVariable("professorId", "variable_name", "variable_value");
```

-   获取教授变量

```typescript
edusignAPI.professors().getVariables("professorId");
```

-   编辑教授变量

```typescript
edusignAPI
  .professors()
  .editVariable("professorId", "variableId", "variable_name", "variable_value");
```

-   删除教授变量

```typescript
edusignAPI.professors().deleteVariable("variableId");
```

### 学校

-   上学吧

```typescript
edusignAPI.school().get();
```

-   每日课程

```typescript
edusignAPI.school().getDailyCourses("schoolId");
```

-   编辑学校

```typescript
const updateSchool = {
       NAME: "My super school",
       LOGO: "https://", // url of the main logo
       LOGOS: [{url: "https://", filename: "my_logo.png"}], // others logos used by the school
       STREET_ADDRESS: "1 avenue des champs élysées",
       CITY: "Paris",
       POSTALCODE: "75008",
       COUNTRY: "France",
       PHONE: "01 00 00 00 00 00",
       WEBHOOKS: [{"type":"on_student_sign","url":"https://webhook.site/abc"}, ...] // array of webhooks used in the school
   };

edusignAPI.school().edit(updateSchool);
```

### 学生

-   添加学生

```typescript
const newStudent = {
  FIRSTNAME: "Kurt",
  LASTNAME: "Cobain",
  EMAIL: "kurtcobain@gmail.com (mandatory)",
  FILE_NUMBER: "4567098547",
  PHOTO: "https://randomuser.me/api/portraits/men/64.jpg",
  PHONE: "+33782576806",
  GROUPS: ["groupIds"],
  TRAINING_NAME: "Master 1 Digital",
  COMPANY: "Edusign", // student's company (if apprenticeship or continuing education)
  TAGS: ["tag 1", "tag 2"],
  SEND_EMAIL_CREDENTIALS: true, // if true it will send an email to the student with his credentials
  API_ID: "f0js9Uj", // External ID of the student (can be used to make a link with your service)
  API_TYPE: "hyperplanning", // Name of the connector associated with the external ID (do not use if you don't know)
  BADGE_ID: "1234567", // ID of NFC card (if needed)
  STUDENT_FOLLOWER_ID: [], // ID of externals (see external section) that follows the student (Tuteur, Maitre d'apprentissage...)
  NEW_PASSWORD_NEEDED: true,
};

edusignAPI.students().add(newStudent);
```

-   让所有的学生

```typescript
// params page:2
// ⚠️ page param is currently not mandatory but strongly recommended
edusignAPI.students().getAll(2);
```

-   让学生通过id

```typescript
edusignAPI.students().get("studentId");
```

-   通过电子邮件获得学生

```typescript
edusignAPI.students().byEmail("studentEmail@test.com");
```

-   由 API ID 获取学生

```typescript
edusignAPI.students().getIdByApiId("studentApiId");
```

-   获取存在摘要

```typescript
edusignAPI.students().getPresenceSummary("studentId", "startDate", "endDate");
```

-   编辑学生

```typescript
const updateStudent = {
  ID: "45ygb678h6G6",
  FIRSTNAME: "Jimi",
  LASTNAME: "Hendrix",
  EMAIL: "jimihendrix@gmail.com",
  FILE_NUMBER: "4567098547",
  PHOTO: "https://randomuser.me/api/portraits/men/64.jpg",
  HIDDEN: false, // true if the student is soft deleted (archived) - Use endpoint "restore a student " to unarchive it /!\
  GROUPS: ["groupIds"],
  PHONE: "+33782576806",
  TRAINING_NAME: "Master 1 Digital",
  COMPANY: "Edusign", // student's company (if apprenticeship or continuing education)
  TAGS: ["Tag 1", "Tag 2"],
  API_ID: "f0js9Uj", // External ID of the student  (can be used to make a link with your service)
  API_TYPE: "hyperplanning", // Name of the connector associated with the external ID (do not use if you don't know)
  BADGE_ID: "123456", // ID of NFC card (if needed)
  STUDENT_FOLLOWER_ID: [], // ID of externals (see external section) that follows the student (Tuteur, Maitre d'apprentissage...)
};

edusignAPI.students().edit(updateStudent);
```

-   存档学生

```typescript
edusignAPI.students().archive("studentId");
```

-   恢复学生

```typescript
edusignAPI.students().restore("studentId");
```

### 学生关系

-   添加学生的外部关系

```typescript
edusignAPI
  .students()
  .addExternalRelation("studentId", "externalId", "relationType");
```

-   获取学生的外在关系

```typescript
edusignAPI.students().getRelations("studentId");
```

-   删除学生的外部关系

```typescript
edusignAPI.students().deleteRelation("studentId", "externalId");
```

### 学生变量

-   添加学生变量

```typescript
edusignAPI.students().addVariable("studentId", "variable_name", "variable_value");
```

-   获取学生变量

```typescript
edusignAPI.students().getVariables("studentId");
```

-   编辑学生变量

```typescript
edusignAPI
  .students()
  .editVariable("studentId", "variableId", "variable_name", "variable_value");
```

-   删除学生变量

```typescript
edusignAPI.students().deleteVariable("variableId");
```

### 调查

-   添加调查

```typescript
const newSurvey = {
  survey: "dkjaja181Iddk1", // Template ID of the survey used (in the URL when you create/edita survey in the edusign platform)
  students: ["6dkfds1jj822", "aksj6djf911ed", "901ml6ddj18"], // Array of id of the students
  professors: ["6djaie7jj822", "aksj6djj39dja", "ja8926ddj18"], // Array of id of the professors
  sending_date: "2021-03-20T15:00:00 (ISO 8601 datetime)", // Schedule a sending date. If it's empty, the survey is sent immediately.
};

edusignAPI.surveys().add(newSurvey);
```

-   得到所有调查

```typescript
edusignAPI.surveys().getAll();
```

-   由 Id 调查

```typescript
edusignAPI.surveys().get("surveyId");
```

-   删除调查

```typescript
edusignAPI.surveys().delete("surveyId");
```

-   发送提醒

```typescript
edusignAPI.surveys().sendReminder("surveyId");
```

-   获取全部模板

```typescript
edusignAPI.surveys().getAllTemplates();
```

-   从学生答案生成 PDF

```typescript
edusignAPI.surveys().generatePDFFromStudentAnswers("surveyId", "studentId");
```

### 用户

-   添加用户

```typescript
const newUser = {
    CREATOR_NAME: "John Doe", // Name of the person who creates the account (if empty = "WEB SERVICES") - used in the welcome email.
    NAME: "Kurt Cobain",
    EMAIL: "kurt@gmail.com",
    PHONE: "+33 6 12 34 56 78", // Phone number , optional field
    PERMISSIONS: 2, 0-5 : 0 = viewer, 1 = user, 4 = admin, 5 = Owner. (2-3 are not currently used, atempting to use them will result in a user created with permissions 1)
};

edusignAPI.users().add(newUser);
```

-   获取所有用户

```typescript
edusignAPI.users().getAll();
```

-   删除用户

```typescript
edusignAPI.users().delete("userId");
```

-   更改用户权限

```typescript
edusignAPI.users().changePermissions("userId", 3); // permissions: 0 | 1 | 2 | 3 | 4 | 5
```

### 用户

-   从 Adobe 文档获取输入

```typescript
import fs from "fs";

const fileContent = fs.readFileSync("filePath");
const base64Data = Buffer.from(fileContent).toString("base64"); // output in string format

edusignAPI.utils().getInputsFromAdobeDocument(base64Data);
```

-   从文档文本获取输入

```typescript
import fs from "fs";

const fileContent = fs.readFileSync("filePath");
const base64Data = Buffer.from(fileContent).toString("base64"); // output in string format

edusignAPI.utils().getInputsFromDocumentText(base64Data);
```

### 教室

-   添加课堂

```typescript
edusignAPI.classrooms().add("classroom_add");
```

-   把所有的教室都搬来

```typescript
edusignAPI.classrooms().getAll();
```

-   以姓名命名课堂

```typescript
edusignAPI.classrooms().getByName("classroom_name");
```

-   更新教室

```typescript
edusignAPI.classrooms().update("classroom_id", "classroom_name");
```

-   以 id 删除教室

```typescript
edusignAPI.classrooms().delete("classroom_id");
```

-   按名称删除教室

```typescript
edusignAPI.classrooms().deleteByName("classroom_name");
```

### 现状

-   设置学生缺席

```typescript
edusignAPI
  .presentialStates()
  .setStudentAbsent("student_id", "course_id", "comment");
```

-   设置学生延迟

```typescript
edusignAPI
  .presentialStates()
  .setStudentDelayed("student_id", "course_id", 30, "comment"); // 30 is delay in minutes
```

-   早点出发

```typescript
edusignAPI
  .presentialStates()
  .setStudentEarlyDeparture("student_id", "course_id", "early_date", "comment");
```

-   设置学生评论

```typescript
edusignAPI
  .presentialStates()
  .setStudentComment("student_id", "course_id", "comment");
```

-   设置排除学生

```typescript
edusignAPI
  .presentialStates()
  .setStudentExcluded("student_id", "course_id", "excludeDate", "comment");
```

-   设置学生在场

```typescript
edusignAPI.presentialStates().setStudentPresent("course_id", "student_id");
```

### 折旧

-   删除文档

```typescript
edusignAPI.deprecated().deleteDocument("document_id");
```

-   获取全部文档

```typescript
edusignAPI
  .deprecated()
  .getAllDocuments(
    `optional : {studentId?: 'studentId', start?: 'startDate', end?: 'enddate'}`
  );
```

-   由 ID 获取文档

```typescript
edusignAPI.deprecated().getDocumentById("document_id");
```

-   获取全部文档模板

```typescript
edusignAPI.deprecated().getAllDocumentTemplates();
```

-   发送模板以签名

```typescript
const template = {
    user_id: "2gb2fc6a11edb",
    sendDocumentToRecipients: true, // if true, send the signed document to the recipients once the document is signed
    templateId: "", // template ID
    adminSignature: {
       name: "Dylan Teixeira", // your admin signatory name
       email: "dylan@edusign.fr", // your admin signatory email
       signature: "https://edusign-sign.s3.eu-west-3.amazonaws.com/ac81505d3ecb669e8aa1a7f43e8055b25d3d029c00e58ea514cf28f02f40f8d4.jpg" // fill with your admin URL signature
    },
    signatory: {
       type: "students", // or "externals" if there is no student that needs to sign the document
       id: "fhdehj8H4sq2", // id of the student that has to sign the document (max 1 student)
       externalsId: [] // Id of the external signatories for the document (optional)
    },
    redirectionLinkOnceSigned: "", // used to specify an URL where to redirect the user once he has signed
    validateSignatureBy: "email" // use "email" or "sms" to choose the method for sending the signature validation code or "none" to deactivate the option
    emailReminder: {
       subject: "", // objet du mail
       message: "", // corps du mail
       amount: 3, // maximum 5
       interval: 1 // in hours
    },
    fields: { // If your template has fields that has to be filled, please provide an object with the "name" of the field. If all the field are not filled, the API will respond an array with the fields to fill
       "debut coaching": "12/12/2021",
       "fin coaching": "23/12/2021"
    },
    directoryId: "" // ID of a directory
};

edusignAPI.deprecated().sendTemplateToSign(template);
```

-   发送文档以签名

```typescript
const document = {
  students: ["a72344hzzaa", "2983I902ksdf"], // ID of the students that will receive and sign the document (One document per student).
  user_id: "2gb2fc6a99edb",
  fields: {
    // If your template has fields that has to be filled, please provide an object with the "name" of the field. If all the field are not filled, the API will respond an array with the fields to fill
    "input_date debut coaching": "12/12/2021",
    "input_date fin coaching": "23/12/2021",
  },
  admin_signature:
    "https://upload.wikimedia.org/wikipedia/commons/6/68/Justin_Timberlake_signature.jpg", // admin signature (if needed in the template)
  sendDocumentToStudent: true, // if true, send the signed document to the student,
  validateSignatureBy: "email", // use "email" or "sms" to choose the method for sending the signature validation code or "none" to deactivate the option
};

edusignAPI.deprecated().sendDocumentToSign(document);
```

-   没有模板就发送文档

```typescript
import fs from "fs";

const fileContent = fs.readFileSync("filePath");
const base64Data = Buffer.from(fileContent).toString("base64"); // output in string format

const document = {
  user_id: "2gb2fc6a11edb",
  document: {
    name: "file_name.pdf",
    base64: base64Data,
  },
  sendDocumentToRecipients: true, // if true, send the signed document to the recipients once the document is signed
  signatories: [
    {
      type: "student", // or "external"
      id: "fhdehj8H4sq2", // id of the student that has to sign the document (max 1 student)
      elements: [
        {
          type: "",
          position: {
            page: "",
            x: "",
            y: "",
          },
        },
      ],
    },
  ],
  redirectionLinkOnceSigned: "", // used to specify an URL where to redirect the user once he has signed
  validateSignatureBy: "email", // use "email" or "sms" to choose the method for sending the signature validation code or "none" to deactivate the option
  emailReminder: {
    subject: "", // objet du mail
    message: "", // corps du mail
    amount: 3, // maximum 5
    interval: 1, // in hours
  },
  directoryId: "", // ID of a directory
};

edusignAPI.deprecated().sendDocumentWithoutTemplate(document);
```

-   以 Id 为理由缺席

```typescript
edusignAPI.deprecated().getJustifiedAbsenceById("absence_id");
```

## 维护者

这种回波由Edusign开发和维护.

## 常见问题

### @\_edusign/api 是什么？

Edusign ext API 为访问您的数据提供了简单的方式\. 无论是课程,老师,还是学生\. 您将使用库方法访问存储在 REST API 中的数据 \.

### 如何安装 @\_edusign/api？

在项目目录运行 npm install @\_edusign/api，或使用 pnpm add / yarn add / bun add。

### @\_edusign/api 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @\_edusign/api 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @\_edusign/api 可以商用吗？

@\_edusign/api 使用 ISC 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @\_edusign/api 的下载量有多少？

根据 npm 官方下载统计，@\_edusign/api 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,732 次，日均约 124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @\_edusign/api 还在维护吗？

最新版本 1\.12\.0 发布于 2025/04/25（1\.5 年前）；至今共发布 55 个版本，其中过去 12 个月发布了 0 个；首次发布于 2023/08/08。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

