---
title: "新增协议脚本"
method: POST
path: "/api/v1/things/protocol/script/create"
tags: ["things/protocol/script", "thingsProtocolScript"]
---

# 新增协议脚本

`POST /api/v1/things/protocol/script/create`

## Request body

- ProtocolScript
  - `id` string
  - `name` string
  - `desc` string
  - `triggerDir` integer — 1:up 2:down
  - `triggerTimer` integer — 收到前处理1:before 2:after
  - `triggerHandle` string — 对应 mqtt topic的第一个 thing ota config 等等
  - `triggerType` string — 操作类型 从topic中提取 物模型下就是 property属性 event事件 action行为
  - `script` string — 脚本内容
  - `status` integer — 状态:是否启用
  - `createdTime` integer — 创建时间

## Response `200`

A successful response.

- object
  - `code` integer
  - `msg` string
  - `data` WithIDStr
    - `id` string — id

## Changes

- **2025-03-14** `e87dbcac5d9e` — 2 breaking
  - removed the request body
  - removed the media type `application/json` for the response with the status `200`

[Change history](https://skmtc.dev/unitedrhino/apis/things-api/changes/api/v1/things/protocol/script/create/post.md)

---

[API](https://skmtc.dev/unitedrhino/apis/things-api.md) · [All operations](https://skmtc.dev/unitedrhino/apis/things-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/unitedrhino/things-api/revisions/65ee90cd440e/schema)
