Managing Prompt Pull Requests via Confident AI SDK
Overview
The Confident AI SDK exposes every Pull Request method on the platform. This page documents how to call these methods in all supported languages. See the introduction to install the SDK and set your API key.
Methods
Get Pull Requests
Lists the pull requests of the prompt one page at a time, newest first, optionally filtered by status, source branch or title. Each pull request is returned in brief; retrieve it by id for its description and merge details. Branches are referenced by id, which the prompt's branches list supplies.
from confident_ai import ConfidentAI
from confident_ai.prompts import PRStatus
client = ConfidentAI()
result = client.prompts.get_pull_requests(
prompt_id="<PROMPT-ID>",
page=1,
page_size=25,
status=PRStatus.OPEN,
source_branch_id="<BRANCH-ID>",
search_term="tone",
)For async mode, call a_get_pull_requests and await it as shown below:
result = await client.prompts.a_get_pull_requests(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
page | Optional[int] | The page of pull requests to return. Defaults to 1. |
page_size | Optional[int] | The number of pull requests per page, at most 100. Defaults to 25. |
status | Optional[PRStatus] | Only return pull requests in this status. See PRStatus. |
source_branch_id | Optional[str] | Only return pull requests opened from this branch id. |
search_term | Optional[str] | Only return pull requests whose title contains this text, ignoring case. |
import { ConfidentAI } from "confident-ai";
import { PRStatus } from "confident-ai/prompts";
const client = new ConfidentAI();
const result = await client.prompts.getPullRequests(
"<PROMPT-ID>",
{
page: 1,
pageSize: 25,
status: PRStatus.OPEN,
sourceBranchId: "<BRANCH-ID>",
searchTerm: "tone"
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
page | number | The page of pull requests to return. Defaults to 1. |
pageSize | number | The number of pull requests per page, at most 100. Defaults to 25. |
status | PRStatus | Only return pull requests in this status. See PRStatus. |
sourceBranchId | string | Only return pull requests opened from this branch id. |
searchTerm | string | Only return pull requests whose title contains this text, ignoring case. |
Returns
This method returns an object of type PromptPullRequestList.
Create Pull Request
Opens a pull request proposing to merge the source branch of the prompt into the target branch, and returns its id. The pull request is attributed to the owner of the API key or the signed-in MCP user, so a key without an owner is rejected. The source branch must have commits, the two branches must differ, and only one pull request can be open for a branch pair.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.create_pull_request(
prompt_id="<PROMPT-ID>",
title="Tighten the support tone",
description="Shortens the greeting and drops the apology.",
source_branch_id="<SOURCE-BRANCH-ID>",
target_branch_id="<TARGET-BRANCH-ID>",
)For async mode, call a_create_pull_request and await it as shown below:
result = await client.prompts.a_create_pull_request(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
title | str | Required. The title of the pull request. |
description | Optional[str] | What the pull request changes and why. Omit to leave it empty when opening, or to keep the stored value when updating; send null when updating to clear it. |
source_branch_id | Optional[str] | The id of the branch whose changes are proposed. Required when opening a pull request, and it must have at least one commit. Ignored when updating, since a pull request keeps its branches. |
target_branch_id | Optional[str] | The id of the branch the changes would be merged into, different from the source branch. Required when opening a pull request. Ignored when updating. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.createPullRequest(
"<PROMPT-ID>",
"Tighten the support tone",
{
description: "Shortens the greeting and drops the apology.",
sourceBranchId: "<SOURCE-BRANCH-ID>",
targetBranchId: "<TARGET-BRANCH-ID>"
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
title | string | Required. The title of the pull request. |
description | string | null | What the pull request changes and why. Omit to leave it empty when opening, or to keep the stored value when updating; send null when updating to clear it. |
sourceBranchId | string | The id of the branch whose changes are proposed. Required when opening a pull request, and it must have at least one commit. Ignored when updating, since a pull request keeps its branches. |
targetBranchId | string | The id of the branch the changes would be merged into, different from the source branch. Required when opening a pull request. Ignored when updating. |
Returns
This method returns an object of type PromptPullRequestRef.
Get Pull Request
Retrieves a pull request of the prompt, with its description, who opened and merged it, and the merge commit once it is merged.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.get_pull_request(
prompt_id="<PROMPT-ID>",
pull_request_id="<PULL-REQUEST-ID>",
)For async mode, call a_get_pull_request and await it as shown below:
result = await client.prompts.a_get_pull_request(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
pull_request_id | str | Required. The unique id of the pull request. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.getPullRequest(
"<PROMPT-ID>",
"<PULL-REQUEST-ID>",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
pullRequestId | string | Required. The unique id of the pull request. |
Returns
This method returns an object of type PromptPullRequest.
Update Pull Request
Changes the title and description of an open pull request and returns the updated pull request. Its branches cannot be changed, and a merged or closed pull request cannot be updated.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.update_pull_request(
prompt_id="<PROMPT-ID>",
pull_request_id="<PULL-REQUEST-ID>",
title="Tighten the support tone",
description="Shortens the greeting and drops the apology.",
source_branch_id="<SOURCE-BRANCH-ID>",
target_branch_id="<TARGET-BRANCH-ID>",
)For async mode, call a_update_pull_request and await it as shown below:
result = await client.prompts.a_update_pull_request(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
pull_request_id | str | Required. The unique id of the pull request. |
title | str | Required. The title of the pull request. |
description | Optional[str] | What the pull request changes and why. Omit to leave it empty when opening, or to keep the stored value when updating; send null when updating to clear it. |
source_branch_id | Optional[str] | The id of the branch whose changes are proposed. Required when opening a pull request, and it must have at least one commit. Ignored when updating, since a pull request keeps its branches. |
target_branch_id | Optional[str] | The id of the branch the changes would be merged into, different from the source branch. Required when opening a pull request. Ignored when updating. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.updatePullRequest(
"<PROMPT-ID>",
"<PULL-REQUEST-ID>",
"Tighten the support tone",
{
description: "Shortens the greeting and drops the apology.",
sourceBranchId: "<SOURCE-BRANCH-ID>",
targetBranchId: "<TARGET-BRANCH-ID>"
},
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
pullRequestId | string | Required. The unique id of the pull request. |
title | string | Required. The title of the pull request. |
description | string | null | What the pull request changes and why. Omit to leave it empty when opening, or to keep the stored value when updating; send null when updating to clear it. |
sourceBranchId | string | The id of the branch whose changes are proposed. Required when opening a pull request, and it must have at least one commit. Ignored when updating, since a pull request keeps its branches. |
targetBranchId | string | The id of the branch the changes would be merged into, different from the source branch. Required when opening a pull request. Ignored when updating. |
Returns
This method returns an object of type PromptPullRequest.
Close Pull Request
Closes an open pull request without merging it. A merged or closed pull request cannot be closed.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.close_pull_request(
prompt_id="<PROMPT-ID>",
pull_request_id="<PULL-REQUEST-ID>",
)For async mode, call a_close_pull_request and await it as shown below:
result = await client.prompts.a_close_pull_request(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
pull_request_id | str | Required. The unique id of the pull request. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.closePullRequest(
"<PROMPT-ID>",
"<PULL-REQUEST-ID>",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
pullRequestId | string | Required. The unique id of the pull request. |
Returns
This method returns an object of type PromptPullRequestRef.
Merge Pull Request
Merges an open pull request: the source branch's latest commit becomes a new merge commit on the target branch, and the pull request is marked merged. Returns the merge commit, whose hash pulls the merged prompt. It fails when the source branch changed after the merge started, in which case retry.
from confident_ai import ConfidentAI
client = ConfidentAI()
result = client.prompts.merge_pull_request(
prompt_id="<PROMPT-ID>",
pull_request_id="<PULL-REQUEST-ID>",
)For async mode, call a_merge_pull_request and await it as shown below:
result = await client.prompts.a_merge_pull_request(...)Parameters
| Parameter | Type | Description |
|---|---|---|
prompt_id | str | Required. The unique id of the prompt. |
pull_request_id | str | Required. The unique id of the pull request. |
import { ConfidentAI } from "confident-ai";
const client = new ConfidentAI();
const result = await client.prompts.mergePullRequest(
"<PROMPT-ID>",
"<PULL-REQUEST-ID>",
);Parameters
| Parameter | Type | Description |
|---|---|---|
promptId | string | Required. The unique id of the prompt. |
pullRequestId | string | Required. The unique id of the pull request. |
Returns
This method returns an object of type PromptCommit.
Types
PRStatus
Where a pull request stands: OPEN while it awaits a decision, MERGED once its changes landed on the target branch, or CLOSED when it was dropped without merging.
class PRStatus(Enum):
OPEN = "OPEN"
MERGED = "MERGED"
CLOSED = "CLOSED"enum PRStatus {
OPEN = "OPEN",
MERGED = "MERGED",
CLOSED = "CLOSED",
}OPEN · MERGED · CLOSED
PromptCommit
class PromptCommit:
id: str
hash: str
message: stridstrRequired
The id of a commit generated by Confident AI, not to be confused with the prompt id or the commit hash.
Example: "<COMMIT-ID>"
hashstrRequired
The hash of a commit generated by Confident AI.
Example: "bab04ce"
messagestrRequired
The message associated with a commit, not to be confused with a prompt's messages.
Example: "Committed from API"
interface PromptCommit {
id: string;
hash: string;
message: string;
}idstringRequired
The id of a commit generated by Confident AI, not to be confused with the prompt id or the commit hash.
Example: "<COMMIT-ID>"
hashstringRequired
The hash of a commit generated by Confident AI.
Example: "bab04ce"
messagestringRequired
The message associated with a commit, not to be confused with a prompt's messages.
Example: "Committed from API"
PromptPullRequest
A proposal to merge one branch of a prompt into another, with where it stands and, once merged, the commit it produced.
class PromptPullRequest:
id: str
title: str
status: PRStatus
source_branch_id: str = Field(alias="sourceBranchId")
target_branch_id: str = Field(alias="targetBranchId")
created_by: UserReference = Field(alias="createdBy")
created_at: str = Field(alias="createdAt")
merged_at: Optional[str] = Field(alias="mergedAt")
description: Optional[str]
merged_by: Optional[UserReference] = Field(alias="mergedBy")
merge_commit: Optional[PromptCommit] = Field(alias="mergeCommit")
updated_at: str = Field(alias="updatedAt")idstrRequired
The unique id of the pull request.
Example: "<PULL-REQUEST-ID>"
titlestrRequired
The title of the pull request.
Example: "Tighten the support tone"
statusPRStatusRequired
See PRStatus.
source_branch_idstrRequired
The id of the branch whose changes are proposed.
Example: "<SOURCE-BRANCH-ID>"
target_branch_idstrRequired
The id of the branch the changes would be merged into.
Example: "<TARGET-BRANCH-ID>"
created_byUserReferenceRequired
The user who opened the pull request.
See UserReference.
created_atstrRequired
When the pull request was opened, as an ISO 8601 timestamp.
Example: "2026-05-28T13:05:24.777000+00:00"
merged_atOptional[str]Required
When the pull request was merged, as an ISO 8601 timestamp, or null while it has not been merged.
descriptionOptional[str]Required
What the pull request changes and why, or null when none was given.
Example: "Shortens the greeting and drops the apology."
merged_byOptional[UserReference]Required
The user who merged the pull request, or null while it is not merged or when the merge was not attributed to a user.
See UserReference.
merge_commitOptional[PromptCommit]Required
The commit the merge created on the target branch, or null while the pull request is not merged.
See PromptCommit.
updated_atstrRequired
When the pull request was last updated, as an ISO 8601 timestamp.
Example: "2026-05-28T13:35:16.268000+00:00"
interface PromptPullRequest {
id: string;
title: string;
status: PRStatus;
sourceBranchId: string;
targetBranchId: string;
createdBy: UserReference;
createdAt: string;
mergedAt: string | null;
description: string | null;
mergedBy: UserReference | null;
mergeCommit: PromptCommit | null;
updatedAt: string;
}idstringRequired
The unique id of the pull request.
Example: "<PULL-REQUEST-ID>"
titlestringRequired
The title of the pull request.
Example: "Tighten the support tone"
statusPRStatusRequired
See PRStatus.
sourceBranchIdstringRequired
The id of the branch whose changes are proposed.
Example: "<SOURCE-BRANCH-ID>"
targetBranchIdstringRequired
The id of the branch the changes would be merged into.
Example: "<TARGET-BRANCH-ID>"
createdByUserReferenceRequired
The user who opened the pull request.
See UserReference.
createdAtstringRequired
When the pull request was opened, as an ISO 8601 timestamp.
Example: "2026-05-28T13:05:24.777000+00:00"
mergedAtstring | nullRequired
When the pull request was merged, as an ISO 8601 timestamp, or null while it has not been merged.
descriptionstring | nullRequired
What the pull request changes and why, or null when none was given.
Example: "Shortens the greeting and drops the apology."
mergedByUserReference | nullRequired
The user who merged the pull request, or null while it is not merged or when the merge was not attributed to a user.
See UserReference.
mergeCommitPromptCommit | nullRequired
The commit the merge created on the target branch, or null while the pull request is not merged.
See PromptCommit.
updatedAtstringRequired
When the pull request was last updated, as an ISO 8601 timestamp.
Example: "2026-05-28T13:35:16.268000+00:00"
PromptPullRequestList
One page of a prompt's pull requests, with the total across all pages.
class PromptPullRequestList:
pull_requests: List[PromptPullRequestSummary] = Field(alias="pullRequests")
total_pull_requests: int = Field(alias="totalPullRequests")
page: int
page_size: int = Field(alias="pageSize")pull_requestsList[PromptPullRequestSummary]Required
The prompt's pull requests for the current page, newest first.
total_pull_requestsintRequired
The total number of pull requests matching the filters, across every page.
Example: 4
pageintRequired
The page this response covers.
Example: 1
page_sizeintRequired
The number of pull requests per page.
Example: 25
interface PromptPullRequestList {
pullRequests: PromptPullRequestSummary[];
totalPullRequests: number;
page: number;
pageSize: number;
}pullRequestsPromptPullRequestSummary[]Required
The prompt's pull requests for the current page, newest first.
totalPullRequestsnumberRequired
The total number of pull requests matching the filters, across every page.
Example: 4
pagenumberRequired
The page this response covers.
Example: 1
pageSizenumberRequired
The number of pull requests per page.
Example: 25
PromptPullRequestRef
A reference to a prompt pull request by its id.
class PromptPullRequestRef:
id: stridstrRequired
The unique id of the pull request.
Example: "<PULL-REQUEST-ID>"
interface PromptPullRequestRef {
id: string;
}idstringRequired
The unique id of the pull request.
Example: "<PULL-REQUEST-ID>"
PromptPullRequestSummary
A pull request as it appears in the list of a prompt's pull requests. Retrieve it by id for its description and merge details.
class PromptPullRequestSummary:
id: str
title: str
status: PRStatus
source_branch_id: str = Field(alias="sourceBranchId")
target_branch_id: str = Field(alias="targetBranchId")
created_by: UserReference = Field(alias="createdBy")
created_at: str = Field(alias="createdAt")
merged_at: Optional[str] = Field(alias="mergedAt")idstrRequired
The unique id of the pull request.
Example: "<PULL-REQUEST-ID>"
titlestrRequired
The title of the pull request.
Example: "Tighten the support tone"
statusPRStatusRequired
See PRStatus.
source_branch_idstrRequired
The id of the branch whose changes are proposed.
Example: "<SOURCE-BRANCH-ID>"
target_branch_idstrRequired
The id of the branch the changes would be merged into.
Example: "<TARGET-BRANCH-ID>"
created_byUserReferenceRequired
The user who opened the pull request.
See UserReference.
created_atstrRequired
When the pull request was opened, as an ISO 8601 timestamp.
Example: "2026-05-28T13:05:24.777000+00:00"
merged_atOptional[str]Required
When the pull request was merged, as an ISO 8601 timestamp, or null while it has not been merged.
interface PromptPullRequestSummary {
id: string;
title: string;
status: PRStatus;
sourceBranchId: string;
targetBranchId: string;
createdBy: UserReference;
createdAt: string;
mergedAt: string | null;
}idstringRequired
The unique id of the pull request.
Example: "<PULL-REQUEST-ID>"
titlestringRequired
The title of the pull request.
Example: "Tighten the support tone"
statusPRStatusRequired
See PRStatus.
sourceBranchIdstringRequired
The id of the branch whose changes are proposed.
Example: "<SOURCE-BRANCH-ID>"
targetBranchIdstringRequired
The id of the branch the changes would be merged into.
Example: "<TARGET-BRANCH-ID>"
createdByUserReferenceRequired
The user who opened the pull request.
See UserReference.
createdAtstringRequired
When the pull request was opened, as an ISO 8601 timestamp.
Example: "2026-05-28T13:05:24.777000+00:00"
mergedAtstring | nullRequired
When the pull request was merged, as an ISO 8601 timestamp, or null while it has not been merged.
UserReference
A Confident AI user, as referenced by the records they created.
class UserReference:
id: str
email: str
name: Optional[str]
image: Optional[str]idstrRequired
This is the id of the user.
Example: "<USER-ID>"
emailstrRequired
This is the email address of the user.
Example: "jane@acme.com"
nameOptional[str]Required
This is the display name of the user, or null when they have not set one.
Example: "Jane Doe"
imageOptional[str]Required
This is the URL of the user's avatar, or null when they have none.
interface UserReference {
id: string;
email: string;
name: string | null;
image: string | null;
}idstringRequired
This is the id of the user.
Example: "<USER-ID>"
emailstringRequired
This is the email address of the user.
Example: "jane@acme.com"
namestring | nullRequired
This is the display name of the user, or null when they have not set one.
Example: "Jane Doe"
imagestring | nullRequired
This is the URL of the user's avatar, or null when they have none.
Last updated on