跳到主要内容

v1 API 创建表单

API使用者,可以通过本接口,创建一个新的表单,并配置字段

功能免费版专业版/专业增强版企业基础版企业协作版企业高级版
创建表单✔️✔️✔️

认证方式

V1 Basic 认证方式

headers 设置

需要在请求中设置如下 headers

  • Content-Type: application/json
  • Accept: application/json
  • Authorization: 放入上一步骤生成的CODE

接口说明

  • 个人版用户/企业子账号用户,以自己身份创建表单。
  • 企业全局 API,以企业 owner 身份创建表单。
  • 可选地将新表单放入某个文件夹,通过 folder_token 参数指定目标文件夹的 token(可通过获取文件夹列表得到)。

接口描述

Request

POST https://jinshuju.net/api/v1/forms

{
"name": "产品需求调研表",
"description": "感谢您能抽出几分钟时间填写以下内容",
"fields": [
{ "type": "TextField", "label": "姓名", "required": true },
{ "type": "MobileField", "label": "手机号" },
{
"type": "RadioButton",
"label": "您对产品的整体评价",
"choices": [
{ "value": "非常满意" },
{ "value": "满意" },
{ "value": "一般" },
{ "value": "不满意" }
]
}
],
"setting": {
"success_message": "感谢您的反馈!",
"password_required": true,
"access_password": "abc123",
"fill_frequency": { "fill_type": "once", "condition": "by_ip" }
},
"folder_token": "aZ9bQ3"
}
参数名称是否必须类型说明
nameString表单标题
fieldsArray字段定义数组,至少一个字段
fields[].typeString字段类型,见下方「支持的字段类型」
fields[].labelString字段标题
fields[].requiredBool是否必填(默认 false)
fields[].privateBool是否隐藏字段(默认 false),与 required 互斥
fields[].notesString字段描述/提示文字
fields[].choicesArray选项数组(仅适用于选择类字段)
fields[].choices[].valueString选项展示值
fields[].choices[].quotaNumber选项可选配额上限
fields[].rating_maxNumber评分字段最大分(支持 3/5/10,默认 5)
fields[].init_row_lengthNumber表格题初始行数(1-5,默认 3)
fields[].dimensionsArray表格题列定义
descriptionString表单描述
settingObject表单设置对象(提交后行为、表单状态、提交限制、权限、Webhook、通知规则等)。完整字段见表单设置 Schemasetting.notification_rules 用于配置企微 / 钉钉 / Webhook 类高级通知规则,详见 schema。
folder_tokenString目标文件夹 token;设置后新表单会放入该文件夹

支持的字段类型

基础字段(19 种)

TextField TextArea NumberField EmailField MobileField TelephoneField IdCardField NameField AddressField LinkField GeoField AttachmentField DateTimeField TimeField RatingField NpsField RadioButton CheckBox DropDown

进阶字段

TableField CascadeDropDown SortField LikertField MatrixField MatrixScaleField ImageRadioButton ImageCheckBox GoodsField FormulaField ReservationField FormAssociation ESignatureField AudioField

装饰 / 控件类(不收集数据):

PageBreak SectionBreak WidgetButton WidgetContact WidgetMap WidgetMarquee

SectionBreak 即"描述字段",用于在表单里插入一段说明文字(不收集数据)。

部分字段需要专业版及以上套餐(FormulaField / GoodsField / FormAssociation / ESignatureField / WidgetButton 等);账号套餐不支持时返回 400 并附带升级提示。

表格题(TableField)的列可选类型:TextField TextArea NumberField EmailField MobileField IdCardField NameField CheckBox DropDown DateTimeField RatingField

字段特定属性

下列属性按字段类型分组,仅对应类型识别,传给其他类型会被静默忽略。所有属性均可选;不传则使用字段默认值。

字段类型属性类型说明
TextField / TextArea / MobileField / TelephoneField / LinkFieldpredefined_valueString默认预填值
同上placeholderString占位提示文案
EmailFieldplaceholderString占位提示文案
NumberFieldpredefined_valueString默认预填值
NumberFieldplaceholderString占位提示文案
NumberFieldrange_minNumber允许的最小值(闭区间)
NumberFieldrange_maxNumber允许的最大值(闭区间)
NumberFieldprecisionInteger小数位数(0–6)
DateTimeFieldpredefined_valueString默认值。可填与 precision 匹配的日期串,或 today / yesterday / tomorrow
DateTimeFieldprecisionString精度:year / month / day(默认) / hour / minute / second
TimeFieldpredefined_valueString默认值(HH:MMHH:MM:SS
TimeFieldinclude_secondBool是否精确到秒
AddressFieldpredefined_valueObject默认地址 {province, city, district, street}
AddressFieldchangeableBool用户是否可在填写页修改
AddressFieldenable_auto_positionBool是否启用自动定位
AttachmentFieldmax_sizeNumber单文件最大尺寸(MB)
AttachmentFieldmax_file_quantityInteger最多上传文件数(1–15)
AttachmentFieldmedia_typeStringall / image / video
AttachmentFieldmobile_camera_onlyBool移动端是否仅允许拍照(不开放相册)
NpsFieldminimum_ratings_display_textString最低分文案
NpsFieldmaximum_ratings_display_textString最高分文案
RatingFieldrating_maxNumber评分最大分(3 / 5 / 10,默认 5)
SortFieldrandom_choicesBool选项随机展示
AudioFieldmax_durationNumber最大录音时长(秒)
CascadeDropDownlevelsInteger级联层数
CascadeDropDownchoice_filterableBool是否允许搜索选项
CascadeDropDownrandom_choicesBool选项随机展示
LikertField / MatrixField / MatrixScaleFieldhorizontal_on_mobileBool移动端横向排版
LikertFieldlikert_choice_styleString单选样式
LikertFieldminimum_length / maximum_lengthInteger单选数量限制
GoodsFieldunitString计量单位文案(如「件」)
GoodsFieldcollapse_on_mobileBool移动端折叠展示
GoodsFieldcolumns_on_mobileInteger移动端列数
FormulaFieldformula_displayString公式表达式(HTML 标签内嵌字段引用)
FormulaFieldresult_display_typeString结果展示形式(text / number / date
FormulaFieldprecision / display_as_percentage / thousands_separator-数字结果展示控制
ReservationFieldallow_multiple_itemsBool是否允许选多个时段
ReservationFielditem_allow_multiple_reservationsBool单时段是否允许多人预约
FormAssociationassociated_form_tokenString被关联表单的 token
FormAssociationassociated_field_api_codesArray(String)关联字段(最多 4 个)
FormAssociationprivacy_safeBool是否隐去关联表单的隐私字段
PageBreakdisable_previous_pageBool禁止返回上一页
PageBreakprevious_page_text / next_page_textString自定义按钮文案

完整属性以及最新约束以服务端为准;常见用法可参考 MCP describe_field_type 工具的输出。

Response

{
"name": "产品需求调研表",
"description": "感谢您能抽出几分钟时间填写以下内容",
"fields": [
{
"field_1": {
"label": "姓名",
"type": "single_line_text",
"notes": "",
"private": false,
"validation": { "required": true }
}
},
{
"field_2": {
"label": "手机号",
"type": "mobile",
"notes": "",
"private": false,
"validation": {}
}
}
]
}

响应结构与获取单个表单结构相同。

状态码

状态码说明
201创建成功
400参数校验失败(name 或 fields 为空、字段类型非法、表单设置校验失败等;设置校验规则详见表单设置 Schema的"错误处理"小节)
401未认证
402当前套餐不支持 V1 API
404指定的 folder_token 不存在,或当前账号无权管理该文件夹

示例代码

伪代码

api_key = "YOUR_API_KEY"
api_secret = "YOUR_API_SECRET"

credentials = api_key + ":" + api_secret
encoded_credentials = base64_encode(credentials)
auth_header_payload = "Basic " + encoded_credentials
headers = {"Authorization": auth_header_payload, "Content-Type": "application/json"}

body = {
"name": "产品需求调研表",
"fields": [{"type": "TextField", "label": "姓名", "required": true}]
}

http.post("https://jinshuju.net/api/v1/forms", headers, body)

HTTP

POST https://jinshuju.net/api/v1/forms

Content-Type: application/json
Accept: application/json
Authorization: Basic BASE_64_ENCODED_CREDENTIALS

{
"name": "产品需求调研表",
"fields": [{"type": "TextField", "label": "姓名", "required": true}]
}

Postman

POST https://jinshuju.net/api/v1/forms

authorization 选择 `Basic Auth`
Username 输入 API Key
Password 输入 API Secret

Body (raw, JSON):
{
"name": "产品需求调研表",
"fields": [{"type": "TextField", "label": "姓名", "required": true}]
}

Python

import requests

api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'

payload = {
"name": "产品需求调研表",
"fields": [{"type": "TextField", "label": "姓名", "required": True}]
}

response = requests.post(
'https://jinshuju.net/api/v1/forms',
auth=(api_key, api_secret),
json=payload
)

print(response.text)

Ruby

require 'net/http'
require 'uri'
require 'json'

uri = URI.parse('https://jinshuju.net/api/v1/forms')
api_key = 'YOUR_API_KEY'
api_secret = 'YOUR_API_SECRET'

payload = {
name: '产品需求调研表',
fields: [{ type: 'TextField', label: '姓名', required: true }]
}

request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
request.basic_auth(api_key, api_secret)
request.body = payload.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(request)
end

puts(response.body)