---
title: "Create a rule"
method: POST
path: "/v2/teamspaces/{teamspaceId}/rules"
tags: ["Teamspace Admin"]
---

# Create a rule

`POST /v2/teamspaces/{teamspaceId}/rules`

## Request

- Base URL: `https://context7.com/api`
- URL: `https://context7.com/api/v2/teamspaces/{teamspaceId}/rules`
- Auth: HTTP bearer

Owners and admins only, on a teamspace whose owner has a paid plan (403 `paid_plan_required`).

## Request body

- object
  - `text` string, required
  - `libraryId` string, nullable: Library id starting with `/`. Omit or null for a rule on every library.
  - `libraryType` 'repo' | 'llmstxt' | 'website' | 'openapi' | 'pdf' | 'docx' | 'file' | 'confluence' | 'notion': Display hint for the library.
  - `docsUrl` string, uri: http(s) link shown with the library.

## Response `200`

Rule created

- TeamspaceRuleResponse
  - `success` boolean
  - `data` object
    - `text` string, required
    - `createdBy` string, required: User id of the author.
    - `createdAt` integer, required: Unix time in milliseconds.
    - `libraryType` 'repo' | 'llmstxt' | 'website' | 'openapi' | 'pdf' | 'docx' | 'file' | 'confluence' | 'notion'
    - `docsUrl` string, uri
    - `id` string, uuid: Returned on create only.

## Other responses

- `400`: Bad Request - Invalid input parameters
- `401`: Unauthorized - Invalid or missing API key
- `403`: Forbidden - Insufficient permissions or plan restrictions
- `500`: Internal Server Error

## Changes

- **2026-10-22** `e17589fd8767`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/context7/apis/context7-public-api/changes/v2/teamspaces/:teamspaceId/rules/post.md)

---

[API](https://skmtc.dev/context7/apis/context7-public-api.md) - [All operations](https://skmtc.dev/context7/apis/context7-public-api/llms.txt) - [OpenAPI document](https://skmtc.dev/context7/apis/context7-public-api/revisions/945f7834fa8c?raw)
