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

# Link Session प्राप्त करें

> जाँचें कि कोई सोशल-लिंकिंग URL खोला गया है, अब भी वैध है, या रद्द किया जा चुका है।

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="/docs/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="/docs/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="/docs/apis/overview#profile-key-format">Profile Key</a> of a User Profile.
          <br />
          <br />
          Format: <code>Profile-Key: PROFILE_KEY</code>
        </ParamField>)}
  </>;

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

[Link Session बनाएँ](/docs/apis/profiles/create-link-session) से बनाए गए किसी लिंकिंग URL की
स्थिति जाँचें — आपके उपयोगकर्ता ने उसे खोला या नहीं, वह अब भी वैध है या नहीं, और उसका कितनी
बार उपयोग हुआ है।

यह तब उपयोगी है जब आप उपयोगकर्ता से पूछे बिना जानना चाहते हैं कि उन्होंने अपने अकाउंट कनेक्ट
करना शुरू किया या नहीं, या नया लिंक बनाने से पहले पुष्टि करना चाहते हैं कि कोई लिंक निष्क्रिय
हो चुका है।

<Note>
  ऐसा `sessionId` जो मौजूद नहीं है, या जो किसी अन्य अकाउंट का है, वही `not found` प्रतिक्रिया
  लौटाता है। यह जानबूझकर है, ताकि इस एंडपॉइंट का उपयोग यह पता लगाने के लिए न किया जा सके कि
  कोई identifier वास्तविक है या नहीं।
</Note>

## हेडर पैरामीटर

<HeaderAPI profileKeyRequired={true} />

## पाथ पैरामीटर

<ParamField path="sessionId" type="string" required>
  लिंक बनाए जाने पर लौटाया गया `sessionId`।
</ParamField>

## लिंक की स्थितियाँ

`state` फ़ील्ड इनमें से एक होती है:

* `pending`: बनाया गया, कभी खोला नहीं गया।
* `active`: कम से कम एक बार खोला गया, अब भी अपनी अवधि के भीतर।
* `expired`: `expiresAt` बीत चुका।
* `revoked`: [Link Session रद्द करें](/docs/apis/profiles/revoke-link-session) से निष्क्रिय किया गया।

रद्द किया गया लिंक अपनी अवधि बीत जाने के बाद भी `revoked` ही रिपोर्ट करता है, क्योंकि वही
अधिक उपयोगी उत्तर है।

## कनेक्टेड अकाउंट

जब आपका उपयोगकर्ता कोई अकाउंट कनेक्ट करता है, तो लिंक उसे दर्ज कर लेता है। कुछ कनेक्ट हो जाने
के बाद तीन फ़ील्ड दिखाई देती हैं, और तब तक अनुपस्थित रहती हैं:

* `completedAt`: पहला अकाउंट कब कनेक्ट हुआ।
* `lastCompletedAt`: सबसे हालिया कब हुआ।
* `completedNetworks`: इस लिंक पर कनेक्ट हुआ हर नेटवर्क।

ये `state` से अलग हैं, और दोनों वास्तविक सवालों के जवाब देते हैं: कोई लिंक `active` हो सकता है और
अभी कुछ भी कनेक्ट न किया हो, या `expired` हो और समाप्त होने से पहले तीन अकाउंट कनेक्ट कर चुका
हो। `completedNetworks` के लिए poll करना ही वह तरीक़ा है जिससे कोई server-rendered ऐप या मोबाइल
ऐप जानता है कि कनेक्शन पूरा हुआ, और Telegram के लिए यही एकमात्र संकेत है, जो out of band पूरा
होता है।

<Warning>
  **`completedNetworks` इस लिंक सेशन का इतिहास है, प्रोफ़ाइल की वर्तमान स्थिति नहीं।** यह
  append-only है: कोई नेटवर्क इस सेशन के माध्यम से कनेक्ट होने पर जोड़ा जाता है और कभी हटाया नहीं
  जाता, इसलिए अकाउंट के अनलिंक होने, किसी अन्य सेशन से फिर से लिंक होने, या नेटवर्क की तरफ़ से
  डिस्कनेक्ट होने के बाद भी वह सूचीबद्ध रहता है। यह देखने के लिए कि **अभी** User Profile से कौन से
  नेटवर्क लिंक हैं, `include=state` के साथ
  [User Profiles प्राप्त करें](/docs/apis/profiles/get-profiles) को कॉल करें।
</Warning>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -H 'Profile-Key: PROFILE_KEY' \
  -X GET https://api.ayrshare.com/api/profiles/link-sessions/SESSION_ID
  ```

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

  fetch(`https://api.ayrshare.com/api/profiles/link-sessions/${SESSION_ID}`, {
    headers: {
      Authorization: `Bearer ${API_KEY}`,
      "Profile-Key": PROFILE_KEY,
    },
  })
    .then((res) => res.json())
    .then((json) => console.log(json))
    .catch(console.error);
  ```

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

  headers = {'Authorization': 'Bearer API_KEY',
          'Profile-Key': 'PROFILE_KEY'}

  response = requests.get(
      'https://api.ayrshare.com/api/profiles/link-sessions/SESSION_ID',
      headers=headers)
  print(response.json())
  ```

  ```php PHP theme={"system"}
  <?php
  require 'vendor/autoload.php';    // Composer auto-loader using Guzzle. See .../guzzlephp.org/en/stable/overview.html

  $client = new GuzzleHttp\Client();
  $res = $client->request(
      'GET',
      'https://api.ayrshare.com/api/profiles/link-sessions/SESSION_ID',
      [
          'headers' => [
              'Authorization' => 'Bearer API_KEY',
              'Profile-Key'   => 'PROFILE_KEY'
          ]
      ]
  );

  echo json_encode(json_decode($res->getBody()), JSON_PRETTY_PRINT);
  ```

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

  namespace GetLinkSession_csharp
  {
    class GetLinkSession
    {
        static async Task Main(string[] args)
        {
            string API_KEY = "API_KEY";
            string PROFILE_KEY = "PROFILE_KEY";
            string url = "https://api.ayrshare.com/api/profiles/link-sessions/SESSION_ID";

            try
            {
                using (var client = new HttpClient())
                {
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + API_KEY);
                    client.DefaultRequestHeaders.Add("Profile-Key", PROFILE_KEY);

                    HttpResponseMessage response = await client.GetAsync(url);
                    response.EnsureSuccessStatusCode();

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

<ResponseExample>
  ```json 200: Opened Once, Still Valid theme={"system"}
  {
      "status": "success",
      "sessionId": "c7a2434e72e91bde27579efde0fd6dd0b74ceee29a471fd368407f273708c2e8",
      "state": "active",  // pending | active | expired | revoked - see Link States above.
      "createdAt": "2026-09-01T08:03:26.838Z",  // When the link was created, as an ISO 8601 timestamp.
      "expiresAt": "2026-09-02T08:03:26.838Z",  // When the link stops working.
      "firstUsedAt": "2026-09-01T08:14:02.104Z",  // When the link was first opened. Absent if it never has been.
      "lastUsedAt": "2026-09-01T08:14:02.104Z",  // When the link was most recently opened. Absent if it never has been.
      "useCount": 1,  // How many times the link has been opened. A reload or an OAuth retry increments this.
      "completedAt": "2026-09-01T08:15:44.870Z",  // When the first account was connected. Absent until one is.
      "lastCompletedAt": "2026-09-01T08:16:20.412Z",  // When the most recent was connected. Absent until one is.
      "completedNetworks": ["reddit", "bluesky"]  // Every network connected on this link, append-only. Absent until one is.
  }
  ```

  ```json 200: Created, Never Opened theme={"system"}
  {
      "status": "success",
      "sessionId": "c7a2434e72e91bde27579efde0fd6dd0b74ceee29a471fd368407f273708c2e8",
      "state": "pending",  // Created but never opened, so firstUsedAt and lastUsedAt are absent.
      "createdAt": "2026-09-01T08:03:26.838Z",
      "expiresAt": "2026-09-02T08:03:26.838Z",
      "useCount": 0
  }
  ```

  ```json 404: Not Found theme={"system"}
  {
    "action": "link session",
    "status": "error",
    "code": 502,
    "message": "Social linking session not found. Please request a new linking URL."
  }
  ```
</ResponseExample>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.