> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 删除评论

> 删除单条评论或删除某条帖子下的所有评论

export const XByoNotice = () => <Info>
  <strong>Targeting X/Twitter?</strong> Starting March 31, 2026, all X operations require your own API credentials. After linking X via OAuth, include these 2 headers in your request:
  <br /><br />
  <code>X-Twitter-OAuth1-Api-Key</code> — Your API Key (Consumer Key)<br />
  <code>X-Twitter-OAuth1-Api-Secret</code> — Your API Key Secret (Consumer Secret)
  <br /><br />
  <strong>One-time setup per Ayrshare account.</strong> You create one X Developer App and reuse the same API Key and Secret across every sub-profile / end-user you link. You do <em>not</em> create a new app per customer.
  <br /><br />
  Not linked yet? See the <a href="/dashboard/connect-social-accounts/x-twitter-byo-keys">full setup guide</a> to connect your X account.
  <br /><br />
  Your keys are never logged or stored by Ayrshare.
</Info>;

export const HeaderAPI = ({noProfileKey, profileKeyRequired}) => <>
    <ParamField header="Authorization" type="string" required>
      <a href="/apis/overview#authorization">API Key</a> of the Primary Profile.
      <br />
      <br />
      Format: <code>Authorization: Bearer API_KEY</code>
    </ParamField>
    {!noProfileKey && (profileKeyRequired ? <ParamField header="Profile-Key" type="string" required>
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField> : <ParamField header="Profile-Key" type="string">
          <a href="/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

export const PlansAvailable = ({plans = [], maxPackRequired}) => {
  let displayPlans = plans;
  if (plans && plans.length === 1) {
    const lowerCasePlan = plans[0].toLowerCase();
    if (lowerCasePlan === "business") {
      displayPlans = ["Launch", "Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "Launch", "Business", "Enterprise"];
    }
  }
  return <Note>
Available on {displayPlans.length === 1 ? "the " : ""}
{displayPlans.join(", ").replace(/\b\w/g, l => l.toUpperCase())}{" "}
{displayPlans.length > 1 ? "plans" : "plan"}.

{maxPackRequired && <span onClick={() => window.open('https://www.ayrshare.com/docs/additional/maxpack', '_self')} className="flex items-center mt-2 cursor-pointer">
 <span className="px-1.5 py-0.5 rounded text-sm" style={{
    backgroundColor: '#C264B6',
    color: 'white',
    fontSize: '12px'
  }}>
   Max Pack required
 </span>
</span>}
</Note>;
};

<PlansAvailable plans={["premium"]} maxPackRequired={false} />

<XByoNotice />

删除端点允许你删除通过 Ayrshare 发送的评论，或删除在 Ayrshare 外部发送的评论。

有关不同 ID 类型的更多信息，请参见[评论概述](/apis/comments/overview)。

### 删除通过 Ayrshare 发送的评论

删除通过 Ayrshare 发送的单条评论，或删除某条帖子下的所有评论。
更多信息请参见 [Ayrshare 帖子 ID](/apis/comments/overview#comments-with-ayrshare-post-id) 和 [Ayrshare 评论 ID](/apis/comments/overview#comments-with-ayrshare-comment-id)。

支持的平台：Bluesky、Facebook、Instagram、LinkedIn、Reddit、TikTok、X/Twitter 和 YouTube。

### 删除在 Ayrshare 外部发送的评论

通过使用特定社交网络返回的 `commentId` 来删除并非通过 Ayrshare 发送的评论。
这是社交网络的[社交评论 ID](/apis/comments/overview#comments-with-social-comment-id)，而不是 Ayrshare 的 ID。

支持的平台：Facebook、Instagram、TikTok、X/Twitter 和 YouTube。

<Note>
  **TikTok — 仅限自己发表的评论。** 在 TikTok 上，`DELETE /comments` 仅在评论由已认证的 TikTok 账户自身撰写时才会成功（例如你通过 Ayrshare 的[回复端点](/apis/comments/reply-to-comment)或直接在 TikTok 应用中发布的回复）。尝试删除其他用户撰写的评论——即使是留在你自己视频下的评论——都会返回 Ayrshare `code: 328`。若需要在你自己的 TikTok 视频上审核第三方评论，请联系支持团队，以便我们确认你所关联账户类型可用的功能。
</Note>

例如，你可以使用[获取评论](/apis/comments/get-comments)端点（将 `searchPlatformId` 设置为 `true`）获取某个 Instagram 帖子下的所有评论。

```http theme={"system"}
GET https://api.ayrshare.com/api/comments/18231730279304111?platform=instagram&searchPlatformId=true
```

返回的 JSON 中每条评论都会包含一个 `commentId`，你可以用它来删除该评论。请记得将 `searchPlatformId` 设置为 `true`。

```json {5} theme={"system"}
{
  "instagram": [
    {
      "comment": "What an amazing comment",
      "commentId": "17969247335804735",
      "created": "2024-11-26T11:49:00Z",
      "from": {
        "id": "103038435208332",
        "username": "john_smith"
      },
      "hidden": false,
      "likeCount": 3,
      "platform": "instagram",
      "postId": "18231730279304333",
      "username": "john_smith"
    }
  ]
}
```

## 请求头参数

<HeaderAPI />

## 路径参数

<ParamField path="id" type="string" required>
  删除通过 Ayrshare 发送的评论：

  <ul className="custom-bullets">
    <li>提供 [Ayrshare 帖子 ID](/apis/comments/overview#comments-with-ayrshare-post-id) 可删除通过 Ayrshare 发送的所有评论。</li>
    <li>提供 [Ayrshare 评论 ID](/apis/comments/overview#comments-with-ayrshare-comment-id) 可删除单条评论。</li>
  </ul>

  删除在 Ayrshare 外部发送的评论：

  <ul className="custom-bullets">
    <li>
      提供社交网络的[社交评论 ID](/apis/comments/overview#comments-with-social-comment-id) 可删除单条评论。
    </li>

    <li>必须将 `searchPlatformId` 设置为 `true`。</li>
  </ul>
</ParamField>

## 请求体参数

<ParamField body="platforms" type="array">
  在删除通过 Ayrshare 发送的评论时必填。指定要删除评论的平台。

  支持的平台：`bluesky`、`facebook`、`instagram`、`linkedin`、`reddit`、`threads`、`tiktok`、`twitter`、`youtube`。

  ```json Deleting comments sent via Ayrshare theme={"system"}
  DELETE /comments/:id // Ayrshare Post ID or Ayrshare Comment ID
  {
    "platforms": ["bluesky", "facebook", "instagram", "linkedin", "reddit", "threads", "tiktok", "twitter", "youtube"]
  }
  ```
</ParamField>

<ParamField body="platform" type="string">
  当使用[社交评论 ID](/apis/comments/overview#comments-with-social-comment-id)（即社交网络返回的 `commentId`）进行删除时必填。

  支持的平台：`bluesky`、`facebook`、`instagram`、`threads`、`tiktok`、`twitter`、`youtube`。一次仅支持一个平台。
</ParamField>

<ParamField body="searchPlatformId" type="boolean" default={false}>
  当使用[社交评论 ID](/apis/comments/overview#comments-with-social-comment-id)（即社交网络返回的 `commentId`）进行删除时必填，设置为 `true`。

  ```json Deleting comments with Social Comment ID theme={"system"}
  DELETE /comments/:id // Social Comment ID
  {
    "searchPlatformId": true,
    // bluesky, facebook, instagram, threads, tiktok, twitter, youtube
    "platform": "facebook"
  }
  ```
</ParamField>

<ParamField body="hide" type="boolean" default={false}>
  仅限 TikTok。将此项与 `videoId` 一同设置为 `true`，可将某条 TikTok 评论对公众隐藏而不删除。成功响应会返回 `action: "hide"` 并回传该评论。发送 `hide=true` 但未提供 `videoId` 会返回 HTTP `400`。

  隐藏的评论对视频所有者在 TikTok Studio 中仍然可见。

  ```json Hiding a TikTok comment theme={"system"}
  DELETE /comments/:id // Social Comment ID
  {
    "searchPlatformId": true,
    "platform": "tiktok",
    "hide": true,
    "videoId": "7303719953248109358"
  }
  ```
</ParamField>

<ParamField body="videoId" type="string">
  隐藏 TikTok 评论时必填（`hide=true`）。该评论所属的 TikTok 视频 ID。
</ParamField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -X DELETE https://api.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ
  ```

  ```javascript JavaScript theme={"system"}
  const API_KEY = "API_KEY";

  fetch("https://api.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ", {
    method: "DELETE",
    headers: {
      Authorization: `Bearer ${API_KEY}`,
    },
  })
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch(console.error);
  ```

  ```python Python theme={"system"}
  import requests

  headers = {'Authorization': 'Bearer API_KEY'}

  r = requests.delete('https://api.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ', headers=headers)

  print(r.json())
  ```

  ```php PHP theme={"system"}
  <?php

  $apiUrl = 'https://api.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ'; // Replace with your post ID
  $apiKey = 'API_KEY';  // Replace 'API_KEY' with your actual API key

  $headers = [
      'Content-Type: application/json',
      'Authorization: Bearer ' . $apiKey,
  ];

  $curl = curl_init($apiUrl);
  curl_setopt_array($curl, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'DELETE',
      CURLOPT_HTTPHEADER => $headers
  ]);

  $response = curl_exec($curl);

  if ($response === false) {
      echo 'Curl error: ' . curl_error($curl);
  } else {
      echo json_encode(json_decode($response), JSON_PRETTY_PRINT);
  }

  curl_close($curl);

  ```

  ```csharp C# theme={"system"}
  using System;
  using System.Net.Http;
  using System.Threading.Tasks;

  namespace CommentsDELETERequest_csharp
  {
      class CommentsDELETE
      {
          private static readonly HttpClient client = new HttpClient();

          static async Task Main(string[] args)
          {
              string API_KEY = "API_KEY";
              string url = "https://api.ayrshare.com/api/comments/Ut1fWU6XkqkMayHGnJZ";

              client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);

              try
              {
                  HttpResponseMessage response = await client.DeleteAsync(url);
                  response.EnsureSuccessStatusCode();
                  string responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine(responseBody);
              }
              catch (HttpRequestException e)
              {
                  Console.WriteLine($"Error: {e.Message}");
              }
          }
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Success Single Comment theme={"system"}
  {
    "status": "success",
    "bluesky": {
      "action": "delete",
      "status": "success",
      "id": "at://did:plc:d/app.bsky.feed.post/3lez", // Bluesky Social Comment ID
      "comment": "This is a comment"
    },
    "facebook": {
      "action": "delete",
      "status": "success",
      "id": "938010233_939392023", // Facebook Social Comment ID
      "comment": "This is a comment"
    },
    "instagram": {
      "action": "delete",
      "status": "success",
      "id": "18010439663043269",  // Instagram Social Comment ID
      "comment": "This is a comment"
    },
    "linkedin": {
      "action": "delete",
      "status": "success",
      "id": "7133271664032669696", // LinkedIn Social Comment ID
      "comment": "This is a comment"
    },
    "threads": {
      "action": "delete",
      "status": "success",
      "id": "18064102964006231"   // Threads Social Comment ID
    },
    "tiktok": {
      "action": "delete",
      "status": "success",
      "commentId": "7303719953248109358", // Deprecated December 1, 2023. Use the id field instead.
      "id": "7303719953248109358", // TikTok Social Comment ID
      "comment": "This is a comment"
    },
    "twitter": {
      "action": "delete",
      "status": "success",
      "id": "1633128546494459904", // Twitter Social Comment ID
      "comment": "This is a comment"
    },
    "youtube": {
      "action": "delete",
      "status": "success",
      "id": "Ugy2m5u-LS9M29Gn3hd4AaABAg", // YouTub Social Comment ID
      "comment": "This is a comment"
    }
  }
  ```

  ```json 200: Sucesss Multiple Comments theme={"system"}
  {
    "status": "success",
    "linkedin": [
      {
        "action": "delete",
        "status": "success",
        "id": "7090782997972410368", // LinkedIn Social Comment ID
        "comment": "This is a comment"
      },
      {
        "action": "delete",
        "status": "success",
        "id": "7090783025164103680", // LinkedIn Social Comment ID
        "comment": "This is a comment"
      }
    ],
    "twitter": [
      {
        "action": "delete",
        "posts": [
          {
            "action": "delete",
            "status": "success",
            "id": "1685017310942134272", // Twitter Social Comment ID
            "comment": "This is a comment"
          }
        ]
      },
      {
        "action": "delete",
        "posts": [
          {
            "action": "delete",
            "status": "success",
            "id": "1685017338184146946", // Twitter Social Comment ID
            "comment": "This is a comment"
          }
        ]
      }
    ],
    "facebook": [
      {
        "action": "delete",
        "status": "success",
        "id": "676770944469840_644047184361660", // Facebook Social Comment ID
        "comment": "This is a comment"
      },
      {
        "action": "delete",
        "status": "success",
        "id": "676770944469840_983782432932944", // Facebook Social Comment ID
        "comment": "This is a comment"
      }
    ]
  }
  ```

  ```json 200: Success Hide TikTok Comment theme={"system"}
  {
    "status": "success",
    "tiktok": {
      "action": "hide",
      "status": "success",
      "id": "7303719953248109358", // TikTok Social Comment ID
      "comment": "This is a comment"
    }
  }
  ```

  ```json 400: Comment id not found theme={"system"}
  {
    "action": "comments",
    "status": "error",
    "code": 219,
    "message": "Error getting comments. Please verify the comments are still available."
  }
  ```
</ResponseExample>
