Update teamspace policies
Incrementally update policy configuration for the teamspace associated with the API key. Only the fields you include in the request body are modified — omitted fields remain unchanged. For source types, use
enable/disable arrays (both allowed if no overlap). For library lists, use add/remove objects or clear: true to remove all. Requires owner or admin role. All field names use camelCase. With dryRun: true nothing is saved; the response shows the policies the patch would give, accessibleLibraryCount after the change, and currentAccessibleLibraryCount before it.1 min read
patch/v2/policies
Request example
curl --request PATCH \
--url https://context7.com/api/v2/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"sourceTypes": {
"disable": [
"websites"
]
}
}'import requests
url = "https://context7.com/api/v2/policies"
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json",
}
payload = {
"sourceTypes": {
"disable": [
"websites"
]
}
}
response = requests.request("PATCH", url, headers=headers, json=payload)
print(response.text)const response = await fetch('https://context7.com/api/v2/policies', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"sourceTypes": {
"disable": [
"websites"
]
}
})
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://context7.com/api/v2/policies',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS => '{
"sourceTypes": {
"disable": [
"websites"
]
}
}',
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/policies"
payload := strings.NewReader("{\n \"sourceTypes\": {\n \"disable\": [\n \"websites\"\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/policies"))
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("{\n \"sourceTypes\": {\n \"disable\": [\n \"websites\"\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/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 = '{
"sourceTypes": {
"disable": [
"websites"
]
}
}'
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/policies
Authorization
Get your API key at context7.com/dashboard. Treat your API key like a password and store it securely. Every key can read the management API (
/v2/teamspaces/*), except personal data: member and invitation emails, library requesters, visitor questions, Docs7 reader searches, conversations, feedback and feature requests, and the GitHub account behind a build. To read those or make changes there, the key must be created with Write access ticked; other keys get 403 write_access_required.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 policy configuration
Was this page helpful?