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

# Cập nhật Tin nhắn

> Cập nhật trạng thái của cuộc trò chuyện

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={["business"]} maxPackRequired={false} />

Cập nhật trạng thái của một cuộc trò chuyện thành active hoặc archived. Bạn có thể muốn lưu trữ các cuộc trò chuyện nếu chúng không còn hoạt động hoặc không còn liên quan.

## Tham số Header

<HeaderAPI />

## **Tham số Path**

<ParamField path="platform" type="string" required>
  Nền tảng để cập nhật trạng thái: `facebook`, `instagram`, `twitter`
</ParamField>

<ParamField path="conversationId" type="string" required>
  ID của cuộc trò chuyện để thực hiện hành động.
</ParamField>

## Tham số Body

<ParamField body="status" type="string" required>
  Giá trị: `active` hoặc `archived`.
</ParamField>

<RequestExample>
  ```bash cURL theme={"system"}
  curl \
  -H "Authorization: Bearer API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"status": "archived"}' \
  -X PUT https://api.ayrshare.com/api/messages/instagram/aWdfZMTpIyzQw
  ```

  ```javascript JavaScript theme={"system"}
  const url = 'https://api.ayrshare.com/api/messages/instagram/aWdfZMTpIyzQw';
  const options = {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer API_KEY'
    },
    body: JSON.stringify({
      'status': 'archived'
    })
  };

  fetch(url, options)
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));
  ```

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

  url = 'https://api.ayrshare.com/api/messages/instagram/aWdfZMTpIyzQw'
  headers = {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer API_KEY'
  }
  data = {
      'status': 'archived'
  }

  response = requests.put(url, headers=headers, data=json.dumps(data))

  try:
      response.raise_for_status()
      data = response.json()
      print(data)
  except requests.exceptions.RequestException as e:
      print('Error:', e)
  ```

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

  $url = 'https://api.ayrshare.com/api/messages/instagram/aWdfZMTpIyzQw';
  $headers = [
      'Content-Type: application/json',
      'Authorization: Bearer API_KEY'
  ];
  $data = [
      'status' => 'archived'
  ];

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

  $response = curl_exec($ch);

  if (curl_errno($ch)) {
      echo 'Error: ' . curl_error($ch);
  } else {
      $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
      if ($httpCode >=
  ```

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

  class Program
  {
      static async Task Main(string[] args)
      {
          string url = "https://api.ayrshare.com/api/messages/instagram/aWdfZMTpIyzQw";
          var headers = new Dictionary<string, string>
          {
              {"Content-Type", "application/json"},
              {"Authorization", "Bearer API_KEY"}
          };
          var data = new Dictionary<string, string>
          {
              {"status", "archived"}
          };

          using (var client = new HttpClient())
          {
              var jsonData = JsonSerializer.Serialize(data);
              var content = new StringContent(jsonData, Encoding.UTF8, "application/json");

              foreach (var header in headers)
              {
                  client.DefaultRequestHeaders.Add(header.Key, header.Value);
              }

              var response = await client.PutAsync(url, content);

              try
              {
                  response.EnsureSuccessStatusCode();
                  string responseBody = await response.Content.ReadAsStringAsync();
                  var responseData = JsonSerializer.Deserialize<Dictionary<string, object>>(responseBody);
                  Console.WriteLine(JsonSerializer.Serialize(responseData, new JsonSerializerOptions { WriteIndented = true }));
              }
              catch (HttpRequestException e)
              {
                  Console.WriteLine($"Error: {e.Message}");
              }
          }
      }
  }
  ```

  ```java Java theme={"system"}
  import java.io.IOException;
  import java.net.URI;
  import java.net.http.HttpClient;
  import java.net.http.HttpRequest;
  import java.net.http.HttpResponse;
  import java.nio.charset.StandardCharsets;
  import java.util.HashMap;
  import java.util.Map;

  public class Main {
      public static void main(String[] args) {
          String url = "https://api.ayrshare.com/api/messages/instagram/aWdfZMTpIyzQw";
          Map<String, String> headers = new HashMap<>();
          headers.put("Content-Type", "application/json");
          headers.put("Authorization", "Bearer API_KEY");
          Map<String, String> data = new HashMap<>();
          data.put("status", "archived");

          HttpClient client = HttpClient.newHttpClient();
          HttpRequest request = HttpRequest.newBuilder()
                  .uri(URI.create(url))
                  .headers(headers.entrySet().stream()
                          .map(entry -> entry.getKey() + ": " + entry.getValue())
                          .toArray(String[]::new))
                  .PUT(HttpRequest.BodyPublishers.ofString(getJsonString(data)))
                  .build();

          try {
              HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
              if (response.statusCode() >= 400) {
                  System.out.println("Error: HTTP " + response.statusCode());
              } else {
                  System.out.println(response.body());
              }
          } catch (IOException | InterruptedException e) {
              System.out.println("Error: " + e.getMessage());
          }
      }

      private static String getJsonString(Map<String, String> data) {
          StringBuilder jsonBuilder = new StringBuilder();
          jsonBuilder.append("{");
          for (Map.Entry<String, String> entry : data.entrySet()) {
              jsonBuilder.append("\"").append(entry.getKey()).append("\":\"").append(entry.getValue()).append("\",");
          }
          if (jsonBuilder.length() > 1) {
              jsonBuilder.setLength(jsonBuilder.length() - 1);
          }
          jsonBuilder.append("}");
          return jsonBuilder.toString();
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200: Success theme={"system"}
  {
      "status": "success"
  }
  ```

  ```json 400: Missing Status theme={"system"}
  {
    "action": "request",
    "status": "error",
    "code": 101,
    "message": "Missing or incorrect parameters. Please verify with the docs. .../ayrshare.com/rest-api/endpoints"
  }
  ```
</ResponseExample>
