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

# Mark as Read

> Mark a whole chat as read or unread on every device.

## Endpoint

POST `https://api.wapimax.com/whatsapp/v1/sessions/{session_id}/chats/{jid}/read`

## Authentication

Every request must include your API key in the `X-API-Key` header. See [Authorization](https://docs.wapimax.com/get-started/authorization.md) to create one.

| Header | Value | Required |
| - | - | - |
| `X-API-Key` | Your WapiMax API key | Yes |
| `Content-Type` | `application/json` | Yes |
| `Accept` | `application/json` | Recommended |

## Path parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `session_id` | string | Yes | ID of the session |
| `jid` | string | Yes | Phone number or group ID of the chat |

## Request body

| Parameter | Type | Required | Description |
| - | - | - | - |
| `read` | boolean | Yes | `true` marks the chat as read, `false` marks it unread |

### Chats

| Chat | `jid` format | Example |
| - | - | - |
| Contact | Phone number | `254712345678` |
| Group | Group ID | `120363012345678901@g.us` |

```json Read theme={null}
{
  "read": true
}
```

```json Unread theme={null}
{
  "read": false
}
```

## Request

```bash cURL theme={null}
curl -X POST "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "read": true
  }'
```

```javascript JavaScript theme={null}
const response = await fetch(
  "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read",
  {
    method: "POST",
    headers: {
      "X-API-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      read: true
    })
  }
);

const data = await response.json();
console.log(data);
```

```javascript Node.js theme={null}
const response = await fetch(
  "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read",
  {
    method: "POST",
    headers: {
      "X-API-Key": "YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      read: true
    })
  }
);

console.log(await response.json());
```

```php PHP theme={null}
<?php

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "X-API-Key: YOUR_API_KEY",
        "Content-Type: application/json",
        "Accept: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode([
        "read" => true
    ])
]);

$response = curl_exec($curl);
curl_close($curl);

echo $response;
```

```python Python theme={null}
import requests

url = "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read"

headers = {
    "X-API-Key": "YOUR_API_KEY",
    "Content-Type": "application/json"
}

payload = {
    "read": True
}

response = requests.post(url, headers=headers, json=payload)

print(response.json())
```

```java Java theme={null}
import java.net.URI;
import java.net.http.*;

public class Main {
    public static void main(String[] args) throws Exception {
        HttpClient client = HttpClient.newHttpClient();

        String body = """
            {
              "read": true
            }
            """;

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read"))
            .header("X-API-Key", "YOUR_API_KEY")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(body))
            .build();

        HttpResponse<String> response = client.send(
            request,
            HttpResponse.BodyHandlers.ofString()
        );

        System.out.println(response.body());
    }
}
```

```go Go theme={null}
package main

import (
    "bytes"
    "fmt"
    "io"
    "net/http"
)

func main() {
    body := []byte(`{
        "read": true
    }`)

    req, _ := http.NewRequest(
        "POST",
        "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read",
        bytes.NewBuffer(body),
    )

    req.Header.Set("X-API-Key", "YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    result, _ := io.ReadAll(resp.Body)
    fmt.Println(string(result))
}
```

```ruby Ruby theme={null}
require "net/http"
require "uri"
require "json"

uri = URI("https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read")

request = Net::HTTP::Post.new(uri)
request["X-API-Key"] = "YOUR_API_KEY"
request["Content-Type"] = "application/json"

request.body = {
  read: true
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body
```

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

class Program {
    static async Task Main() {
        using var client = new HttpClient();

        client.DefaultRequestHeaders.Add(
            "X-API-Key", "YOUR_API_KEY"
        );

        var json = """
        {
            "read": true
        }
        """;

        var content = new StringContent(
            json, Encoding.UTF8, "application/json"
        );

        var response = await client.PostAsync(
            "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read",
            content
        );

        Console.WriteLine(await response.Content.ReadAsStringAsync());
    }
}
```

```swift Swift theme={null}
import Foundation

let url = URL(string: "https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read")!

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("YOUR_API_KEY", forHTTPHeaderField: "X-API-Key")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

request.httpBody = try JSONSerialization.data(withJSONObject: [
    "read": true
])

let task = URLSession.shared.dataTask(with: request) { data, _, error in
    if let error = error {
        print(error)
        return
    }

    if let data = data {
        print(String(data: data, encoding: .utf8) ?? "")
    }
}

task.resume()
```

```kotlin Kotlin theme={null}
import okhttp3.*
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody.Companion.toRequestBody

fun main() {
    val client = OkHttpClient()

    val json = """
        {
          "read": true
        }
    """.trimIndent()

    val body = json.toRequestBody("application/json".toMediaType())

    val request = Request.Builder()
        .url("https://api.wapimax.com/whatsapp/v1/sessions/202610123/chats/254712345678/read")
        .addHeader("X-API-Key", "YOUR_API_KEY")
        .post(body)
        .build()

    client.newCall(request).execute().use {
        println(it.body?.string())
    }
}
```

## Response

Returns `200 OK` when the chat is marked as read or unread on every device.

## Errors

| Status | Description |
| - | - |
| `400` | Invalid request or missing required parameters |
| `401` | Missing or invalid API key |
| `403` | Access to this session is not permitted |
| `404` | Session not found |
| `429` | Plan usage quota exceeded or rate limit exceeded. |
| `503` | Session is not connected |

## Notes

* For contacts, send digits only with the country code. Do not add `+` or a WhatsApp suffix.
* For groups, the session must be a member of the group.
* Replace `{session_id}` with your session ID. Get it from [List Sessions](https://docs.wapimax.com/whatsapp/sessions/list-sessions.md).
* This applies to the whole chat, not a single message.


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