---
title: "Update library policies"
method: PATCH
path: "/v2/teamspaces/{teamspaceId}/policies"
tags: ["Teamspace Admin"]
---

# Update library policies

`PATCH /v2/teamspaces/{teamspaceId}/policies`

## Request

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

Incremental update with the same body as `PATCH /v2/policies`. With `dryRun: true` nothing is saved and the response shows the result and its library count. Owners and admins only. Teamspace name and deletion are not part of this API.

## Request body

- object: Incremental policy update. All fields are optional — only provided fields are modified. At least one of 'sourceTypes' or 'libraryFilters' must be provided.
  - `dryRun` boolean: Preview the change and its library count without saving.
  - `sourceTypes` object: Enable or disable specific source types. Both can be provided in one request, but the same type cannot appear in both arrays.
    - `enable` string[]: Source types to enable
    - `disable` string[]: Source types to disable
  - `libraryFilters` object: Update library access filters.
    - `mode` 'quality' | 'select' | 'null', nullable: Filter mode (null to clear)
    - `quality` object: Update quality-mode settings.
      - `requireVerified` boolean: Restrict to verified libraries only
      - `minTrustScore` integer, nullable: Minimum trust score, 0-10 (null to clear)
      - `maxAgeDays` integer, nullable: Maximum age in days (null to clear)
      - `blockedLibraries` ListOperation: Incremental add/remove operation on a list of library identifiers or domains. Use 'clear' to remove all entries at once.
        - `add` string[]: Identifiers to add — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
        - `remove` string[]: Identifiers to remove — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
        - `clear` boolean: Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.
      - `exceptedLibraries` ListOperation: Incremental add/remove operation on a list of library identifiers or domains. Use 'clear' to remove all entries at once.
        - `add` string[]: Identifiers to add — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
        - `remove` string[]: Identifiers to remove — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
        - `clear` boolean: Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.
      - `repoFilters` object: Update repo-specific quality filters.
        - `minStars` integer, nullable: Minimum stars threshold (null to clear)
        - `allowedLicenses` LicenseListOperation: Incremental add/remove operation on a list of SPDX license identifiers. Use 'clear' to remove all entries at once.
          - `add` string[]: SPDX license identifiers to add (e.g. 'MIT', 'Apache-2.0', 'BSD-3-Clause')
          - `remove` string[]: SPDX license identifiers to remove
          - `clear` boolean: Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.
      - `websiteFilters` object: Update website-specific quality filters.
        - `minBacklinks` integer, nullable: Minimum backlinks threshold (null to clear)
        - `minReferringDomains` integer, nullable: Minimum referring domains threshold (null to clear)
        - `minOrganicTraffic` integer, nullable: Minimum organic traffic threshold (null to clear)
    - `select` object: Update select-mode settings.
      - `allowedLibraries` ListOperation: Incremental add/remove operation on a list of library identifiers or domains. Use 'clear' to remove all entries at once.
        - `add` string[]: Identifiers to add — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
        - `remove` string[]: Identifiers to remove — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
        - `clear` boolean: Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.

## Response `200`

Updated policies, or the dry-run preview

- union
  - PolicyResponse: Complete teamspace policy configuration
    - `sourceTypes` object, required: Access settings for each documentation source type
      - `public_repos` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `private_sources` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `confluence` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `uploaded_files` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `websites` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `llmstxt` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
    - `libraryFilters` object, required: Library access filters. Mode determines which sub-object is active.
      - `mode` 'quality' | 'select' | 'null', nullable, required: Filter mode: 'quality' for threshold-based filtering, 'select' for manual library selection
      - `quality` object, required: Quality-mode settings (active when mode is 'quality')
        - `requireVerified` boolean, required: Restrict to verified libraries only
        - `minTrustScore` integer, nullable, required: Minimum trust score, 0-10
        - `maxAgeDays` integer, nullable, required: Maximum days since last update
        - `blockedLibraries` string[], required: Libraries excluded from results
        - `exceptedLibraries` string[], required: Libraries that bypass all quality filters, blocked list, and source type restrictions
        - `repoFilters` object, required: Repo-specific quality filters
          - `minStars` integer, nullable, required: Minimum GitHub stars required
          - `allowedLicenses` string[], required: SPDX license identifiers (e.g. 'MIT', 'Apache-2.0') that are allowed. Empty array means no license restriction. Applies to public repos only; non-repo source types pass through.
        - `websiteFilters` object, required: Website-specific quality filters
          - `minBacklinks` integer, nullable, required: Minimum number of backlinks required
          - `minReferringDomains` integer, nullable, required: Minimum number of referring domains required
          - `minOrganicTraffic` integer, nullable, required: Minimum monthly organic traffic required
      - `select` object, required: Select-mode settings (active when mode is 'select')
        - `allowedLibraries` string[], required: Libraries explicitly allowed
    - `accessibleLibraryCount` integer, required: Number of public libraries currently accessible under these filters
  - TeamspacePolicyDryRunResponse: The policies the patch would give. `accessibleLibraryCount` counts the libraries they would allow. Nothing is saved.
    - `sourceTypes` object, required: Access settings for each documentation source type
      - `public_repos` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `private_sources` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `confluence` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `uploaded_files` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `websites` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
      - `llmstxt` SourceTypeStatus, required: Whether a source type is enabled or disabled
        - `enabled` boolean, required: Whether this source type is enabled
    - `libraryFilters` object, required: Library access filters. Mode determines which sub-object is active.
      - `mode` 'quality' | 'select' | 'null', nullable, required: Filter mode: 'quality' for threshold-based filtering, 'select' for manual library selection
      - `quality` object, required: Quality-mode settings (active when mode is 'quality')
        - `requireVerified` boolean, required: Restrict to verified libraries only
        - `minTrustScore` integer, nullable, required: Minimum trust score, 0-10
        - `maxAgeDays` integer, nullable, required: Maximum days since last update
        - `blockedLibraries` string[], required: Libraries excluded from results
        - `exceptedLibraries` string[], required: Libraries that bypass all quality filters, blocked list, and source type restrictions
        - `repoFilters` object, required: Repo-specific quality filters
          - `minStars` integer, nullable, required: Minimum GitHub stars required
          - `allowedLicenses` string[], required: SPDX license identifiers (e.g. 'MIT', 'Apache-2.0') that are allowed. Empty array means no license restriction. Applies to public repos only; non-repo source types pass through.
        - `websiteFilters` object, required: Website-specific quality filters
          - `minBacklinks` integer, nullable, required: Minimum number of backlinks required
          - `minReferringDomains` integer, nullable, required: Minimum number of referring domains required
          - `minOrganicTraffic` integer, nullable, required: Minimum monthly organic traffic required
      - `select` object, required: Select-mode settings (active when mode is 'select')
        - `allowedLibraries` string[], required: Libraries explicitly allowed
    - `accessibleLibraryCount` integer, required: Number of public libraries currently accessible under these filters
    - `dryRun` true
    - `currentAccessibleLibraryCount` integer: Libraries the saved policies allow now.

## Other responses

- `400`: Bad Request - Invalid input parameters
- `401`: Unauthorized - Invalid or missing API key
- `403`: Forbidden - Insufficient permissions or plan restrictions
- `404`: Not Found - Resource doesn't exist
- `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/policies/patch.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)
