コンテンツにスキップ
commentor API
Esc
↑↓移動↵開く⌘Jプレビュー

文書を JSON で作る

構造化した初期データから文書を作る。project を指定すると、文書の ID はサーバーが作る。個人トークンでは、共有先に新しい行を含めるとき access の範囲も必要。

POST/api/reviews
Authorization
AuthorizationBearer token · headerrequired

本人用の個人トークン。発行時に選んだ範囲の操作を、本人の名義で行う。読み取りと本人のトークン操作は、範囲を問わず使える。

Request body
requiredapplication/json
reviewobjectrequired

新しい文書の初期データ。reviewId・source・access・structure を含める。

Show properties
reviewIdstring
titlestring
sourceobject
accessobject
Show properties
modestring
Allowed:linkrestricted
allowedUsersobject[]
Show properties
Array of object
emailstring<email>required
rolestringrequired
Allowed:editorviewer
structureobject
projectstring

案件コード。社外・クライアントは必須。指定すると文書の ID はサーバーが作るため、review.reviewId を送ると 400 invalid_request。

matches ^[A-Z0-9][A-Z0-9-]{0,31}$
Responses
201

作った。

reviewReview

文書とコメントの全体。ここに挙げた項目のほかにも、画面が使う項目が入る。

Show properties
reviewIdstring
titlestring
commentsRevisioninteger

コメントが書き換わるたびに 1 増える番号。書き込みで baseCommentsRevision として送る。

structureRevisioninteger
commentsComment[]
Show properties
Array of Comment
idstring
authorUser

書いた人。エージェント用トークンで書いたものは、トークンの持ち主の名義になる。

Show properties
idstring
providerstring
displayNamestring
categorystring

コメントの種類。note はメモ、revise は書き換えの提案、add は追記、delete は削除の提案、needs_review は確認、consult は相談。none は分類の無い旧いデータで、画面ではメモとして出す。

Allowed:notereviseadddeleteneeds_reviewconsultnone
statusstring

open は未解決、closed は解決済み。

Allowed:openclosed
bodystring
anchorobject

画面でコメントを表示する位置。書き込むときは anchor でなく Locator を送る。

threadThreadMessage[]
Show properties
Array of ThreadMessage
idstring
authorUser

書いた人。エージェント用トークンで書いたものは、トークンの持ち主の名義になる。

bodystring
createdTsstring<date-time>
statusEventsStatusEvent[]
Show properties
Array of StatusEvent
seqinteger
statusstring
Allowed:openclosed
byUser

書いた人。エージェント用トークンで書いたものは、トークンの持ち主の名義になる。

tsstring<date-time>
versionIdstring

コメントを付けた文書の版。

createdTsstring<date-time>
editedTsstring<date-time>
deletedTsstring<date-time>

削除されたコメントにだけ付く。画面には出ない。

aiReviewRunsRun[]
Show properties
Array of Run
idstring
kindstring
Allowed:ai_reviewvoice
statusstring
Allowed:runningcompletedfailedcancelled
titlestring
versionIdstring
commentIdsstring[]
summarystring
createdTsstring<date-time>
completedTsstring<date-time>
createdAtstring<date-time>
sourceobject

本文の出どころと版。

Show properties
versionsobject[]

版の一覧。古い順で、最後が最新の版。

Show properties
Array of object
versionIdstring
labelstring
createdAtinteger

版を作った時刻(UNIX 時間のミリ秒)。

sourceHashstring
_projectProjectLink

この文書に案件の結び付けがあるときだけ付く。

Show properties
codestringrequired
namestring | nullrequired
companystring | nullrequired
statusstringrequired
Allowed:activeinactive
inSnapshotbooleanrequired
rolestring | nullrequired

要求した本人の案件の役割。

Allowed:managereditorviewernull
400

初期データの形が違う。project を指定した要求に review.reviewId がある場合も 400 invalid_request。

errorstringrequired

エラーの種類を表す短いコード。対処を分けるときはこの値を見る。

statusintegerrequired

HTTP ステータスと同じ値。

currentRevisioninteger

409 comments revision conflict のとき、文書の今の commentsRevision。

latestVersionIdstring

409 stale_target_version のとき、文書の最新版の ID。

401

トークンが無いか、この文書を読む権限が無い。

errorstringrequired

エラーの種類を表す短いコード。対処を分けるときはこの値を見る。

statusintegerrequired

HTTP ステータスと同じ値。

currentRevisioninteger

409 comments revision conflict のとき、文書の今の commentsRevision。

latestVersionIdstring

409 stale_target_version のとき、文書の最新版の ID。

403

案件が必要(project_required)、案件で編集以上の役割が無い(project_role_required)、個人トークンの範囲が不足している(insufficient_scope)、または操作権限が無い(forbidden)。

errorstringrequired

エラーの種類を表す短いコード。対処を分けるときはこの値を見る。

statusintegerrequired

HTTP ステータスと同じ値。

currentRevisioninteger

409 comments revision conflict のとき、文書の今の commentsRevision。

latestVersionIdstring

409 stale_target_version のとき、文書の最新版の ID。

404

案件が見つからない(project_not_found)。

errorstringrequired

エラーの種類を表す短いコード。対処を分けるときはこの値を見る。

statusintegerrequired

HTTP ステータスと同じ値。

currentRevisioninteger

409 comments revision conflict のとき、文書の今の commentsRevision。

latestVersionIdstring

409 stale_target_version のとき、文書の最新版の ID。

409

案件が写しに無い(project_not_in_snapshot)か、配信前の結び付けが競合した(project_conflict)。

errorstringrequired

エラーの種類を表す短いコード。対処を分けるときはこの値を見る。

statusintegerrequired

HTTP ステータスと同じ値。

currentRevisioninteger

409 comments revision conflict のとき、文書の今の commentsRevision。

latestVersionIdstring

409 stale_target_version のとき、文書の最新版の ID。

Request
curl -X POST 'https://comment-review.fsmarketing.workers.dev/api/reviews' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
  "review": {
    "title": "料金ページの下書き",
    "access": {
      "mode": "restricted",
      "allowedUsers": []
    }
  },
  "project": "EX-AA"
}'
Response
{
  "review": {
    "reviewId": "string",
    "title": "string",
    "commentsRevision": 0,
    "structureRevision": 0,
    "comments": [
      {
        "id": "string",
        "author": {
          "id": "string",
          "provider": "string",
          "displayName": "string"
        },
        "category": "note",
        "status": "open",
        "body": "string",
        "anchor": {},
        "thread": [
          {
            "id": "string",
            "author": {
              "id": "string",
              "provider": "string",
              "displayName": "string"
            },
            "body": "string",
            "createdTs": "2019-08-24T14:15:22Z"
          }
        ],
        "statusEvents": [
          {
            "seq": 0,
            "status": "open",
            "by": {
              "id": "string",
              "provider": "string",
              "displayName": "string"
            },
            "ts": "2019-08-24T14:15:22Z"
          }
        ],
        "versionId": "string",
        "createdTs": "2019-08-24T14:15:22Z",
        "editedTs": "2019-08-24T14:15:22Z",
        "deletedTs": "2019-08-24T14:15:22Z"
      }
    ],
    "aiReviewRuns": [
      {
        "id": "string",
        "kind": "ai_review",
        "status": "running",
        "title": "string",
        "versionId": "string",
        "commentIds": [
          "string"
        ],
        "summary": "string",
        "createdTs": "2019-08-24T14:15:22Z",
        "completedTs": "2019-08-24T14:15:22Z"
      }
    ],
    "createdAt": "2019-08-24T14:15:22Z",
    "source": {
      "versions": [
        {
          "versionId": "string",
          "label": "string",
          "createdAt": 0,
          "sourceHash": "string"
        }
      ]
    },
    "_project": {
      "code": "EX-AA",
      "name": "string",
      "company": "string",
      "status": "active",
      "inSnapshot": true,
      "role": "manager"
    }
  }
}