---
title: "Create or update a Story Rule"
method: POST
path: "/rules"
tags: ["rules"]
---

# Create or update a Story Rule

`POST /rules`

## Request

- Base URL: `https://aistoryhub.co/api/v1`
- URL: `https://aistoryhub.co/api/v1/rules`
- Auth: HTTP bearer

Reusing an existing name overwrites that rule instead of creating a duplicate.

## Request body

- RuleCreate
  - `name` string, required: Reusing an existing name overwrites it.
  - `instructions` string, required
  - `special_instructions` string
  - `context` string
  - `description` string
  - `content_rating` 'general' | 'adult'

## Response `201`

The created or updated rule.

- Rule
  - `id` string, uuid
  - `name` string
  - `instructions` string
  - `special_instructions` string, nullable
  - `context` string, nullable
  - `description` string, nullable
  - `content_rating` 'general' | 'adult'
  - `created_at` string, date-time, nullable
  - `updated_at` string, date-time, nullable

## Other responses

- `400`: The request body or parameters are invalid.
- `401`: Missing, malformed, invalid, revoked, or expired token.
- `403`: The token lacks the scope this endpoint requires.
- `429`: Too many requests. Retry after the delay in the `Retry-After` header.

---

[API](https://skmtc.dev/aistoryhub/apis/aistoryhub-api.md) · [All operations](https://skmtc.dev/aistoryhub/apis/aistoryhub-api/llms.txt) · [OpenAPI document](https://skmtc.dev/aistoryhub/apis/aistoryhub-api/revisions/0cfd2c14ae12?raw)
