> ## 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.

# Delete a Post

> Xóa một bài đăng bằng post ID

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 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>;
};

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>)}
  </>;

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

<XByoNotice />

Xóa một bài đăng bằng post ID được trả về từ endpoint [/post](/apis/post/post).
Bạn có thể xóa cả bài đăng đã xuất bản và bài đăng đã lên lịch, nhưng có một số khác biệt tùy theo `platform` mạng xã hội:

<ul class="custom-bullets">
  <li>Các bài đăng đã lên lịch có thể được xóa cho tất cả `platforms` mạng xã hội.</li>

  <li>
    Các bài đăng đã xuất bản có thể được xóa cho tất cả `platforms` mạng xã hội ngoại trừ
    Instagram và TikTok. Instagram và TikTok không hỗ trợ API
    cho việc xóa bài đăng đã xuất bản. Nếu bạn cần xóa một bài đăng đã xuất bản trên
    các nền tảng này, bạn phải làm thủ công thông qua các ứng dụng di động tương ứng.
  </li>

  <li>
    Facebook không cho phép xóa image stories qua API của họ (video stories
    có thể được xóa). Nếu bạn cần xóa một image story, vui lòng vào
    ứng dụng Facebook di động và thực hiện xóa thủ công.
  </li>
</ul>

<Info>
  Instagram và TikTok không hỗ trợ xóa qua API của họ. Vui lòng vào
  ứng dụng di động Instagram hoặc TikTok để xóa các bài đăng.

  Facebook không hỗ trợ xóa image story qua API. Vui lòng vào
  ứng dụng Facebook di động để xóa stories.
</Info>

## Tham số Header

<HeaderAPI noProfileKey={false} />

## Tham số Body

<ParamField path="id" type="string" required>
  Ayrshare Post ID của bài đăng cần xóa.

  Không bắt buộc nếu tham số `bulk` hoặc `deleteAllScheduled` được gửi.

  Nếu bài đăng đã được lên lịch và vẫn ở trạng thái `pending`, các bài đăng đã lên lịch sẽ bị xóa và không được gửi đến các mạng.

  Nếu bài đăng đã được gửi đến các mạng, bài đăng sẽ được xóa khỏi các mạng.
</ParamField>

<ParamField path="bulk" type="array">
  Mảng String các post Id để xóa hàng loạt.

  Bắt buộc nếu tham số `id` hoặc `deleteAllScheduled` không được gửi.
</ParamField>

<ParamField path="deleteAllScheduled" type="boolean" default={false}>
  Nếu là `true` sẽ xóa tất cả các bài đăng đã lên lịch vẫn ở trạng thái pending, tức là các bài đăng chưa được xuất bản lên các mạng, cho User Profile.

  Các tham số `id` hoặc `bulk` sẽ bị bỏ qua nếu đặt thành `true`.

  <Tip>
    Điều này sẽ xóa tất cả các bài đăng đã lên lịch, vì vậy hãy sử dụng cẩn thận.
  </Tip>
</ParamField>

<ParamField path="markManualDeleted" type="boolean" default={false}>
  Nếu là `true`, bài đăng sẽ được đánh dấu là đã xóa trong Ayrshare và Ayrshare sẽ không cố gắng xóa bài đăng tại các mạng.

  Một trường hợp sử dụng phổ biến là khi bài đăng đã bị xóa thủ công tại các mạng và bạn muốn đánh dấu nó là đã xóa trong Ayrshare.

  Trước khi đánh dấu bài đăng là đã xóa, vui lòng đảm bảo rằng bài đăng đã được xóa thủ công trên các mạng xã hội.
</ParamField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API Key" \
  -H 'Content-Type: application/json' \
  -d '{"id": "Post ID"}' \
  -X DELETE https://api.ayrshare.com/api/post
  ```

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

  fetch("https://api.ayrshare.com/api/post", {
        method: "DELETE",
        headers: {
          "Content-Type": "application/json",
          "Authorization": `Bearer ${API_KEY}`
        },
        body: JSON.stringify({ id }),
      })
        .then((res) => res.json())
        .then((json) => console.log(json))
        .catch(console.error);
  ```

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

  payload = {'id': 'Post ID'}
  headers = {'Content-Type': 'application/json',
          'Authorization': 'Bearer API_KEY'}

  r = requests.delete('https://api.ayrshare.com/api/post',
      json=payload,
      headers=headers)

  print(r.json())
  ```

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

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

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

  $data = json_encode(['id' => $postId]);

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

  $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.Text;
  using System.Threading.Tasks;

  namespace DeletePOSTRequest_csharp
  {
      class Delete
      {
          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/post";

              // Set up request headers
              client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);

              // Prepare JSON content
              string json = "{\"id\" : \"Post ID\"}";
              var content = new StringContent(json, Encoding.UTF8, "application/json");

              try
              {
                  // Create and send DELETE request with content
                  var request = new HttpRequestMessage
                  {
                      Method = HttpMethod.Delete,
                      RequestUri = new Uri(url),
                      Content = content
                  };

                  HttpResponseMessage response = await client.SendAsync(request);
                  response.EnsureSuccessStatusCode();

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

<ResponseExample>
  ```javascript 200: Success theme={"system"}
  {
      "twitter": {
          "action": "delete",
          "status": "success",
          "id": "1288900099663775749" // Twitter Social Post ID
      },
      "facebook": {
          "action": "delete",
          "status": "success",
          "id": "104920007983682_108683297607743" // Facebook Social PostID
      },
      "status": "success"
  }
  ```

  ```json 200: Success with markManualDeleted theme={"system"}
  {
    "status": "success",
    "id": "p8Ee6xDPx8PRxsjtDXf3" // Ayrshare Post ID
  }
  ```

  ```json 400: ID Not Found theme={"system"}
  {
    "action": "delete",
    "status": "error",
    "code": 114,
    "message": "Delete id not found.",
    "id": "IdpUOyihLEpIx0d0N9mI" // Ayrshare Post ID used for delete, comment, analytics, etc.
  }
  ```

  ```json 400: Post Already Deleted theme={"system"}
  {
    "action": "delete",
    "status": "error",
    "code": 383,
    "message": "The post is already deleted.",
    "id": "p8Ee6xDPx8PRxsjtDXf3" // Ayrshare Post ID
  }
  ```

  ```json 400: Mark Manual Deleted Error theme={"system"}
  {
    "action": "delete",
    "status": "error",
    "code": 382,
    "message": "The post was not manually deleted at the social network. By using the markManualDeleted option, you are responsible for deleting the post at the social network. Please delete the post and try again.",
    "id": "DD3fA2DC4qe2T48hSdgs",
    "markManualDeleted": true
  }
  ```
</ResponseExample>
