Create one or more learnings
curl --request POST \
--url https://api.coderabbit.ai/v1/learnings \
--header 'Content-Type: application/json' \
--header 'x-coderabbitai-api-key: <api-key>' \
--data '
{
"data": [
{
"repository_id": "<string>",
"learning": "<string>",
"file": "<string>",
"source_url": "<string>"
}
],
"org_id": "<string>"
}
'import requests
url = "https://api.coderabbit.ai/v1/learnings"
payload = {
"data": [
{
"repository_id": "<string>",
"learning": "<string>",
"file": "<string>",
"source_url": "<string>"
}
],
"org_id": "<string>"
}
headers = {
"x-coderabbitai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-coderabbitai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
repository_id: '<string>',
learning: '<string>',
file: '<string>',
source_url: '<string>'
}
],
org_id: '<string>'
})
};
fetch('https://api.coderabbit.ai/v1/learnings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.coderabbit.ai/v1/learnings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'repository_id' => '<string>',
'learning' => '<string>',
'file' => '<string>',
'source_url' => '<string>'
]
],
'org_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-coderabbitai-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.coderabbit.ai/v1/learnings"
payload := strings.NewReader("{\n \"data\": [\n {\n \"repository_id\": \"<string>\",\n \"learning\": \"<string>\",\n \"file\": \"<string>\",\n \"source_url\": \"<string>\"\n }\n ],\n \"org_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-coderabbitai-api-key", "<api-key>")
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))
}HttpResponse<String> response = Unirest.post("https://api.coderabbit.ai/v1/learnings")
.header("x-coderabbitai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"repository_id\": \"<string>\",\n \"learning\": \"<string>\",\n \"file\": \"<string>\",\n \"source_url\": \"<string>\"\n }\n ],\n \"org_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.coderabbit.ai/v1/learnings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-coderabbitai-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"repository_id\": \"<string>\",\n \"learning\": \"<string>\",\n \"file\": \"<string>\",\n \"source_url\": \"<string>\"\n }\n ],\n \"org_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"created_count": 123,
"duplicate_count": 123,
"failed_count": 123,
"results": [
{
"index": 123,
"status": "created",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"error": {
"code": "INVALID_ITEM",
"message": "<string>"
}
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}Create Learnings
Creates 1–100 repository-scoped learnings and indexes them for future reviews. Enterprise plan and learning:write permission required.
POST
/
v1
/
learnings
Create one or more learnings
curl --request POST \
--url https://api.coderabbit.ai/v1/learnings \
--header 'Content-Type: application/json' \
--header 'x-coderabbitai-api-key: <api-key>' \
--data '
{
"data": [
{
"repository_id": "<string>",
"learning": "<string>",
"file": "<string>",
"source_url": "<string>"
}
],
"org_id": "<string>"
}
'import requests
url = "https://api.coderabbit.ai/v1/learnings"
payload = {
"data": [
{
"repository_id": "<string>",
"learning": "<string>",
"file": "<string>",
"source_url": "<string>"
}
],
"org_id": "<string>"
}
headers = {
"x-coderabbitai-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-coderabbitai-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
repository_id: '<string>',
learning: '<string>',
file: '<string>',
source_url: '<string>'
}
],
org_id: '<string>'
})
};
fetch('https://api.coderabbit.ai/v1/learnings', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.coderabbit.ai/v1/learnings",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => [
[
'repository_id' => '<string>',
'learning' => '<string>',
'file' => '<string>',
'source_url' => '<string>'
]
],
'org_id' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-coderabbitai-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.coderabbit.ai/v1/learnings"
payload := strings.NewReader("{\n \"data\": [\n {\n \"repository_id\": \"<string>\",\n \"learning\": \"<string>\",\n \"file\": \"<string>\",\n \"source_url\": \"<string>\"\n }\n ],\n \"org_id\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-coderabbitai-api-key", "<api-key>")
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))
}HttpResponse<String> response = Unirest.post("https://api.coderabbit.ai/v1/learnings")
.header("x-coderabbitai-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"repository_id\": \"<string>\",\n \"learning\": \"<string>\",\n \"file\": \"<string>\",\n \"source_url\": \"<string>\"\n }\n ],\n \"org_id\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.coderabbit.ai/v1/learnings")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-coderabbitai-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"repository_id\": \"<string>\",\n \"learning\": \"<string>\",\n \"file\": \"<string>\",\n \"source_url\": \"<string>\"\n }\n ],\n \"org_id\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"created_count": 123,
"duplicate_count": 123,
"failed_count": 123,
"results": [
{
"index": 123,
"status": "created",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"error": {
"code": "INVALID_ITEM",
"message": "<string>"
}
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"code": "<string>",
"message": "<string>"
}
]
}Create Learnings
Requires the
learning:write permission. Workspace API key owners must also remain workspace admins.API key eligibility
User and workspace API keys can create Learnings. Legacy organization API keys and agentic API keys cannot use this endpoint. A workspace API key must select one organization for every request by providing that organization’s Git provider ID asorg_id.
Batch behavior
Each request processes an ordered batch of 1–100 items. Every item identifies a repository and supplies Learning text; file-path and source-URL metadata are optional. CodeRabbit resolves repository ownership from the authenticated organization and records the authenticated user as the author. Callers cannot set either value. A processed batch returns HTTP 200 even when individual items fail. Check the overall status and every item result: each item is reported ascreated, duplicate, or failed in request order.
Redaction and retries
CodeRabbit redacts recognized credentials before storing and indexing Learning text. Each item receives a stable ID derived from its organization, repository, and redacted content, so retrying identical content is safe. A retry can also repair the review index when the canonical record was created but indexing failed. Publishing content that already exists as a private Learning from an open pull request promotes the existing Learning to shared status instead of creating another record.Rate limit
The Learnings write endpoints share a limit of 10 requests per minute per organization.Authorizations
API key for authentication. You can create an API key from the CodeRabbit dashboard.
Body
application/json
Was this page helpful?