git.pulls.convert-to-draft

Turn an open pull request back into a draft (fires converted_to_draft: webhooks and the workflows that list it)

POST /git/api/repositories/{repoId}/pulls/{prNumber}/draftIAM git:UpdatePullRequestChanges stateDestructive

Request syntax

POST /git/api/repositories/{repoId}/pulls/{prNumber}/draft

Path parameters

  • repoIdRequired

    string

    Constraints: uuid

  • prNumberRequired

    number

    Constraints: integer, min 1

Response

200 with the pull request, now `state: draft` and `isDraft: true`. One that is already a draft is answered 200 unchanged, and nothing fires. 409 when it is closed or merged, in an archived repository, or in a mirror (review it at the source).

A JSON response is wrapped as { "success": true, "data": … }; the CLI prints the whole body with --json.

Fields of data

  • idAlways

    string

    The pull request id
  • orgIdAlways

    string

    The organization that owns it
  • repoIdAlways

    string

    The repository it belongs to
  • numberAlways

    number

    Its number in the repository, as in #12
  • titleAlways

    string

    The title
  • bodyAlways

    string, may be null

    The description (Markdown); null when there is none
  • stateAlways

    one of open, closed, merged, draft

    open, draft, closed (without merging) or merged
  • sourceBranchAlways

    string

    The branch with the changes
  • targetBranchAlways

    string

    The branch it merges into
  • sourceOidAlways

    string, may be null

    Head commit of the source branch when mergeability was last computed
  • targetOidAlways

    string, may be null

    Tip of the target branch when mergeability was last computed
  • mergeStatusAlways

    one of unknown, mergeable, conflicted, up_to_date

    Whether it merges cleanly: mergeable, conflicted, up_to_date (nothing to merge) or unknown
  • mergeConflictsAlways

    array of string, may be null

    The conflicting paths when conflicted; null when not known
  • mergeCommitOidAlways

    string, may be null

    The commit the merge produced; null until merged
  • authorIamUserIdAlways

    string

    The IAM user who opened it (for an imported one, who ran the import)
  • isDraftAlways

    boolean

    A draft, not yet ready for review
  • mergedAtAlways

    string, may be null

    When it was merged; null unless merged
  • closedAtAlways

    string, may be null

    When it was closed; null while open
  • externalAuthorAlways

    string, may be null

    For an imported pull request, who opened it at the source; null otherwise
  • externalUrlAlways

    string, may be null

    For an imported pull request, its address at the source; null otherwise
  • autoMergeMethodAlways

    one of merge, squash, rebase, may be null

    The method auto-merge will use; null when auto-merge is off
  • autoMergeIamUserIdAlways

    string, may be null

    Who turned auto-merge on, and as whom it merges; null when off
  • autoMergeEnabledAtAlways

    string, may be null

    When auto-merge was turned on; null when off
  • autoMergeBlockedReasonAlways

    string, may be null

    Why the last auto-merge attempt did not merge; null when nothing blocks it
  • createdAtAlways

    string

    When it was opened
  • updatedAtAlways

    string

    When it last changed

Checked against the handlers: every route test validates their answers against this schema.

Errors

  • 400The request does not pass the schema above. The body is { "error": …, "issues": […] }, one issue per field.
  • 401No credentials, or an access key that is unknown, revoked or expired.
  • 403The caller's policies do not allow git:UpdatePullRequest on this resource. The body names the action and the resource, and the refusal is recorded in the audit log.
  • 404The resource does not exist in your organization.

Examples

The required parameters only, with example values. Replace id and the other placeholders with your own.

dcloud git pulls convert-to-draft repoId prNumber

Generated from the API description, the same one the API checks requests against and the CLI is built from. MCP tool: dcloud_git_pulls_convert-to-draft.