---
title: "Create Or Update Rule Chain (saveRuleChain)"
method: POST
path: "/api/ruleChain"
tags: ["rule-chain-controller"]
---

# Create Or Update Rule Chain (saveRuleChain)

`POST /api/ruleChain`

Create or update the Rule Chain. When creating Rule Chain, platform generates Rule Chain Id as [time-based UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_1_(date-time_and_MAC_address)). The newly created Rule Chain Id will be present in the response. Specify existing Rule Chain id to update the rule chain. Referencing non-existing rule chain Id will cause 'Not Found' error.

The rule chain object is lightweight and contains general information about the rule chain. List of rule nodes and their connection is stored in a separate 'metadata' object.Remove 'id', 'tenantId' from the request body example (below) to create new Rule Chain entity.

Available for users with 'TENANT_ADMIN' authority.

## Request body

- RuleChain — A JSON value representing the rule chain.
  - `id` RuleChainId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'RULE_CHAIN', required — string
  - `createdTime` integer — Timestamp of the rule chain creation, in milliseconds
  - `tenantId` TenantId, required
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'TENANT', required — string
  - `name` string, required — Rule Chain name
  - `type` 'CORE' | 'EDGE' — Rule Chain type. 'EDGE' rule chains are processing messages on the edge devices only.
  - `firstRuleNodeId` RuleNodeId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'RULE_NODE', required — string
  - `root` boolean — Indicates root rule chain. The root rule chain process messages from all devices and entities by default. User may configure default rule chain per device profile.
  - `debugMode` boolean — Reserved for future usage.
  - `version` integer
  - `configuration` unknown
  - `additionalInfo` unknown

## Response `200`

OK

- RuleChain — A JSON value representing the rule chain.
  - `id` RuleChainId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'RULE_CHAIN', required — string
  - `createdTime` integer — Timestamp of the rule chain creation, in milliseconds
  - `tenantId` TenantId, required
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'TENANT', required — string
  - `name` string, required — Rule Chain name
  - `type` 'CORE' | 'EDGE' — Rule Chain type. 'EDGE' rule chains are processing messages on the edge devices only.
  - `firstRuleNodeId` RuleNodeId
    - `id` string, uuid, required — ID of the entity, time-based UUID v1
    - `entityType` 'RULE_NODE', required — string
  - `root` boolean — Indicates root rule chain. The root rule chain process messages from all devices and entities by default. User may configure default rule chain per device profile.
  - `debugMode` boolean — Reserved for future usage.
  - `version` integer
  - `configuration` unknown
  - `additionalInfo` unknown

---

[API](https://skmtc.net/thingsboard/apis/thingsboard-rest-api.md) · [All operations](https://skmtc.net/thingsboard/apis/thingsboard-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/thingsboard/thingsboard-rest-api/revisions/40169ccdec5c/schema)
