> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create (or upsert) an organization policy rule.

> POSTing a name that already exists atomically REPLACES that rule — this is how a policy pack is re-uploaded without stacking duplicates. Lint errors (e.g…

POSTing a name that already exists atomically REPLACES that rule — this is
how a policy pack is re-uploaded without stacking duplicates. Lint errors
(e.g. RULE007 unbound head variable) reject the write with 400; soft
`lint_warnings` are returned alongside a successful create.

**Required scope:** `write`

### Request body

`CreateRuleRequest`

**body** `RuleAtomRequest[]` *required*

**confidence** `number (float)`

**description** `string`

**effect** `object`

**head\_args** `string[]` *required*

**head\_predicate** `string` *required*

**name** `string` *required*

**test\_cases** `RuleTestCaseRequest[]`

### Response

No response body. Rule created or replaced; body carries id and any lint\_warnings.

### Status codes

| Code | Meaning |
| - | - |
| `201` | Rule created or replaced; body carries id and any lint\_warnings |
| `400` | Lint error — the rule was not installed |
| `401` | Unauthorized — missing or invalid credentials |
| `402` | Tenant rule quota exhausted |
| `403` | Forbidden — the key/token lacks the required scope |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset |

```bash cURL theme={null}
curl --request POST \
  --url 'https://api.nsr.stateset.com/api/v1/rules' \
  --header "X-API-Key: $STATESET_NSR_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "body": [
    {
      "args": [],
      "negated": true,
      "predicate": "string"
    }
  ],
  "confidence": 7.5,
  "description": "Two-person tent, green — replacement for damaged pole set.",
  "effect": {
    "0": "p",
    "1": "e",
    "2": "r",
    "3": "m",
    "4": "i",
    "5": "t"
  },
  "head_args": [
    "string"
  ],
  "head_predicate": "string",
  "name": "Two-Person Tent",
  "test_cases": [
    {
      "expected_output": {},
      "input_bindings": {},
      "name": "Two-Person Tent",
      "should_fire": true
    }
  ]
}'
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.