List rules
Teamspace Rules that Context7 adds to answers. Any member can call it.
1 min read
get/v2/teamspaces/{teamspaceId}/rules
Request example
curl --request GET \
--url https://context7.com/api/v2/teamspaces/{teamspaceId}/rules \
--header 'Authorization: Bearer <token>'import requests
url = "https://context7.com/api/v2/teamspaces/{teamspaceId}/rules"
headers = {
"Authorization": "Bearer <token>",
}
response = requests.request("GET", url, headers=headers)
print(response.text)const response = await fetch('https://context7.com/api/v2/teamspaces/{teamspaceId}/rules', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
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}/rules',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://context7.com/api/v2/teamspaces/{teamspaceId}/rules"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
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}/rules"))
.header("Authorization", "Bearer <token>")
.method("GET", HttpRequest.BodyPublishers.noBody())
.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}/rules')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Get.new(url)
request['Authorization'] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyResponse
{
"success": true,
"data": {
"global": {},
"libraries": {}
}
}{
"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": "api_keys_disabled",
"message": "This teamspace does not allow API keys. Connect with OAuth instead: run `npx ctx7@latest setup --mcp --oauth`, or see https://context7.com/docs/howto/oauth"
}{
"error": "forbidden",
"message": "Private repositories require a pro plan or team. Upgrade at https://context7.com/plans"
}{
"error": "internal_error",
"message": "An error occurred while processing your request"
}get/v2/teamspaces/{teamspaceId}/rules
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. A teamspace can limit API keys to owners and admins, or turn them off for OAuth only; a key that its teamspace's policy refuses gets 403 api_key_admins_only or api_keys_disabled.Path parameters
Teamspace id (from
GET /v2/teamspaces).Responses
application/json
Rules
Show child attributesHide child attributes
Rules for every library, keyed by rule id.
Show child attributesHide child attributes
Rules for one library, keyed by library id, then by rule id.
Show child attributesHide child attributes
Show child attributesHide child attributes
Was this page helpful?