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

# Post History by ID

> Get the history for a specific post

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 />
  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 === "basic") {
      displayPlans = ["Basic", "Premium", "Business", "Enterprise"];
    } else if (lowerCasePlan === "business") {
      displayPlans = ["Business", "Enterprise"];
    } else if (lowerCasePlan === "premium") {
      displayPlans = ["Premium", "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 />

Get the history for a specific post. Replace `:id` with the [Ayrshare Post ID](/apis/overview#ayrshare-post-ids) returned from [post](/apis/post/post).

## Header Parameters

<HeaderAPI />

## Path Parameters

<ParamField path="id" type="string" required>
  Ayrshare Post ID returned from /post
</ParamField>

## Query Parameters

<ParamField query="searchAllPosts" type="boolean" default={false}>
  Search all posts across all User Profiles for the post ID. Default: `false`
</ParamField>

<RequestExample>
  ```javascript cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -X GET https://api.ayrshare.com/api/history/TBEAAqAMMJoweA9wKHUl
  ```

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

  fetch("https://api.ayrshare.com/api/history/TBEAAqAMMJoweA9wKHUl", {
        method: "GET",
        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.get('https://api.ayrshare.com/api/history/TBEAAqAMMJoweA9wKHUl', headers=headers)

  print(r.json())
  ```

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

  $apiUrl = 'https://api.ayrshare.com/api/history/TBEAAqAMMJoweA9wKHUl'; // 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_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 HistoryGETByIDRequest_csharp
  {
      class HistoryGetById
      {
          static async Task Main(string[] args)
          {
              string API_KEY = "API_KEY";
              string url = "https://api.ayrshare.com/api/history/TBEAAqAMMJoweA9wKHUl";

              using (var client = new HttpClient())
              {
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
                  
                  try
                  {
                      var response = await client.GetStringAsync(url);
                      Console.WriteLine(response);
                  }
                  catch (HttpRequestException ex)
                  {
                      Console.WriteLine($"Error: {ex.Message}");
                  }
              }
          }
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
      "tier": "business",
      "status": "success",
      "mediaUrls": [
          "https://images.ayrshare.com/imgs/GhostBusters.jpg"
      ],
      "postIds": [
          {
              "platform": "facebook",
              "postUrl": "https://www.facebook.com/1105775157895689_361710168628052",
              "status": "success",
              "id": "105775157895689_361710168628052" // Facebook Social Post ID
          }
      ],
      "id": "TBEEAqAMMJoweA8wKHUp", // Ayrshare Post ID
      "errors": [],
      "platforms": [
          "facebook"
      ],
      "scheduleDate": {   // In a future release changed to "scheduleDate": "2020-11-05T12:21:29Z"
          "_seconds": 1604578889,
          "_nanoseconds": 211000000,
          "utc": "2020-11-05T12:21:29Z"
      },
      "createDate": {    // deprecated, use created
          "_seconds": 1653067506,
          "_nanoseconds": 179000000,
          "utc": "2022-05-20T17:25:06Z"
      },
      "created": "2022-05-20T17:25:06Z",
      "shortenLinks": true,
      "post": "Today is a great day",
      "notes": "Approved by John Smith", // reference notes set via /post
      "type": "scheduled"
  }
  ```

  ```json 400: Post not found theme={"system"}
  {
    "action": "history",
    "status": "error",
    "code": 221,
    "message": "History not found.",
    "id": "4W3f3RPr6QSrw8S5Yo8"
  }
  ```
</ResponseExample>
