Update library policies
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.1 min read
patch/v2/teamspaces/{teamspaceId}/policies
Request example
curl --request PATCH \
--url https://context7.com/api/v2/teamspaces/{teamspaceId}/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"dryRun": true,
"sourceTypes": {
"enable": [
"public_repos"
],
"disable": [
"public_repos"
]
},
"libraryFilters": {
"mode": "quality",
"quality": {
"requireVerified": true,
"minTrustScore": 0,
"maxAgeDays": 1,
"blockedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"exceptedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"repoFilters": {
"minStars": 0,
"allowedLicenses": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
},
"websiteFilters": {
"minBacklinks": 0,
"minReferringDomains": 0,
"minOrganicTraffic": 0
}
},
"select": {
"allowedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
}
}
}'import requests
url = "https://context7.com/api/v2/teamspaces/{teamspaceId}/policies"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
}
payload = {
"dryRun": True,
"sourceTypes": {
"enable": [
"public_repos"
],
"disable": [
"public_repos"
]
},
"libraryFilters": {
"mode": "quality",
"quality": {
"requireVerified": True,
"minTrustScore": 0,
"maxAgeDays": 1,
"blockedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": True
},
"exceptedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": True
},
"repoFilters": {
"minStars": 0,
"allowedLicenses": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": True
}
},
"websiteFilters": {
"minBacklinks": 0,
"minReferringDomains": 0,
"minOrganicTraffic": 0
}
},
"select": {
"allowedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": True
}
}
}
}
response = requests.request("PATCH", url, headers=headers, json=payload)
print(response.text)const response = await fetch('https://context7.com/api/v2/teamspaces/{teamspaceId}/policies', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"dryRun": true,
"sourceTypes": {
"enable": [
"public_repos"
],
"disable": [
"public_repos"
]
},
"libraryFilters": {
"mode": "quality",
"quality": {
"requireVerified": true,
"minTrustScore": 0,
"maxAgeDays": 1,
"blockedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"exceptedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"repoFilters": {
"minStars": 0,
"allowedLicenses": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
},
"websiteFilters": {
"minBacklinks": 0,
"minReferringDomains": 0,
"minOrganicTraffic": 0
}
},
"select": {
"allowedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
}
}
})
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://context7.com/api/v2/teamspaces/{teamspaceId}/policies',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS => '{
"dryRun": true,
"sourceTypes": {
"enable": [
"public_repos"
],
"disable": [
"public_repos"
]
},
"libraryFilters": {
"mode": "quality",
"quality": {
"requireVerified": true,
"minTrustScore": 0,
"maxAgeDays": 1,
"blockedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"exceptedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"repoFilters": {
"minStars": 0,
"allowedLicenses": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
},
"websiteFilters": {
"minBacklinks": 0,
"minReferringDomains": 0,
"minOrganicTraffic": 0
}
},
"select": {
"allowedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
}
}
}',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "https://context7.com/api/v2/teamspaces/{teamspaceId}/policies"
payload := strings.NewReader("{\n \"dryRun\": true,\n \"sourceTypes\": {\n \"enable\": [\n \"public_repos\"\n ],\n \"disable\": [\n \"public_repos\"\n ]\n },\n \"libraryFilters\": {\n \"mode\": \"quality\",\n \"quality\": {\n \"requireVerified\": true,\n \"minTrustScore\": 0,\n \"maxAgeDays\": 1,\n \"blockedLibraries\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n },\n \"exceptedLibraries\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n },\n \"repoFilters\": {\n \"minStars\": 0,\n \"allowedLicenses\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n }\n },\n \"websiteFilters\": {\n \"minBacklinks\": 0,\n \"minReferringDomains\": 0,\n \"minOrganicTraffic\": 0\n }\n },\n \"select\": {\n \"allowedLibraries\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n }\n }\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://context7.com/api/v2/teamspaces/{teamspaceId}/policies"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("{\n \"dryRun\": true,\n \"sourceTypes\": {\n \"enable\": [\n \"public_repos\"\n ],\n \"disable\": [\n \"public_repos\"\n ]\n },\n \"libraryFilters\": {\n \"mode\": \"quality\",\n \"quality\": {\n \"requireVerified\": true,\n \"minTrustScore\": 0,\n \"maxAgeDays\": 1,\n \"blockedLibraries\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n },\n \"exceptedLibraries\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n },\n \"repoFilters\": {\n \"minStars\": 0,\n \"allowedLicenses\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n }\n },\n \"websiteFilters\": {\n \"minBacklinks\": 0,\n \"minReferringDomains\": 0,\n \"minOrganicTraffic\": 0\n }\n },\n \"select\": {\n \"allowedLibraries\": {\n \"add\": [\n \"<string>\"\n ],\n \"remove\": [\n \"<string>\"\n ],\n \"clear\": true\n }\n }\n }\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://context7.com/api/v2/teamspaces/{teamspaceId}/policies')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Patch.new(url)
request['Authorization'] = 'Bearer <token>'
request['Content-Type'] = 'application/json'
request.body = '{
"dryRun": true,
"sourceTypes": {
"enable": [
"public_repos"
],
"disable": [
"public_repos"
]
},
"libraryFilters": {
"mode": "quality",
"quality": {
"requireVerified": true,
"minTrustScore": 0,
"maxAgeDays": 1,
"blockedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"exceptedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
},
"repoFilters": {
"minStars": 0,
"allowedLicenses": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
},
"websiteFilters": {
"minBacklinks": 0,
"minReferringDomains": 0,
"minOrganicTraffic": 0
}
},
"select": {
"allowedLibraries": {
"add": [
"<string>"
],
"remove": [
"<string>"
],
"clear": true
}
}
}
}'
response = http.request(request)
puts response.read_bodyResponse
{
"sourceTypes": {
"public_repos": {
"enabled": true
},
"private_sources": {
"enabled": true
},
"confluence": {
"enabled": true
},
"uploaded_files": {
"enabled": true
},
"websites": {
"enabled": true
},
"llmstxt": {
"enabled": true
}
},
"libraryFilters": {
"mode": "quality",
"quality": {
"requireVerified": true,
"minTrustScore": 1,
"maxAgeDays": 1,
"blockedLibraries": [
"<string>"
],
"exceptedLibraries": [
"<string>"
],
"repoFilters": {
"minStars": 1,
"allowedLicenses": [
"<string>"
]
},
"websiteFilters": {
"minBacklinks": 1,
"minReferringDomains": 1,
"minOrganicTraffic": 1
}
},
"select": {
"allowedLibraries": [
"<string>"
]
}
},
"accessibleLibraryCount": 1
}{
"error": "validation_error",
"message": "Library name is required"
}{
"error": "invalid_library_id",
"message": "Invalid library ID format. Expected: `/owner/repo` for GitHub repositories, or `/<source>/<id>` for other sources (the URL path of the library on context7.com)"
}{
"error": "invalid_api_key",
"message": "Invalid API key. Please check your API key. API keys should start with 'ctx7sk' prefix."
}{
"error": "access_denied",
"message": "Access denied: Library /owner/repo is not included in your allowed libraries"
}{
"error": "forbidden",
"message": "Only team owners and admins can add private repositories"
}{
"error": "forbidden",
"message": "Private repositories require a pro plan or team. Upgrade at https://context7.com/plans"
}{
"error": "library_not_found",
"message": "Library \"/owner/repo\" not found. Please check the library ID or your access permissions."
}{
"error": "version_not_found",
"message": "Version \"canary\" not found for library \"/owner/repo\". Available versions: v2.0.0, v1.5.0"
}{
"error": "no_snippets_found",
"message": "Could not fetch documentation snippets from the library."
}{
"error": "no_relevant_snippets",
"message": "No documentation in \"/owner/repo\" matched this query. Try a more specific query with different terms, or search for another library that covers this topic."
}{
"error": "team_not_found",
"message": "Team not found or access denied"
}{
"error": "user_not_found",
"message": "User not found"
}{
"error": "no_libraries_found",
"message": "No libraries found for \"nonexistent-lib\". Try a different search term."
}{
"error": "internal_error",
"message": "An error occurred while processing your request"
}patch/v2/teamspaces/{teamspaceId}/policies
Authorization
Get your API key at context7.com/dashboard. Treat your API key like a password and store it securely.
Path parameters
Teamspace id (from
GET /v2/teamspaces).Body
application/jsonPreview the change and its library count without saving.
Enable or disable specific source types. Both can be provided in one request, but the same type cannot appear in both arrays.
Update library access filters.
Show child attributesHide child attributes
Update quality-mode settings.
Show child attributesHide child attributes
Restrict to verified libraries only
Incremental add/remove operation on a list of library identifiers or domains. Use 'clear' to remove all entries at once.
Show child attributesHide child attributes
Identifiers to add — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
Identifiers to remove — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.
Incremental add/remove operation on a list of library identifiers or domains. Use 'clear' to remove all entries at once.
Show child attributesHide child attributes
Identifiers to add — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
Identifiers to remove — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.
Update repo-specific quality filters.
Show child attributesHide child attributes
Incremental add/remove operation on a list of SPDX license identifiers. Use 'clear' to remove all entries at once.
Update website-specific quality filters.
Update select-mode settings.
Show child attributesHide child attributes
Incremental add/remove operation on a list of library identifiers or domains. Use 'clear' to remove all entries at once.
Show child attributesHide child attributes
Identifiers to add — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
Identifiers to remove — library paths (e.g. '/org/repo', '/org') or domains (e.g. 'stripe.com')
Set to true to remove all entries. Cannot be used together with 'add' or 'remove'.
Responses
application/json
Updated policies, or the dry-run preview
Was this page helpful?