You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过API密钥认证的Phabricator API编程分配用户审核Diff?

How to Programmatically Assign a Diff's Review Task via Phabricator API (Authenticated)

Alright, let's break down exactly how to assign a Diff's review to a specific user using Phabricator's Conduit API—assuming you already have a valid API key set up for authentication.

Step 1: Know the Core API Endpoint

Phabricator manages Diffs under Revisions, so we'll use the differential.revision.edit endpoint. This lets us modify revision properties, including adding or updating reviewers.

Step 2: Gather Required Identifiers

Before making the request, you need two key pieces of info:

  • The Revision ID (looks like D1234) or its PHID for the Diff you want to update.
  • The PHID of the target user (e.g., PHID-USER-abc123). If you don't have this, you can fetch it via the user.query API by passing the username:
    curl -X POST https://your-phab-instance.com/api/user.query \
      -d api.token=YOUR_API_KEY \
      -d constraints[usernames][0]=target_username
    

Step 3: Construct the API Request

Send a POST request to the differential.revision.edit endpoint with the following JSON payload. Here's a curl example you can adapt:

curl -X POST https://your-phab-instance.com/api/differential.revision.edit \
  -H "Content-Type: application/json" \
  -d '{
    "api.token": "YOUR_API_KEY",
    "objectIdentifier": "D1234", # Replace with your Revision ID/PHID
    "transactions": [
      {
        "type": "reviewers.add",
        "value": ["PHID-USER-abc123"] # Replace with target user PHID
      }
    ]
  }'

Key Transaction Details:

  • Use reviewers.add to append the user to the existing list of reviewers.
  • If you want to replace all existing reviewers with this user, swap reviewers.add for reviewers.set.
  • You can add multiple reviewers at once by including more PHIDs in the value array (e.g., ["PHID-USER-abc123", "PHID-USER-def456"]).

Step 4: Verify the Assignment Worked

To confirm the change took effect, query the revision details using differential.revision.query:

curl -X POST https://your-phab-instance.com/api/differential.revision.query \
  -d api.token=YOUR_API_KEY \
  -d constraints[ids][0]=1234 # Match the numeric part of your Revision ID (D1234 → 1234)

Check the reviewers field in the response to see if the target user is listed.

Critical Permissions Check

Make sure your API key is linked to a user account that has:

  • Permission to edit the target Revision.
  • Permission to add or modify reviewers for that Revision.

内容的提问来源于stack exchange,提问作者Will

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:48:15