Introducing Confident Voice: Watch the Launch Video Now

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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
pageOptional[int]The page of pull requests to return. Defaults to 1.
page_sizeOptional[int]The number of pull requests per page, at most 100. Defaults to 25.
statusOptional[PRStatus]Only return pull requests in this status. See PRStatus.
source_branch_idOptional[str]Only return pull requests opened from this branch id.
search_termOptional[str]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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
titlestrRequired. The title of the pull request.
descriptionOptional[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_idOptional[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_idOptional[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.

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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
pull_request_idstrRequired. 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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
pull_request_idstrRequired. The unique id of the pull request.
titlestrRequired. The title of the pull request.
descriptionOptional[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_idOptional[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_idOptional[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.

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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
pull_request_idstrRequired. 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

ParameterTypeDescription
prompt_idstrRequired. The unique id of the prompt.
pull_request_idstrRequired. 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"

OPEN · MERGED · CLOSED

PromptCommit

class PromptCommit:
    id: str
    hash: str
    message: str

idstrRequired

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"

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

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"

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.

See PromptPullRequestSummary.

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

PromptPullRequestRef

A reference to a prompt pull request by its id.

class PromptPullRequestRef:
    id: str

idstrRequired

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

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.

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.

Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI