> For the complete documentation index, see [llms.txt](https://docs.nected.ai/nected-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nected.ai/nected-docs/management-api/rules/update-rule.md).

# Update rule

Update an existing rule by entity ID. Send a **partial** request body with only the fields you want to change. Include the **checksum** from the last get/create/update/test when the API requires it for optimistic locking. Payload shape matches create (same type-specific fields); do not change `type`. The **response** returns `data.checksum` for use in the next update or publish.

Use the API reference below to try the endpoint.

## Update rule

> Update an existing rule. Include \*\*checksum\*\* when required. Use examples for full decision-table update or full simpleRule/ruleSet style bodies.

```json
{"openapi":"3.0.3","info":{"title":"Nected Rule API (Dev V1)","version":"1.0"},"tags":[{"name":"Rule","description":"List, create, read, update, test, schedule, and publish rules."}],"servers":[{"url":"https://api.nected.ai","description":"Production"}],"security":[{"DevAuth":[]}],"components":{"securitySchemes":{"DevAuth":{"type":"apiKey","in":"header","name":"Nected-API-Key","description":"Dev API key (`Nected-API-Key` header)"}},"schemas":{"UpdateRulePayload":{"type":"object","description":"Partial update for an existing rule. Send **only the fields you want to change**.\n\n- Include `checksum` from the last get/create/update when the API requires optimistic locking.\n- Do **not** change `type`.\n- Full decision-table update example: `Update/update_DT.json` and `examples/patch_rule_decisionTable.json`.\n- For simpleRule / ruleSet, full-body style patches are shown in `examples/patch_rule_simpleRule.json` and `patch_rule_ruleSet.json`.","additionalProperties":true,"properties":{"checksum":{"type":"string","description":"From last get/create/update; required for optimistic locking when applicable"},"name":{"type":"string"},"description":{"type":"string"},"dataSetId":{"type":"string","nullable":true},"customInput":{"type":"object"},"conditions":{"type":"object"},"action":{"type":"object"},"settings":{"type":"object"},"decisionTable":{"type":"object","nullable":true},"ruleSet":{"type":"array","nullable":true,"items":{}},"ruleSetPolicy":{"type":"string"},"ruleChain":{"type":"object","nullable":true,"additionalProperties":true},"policy":{"type":"string"},"dependencyMap":{"type":"array"}}},"UpdateRuleResponse":{"type":"object","description":"Success response for Update rule (PATCH).","properties":{"data":{"type":"object","properties":{"checksum":{"type":"string","description":"New checksum for next update or publish"}}},"code":{"type":"string"},"message":{"type":"string"}}},"Response":{"type":"object","description":"Standard API response wrapper","properties":{"code":{"type":"string"},"data":{"description":"Response payload: rule object, array of rules (list), version rows, or execution result — shape varies by endpoint"},"message":{"type":"string"},"pageNo":{"type":"integer"},"pageSize":{"type":"integer"},"totalCount":{"type":"integer"},"totalPages":{"type":"integer"},"paginationInfo":{"$ref":"#/components/schemas/PaginationInfo"}}},"PaginationInfo":{"type":"object","description":"Pagination metadata returned by GET /dev/v1/rule (list rules)","properties":{"perPage":{"type":"integer","description":"Page size (items per page)"},"totalPage":{"type":"integer","description":"Total number of pages"},"currentPage":{"type":"integer","description":"Current page index"},"totalRecord":{"type":"integer","description":"Total records across all pages"}}}}},"paths":{"/dev/v1/rule/{entity-id}":{"patch":{"operationId":"updateRule","tags":["Rule"],"summary":"Update rule","description":"Update an existing rule. Include **checksum** when required. Use examples for full decision-table update or full simpleRule/ruleSet style bodies.","parameters":[{"name":"Nected-Branch","in":"header","required":false,"description":"Branch name (optional)","schema":{"type":"string"}},{"name":"entity-id","in":"path","required":true,"schema":{"type":"string"},"description":"The rule's entity ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRulePayload"}}}},"responses":{"200":{"description":"OK. Returns data.checksum.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateRuleResponse"}}}},"400":{"description":"Bad Request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}},"500":{"description":"Internal Server Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}}}
```

{% hint style="info" %}
Replace the example `checksum` values with the **current** value from **Get rule by id** for your entity.
{% endhint %}

### Where to get the Checksum?

The API expects the current **`checksum`** of the rule for **optimistic locking**. If the checksum in your request does not match the rule’s latest checksum on the server, the call fails with a **checksum mismatch** error and the rule is **not** updated.

**Recommended flow**

1. Call **Get rule by id** (`GET /dev/v1/rule/{entity-id}`) for the rule you want to change.
2. From the response, copy **`data.checksum`** (the exact string returned by the API).
3. Paste that value into your **PATCH** body as **`checksum`** (alongside the fields you are updating).

You can also obtain a valid checksum from:

* **Create rule** — `data.checksum` in the `201` response, or
* **Update rule** — `data.checksum` in the `200` response from your **last successful** update

Always use the **latest** checksum before each update if the rule may have changed.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nected.ai/nected-docs/management-api/rules/update-rule.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
