# List account events and mark them seen

Every command on this page needs a [bearer token](/help/rest-api/reference/authentication/) and counts towards your [hourly limit](/help/rest-api/reference/rate-limits-and-errors/).

## List or search account events

**POST**`https://api.sirv.com/v2/account/events/search`

List all events triggered for account.

Request body (JSON)

| Field | Type | Required | Example | Description |
| --- | --- | --- | --- | --- |
| `module` | string | No | `fetching` | Only events from this part of Sirv, for example fetching. |
| `type` | string | No |  | Only events of this type. |
| `filename` | string | No | `/REST API Examples/aurora.jpg` | Only events about this file. |
| `level` | string | No | `error` | One of: `error`, `warn`, `info`. |
| `seen` | boolean | No | `false` | Filter seen/unseen events |

Example request

-   [Node.js](#tab-panel-0-0)
-   [Python](#tab-panel-0-1)
-   [cURL](#tab-panel-0-2)
-   [Java](#tab-panel-0-3)
-   [C#](#tab-panel-0-4)
-   [PHP](#tab-panel-0-5)
-   [Go](#tab-panel-0-6)
-   [Ruby](#tab-panel-0-7)
-   [Swift](#tab-panel-0-8)

```js
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/account/events/search', {
  method: 'POST',
  headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
  body: JSON.stringify({
    "module": "fetching"
  }),
});
console.log(res.status, await res.text());
```

```python
import requests

res = requests.post(
    'https://api.sirv.com/v2/account/events/search',
    headers={'authorization': 'Bearer BEARER_TOKEN', 'content-type': 'application/json'},
    json={
      "module": "fetching"
    },
)
print(res.status_code, res.text)
```

```bash
curl --request POST \
  --url 'https://api.sirv.com/v2/account/events/search' \
  --header 'authorization: Bearer BEARER_TOKEN' \
  --header 'content-type: application/json' \
  --data '{"module":"fetching"}'
```

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sirv.com/v2/account/events/search"))
    .header("authorization", "Bearer BEARER_TOKEN")
    .header("content-type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
        {
          "module": "fetching"
        }
        """))
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
```

```csharp
using System.Net.Http.Headers;

using var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.sirv.com/v2/account/events/search");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");
request.Content = new StringContent("""
{
  "module": "fetching"
}
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

```php
<?php
$ch = curl_init('https://api.sirv.com/v2/account/events/search');
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN', 'content-type: application/json'],
  CURLOPT_POSTFIELDS => json_encode([
    'module' => 'fetching'
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);
```

```go
package main

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

func main() {
  body := strings.NewReader(`{
    "module": "fetching"
  }`)
  req, _ := http.NewRequest("POST", "https://api.sirv.com/v2/account/events/search", body)
  req.Header.Set("authorization", "Bearer BEARER_TOKEN")
  req.Header.Set("content-type", "application/json")
  res, err := http.DefaultClient.Do(req)
  if err != nil {
    panic(err)
  }
  defer res.Body.Close()
  out, _ := io.ReadAll(res.Body)
  fmt.Println(res.Status, string(out))
}
```

```ruby
require 'net/http'

uri = URI('https://api.sirv.com/v2/account/events/search')
req = Net::HTTP::Post.new(uri)
req['authorization'] = 'Bearer BEARER_TOKEN'
req['content-type'] = 'application/json'
req.body = <<~'JSON'
  {
    "module": "fetching"
  }
JSON
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.code, res.body
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.sirv.com/v2/account/events/search")!)
request.httpMethod = "POST"
request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")
request.setValue("application/json", forHTTPHeaderField: "content-type")
request.httpBody = #"""
{
  "module": "fetching"
}
"""#.data(using: .utf8)
let (data, response) = try await URLSession.shared.data(for: request)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))
```

Example response

```json
[
  {
    "module": "fetching",
    "type": "http",
    "level": "error",
    "filename": "/REST API Examples/missing.jpg",
    "fetching": {
      "url": "https://demo.sirv.com/missing.jpg",
      "statusCode": 404,
      "maxFilesize": 2097152,
      "contentLength": "4140",
      "error": "Request not successful: expected status code 200 but got 404"
    },
    "initiator": {
      "type": "api",
      "remoteAddr": "176.105.166.4",
      "date": "2020-07-18T11:31:32.229Z"
    },
    "notify": true,
    "_seen": false,
    "_submitted": "2020-07-18T11:31:32.612Z",
    "_accountId": "sdulth0oi0t9zxpxqtxwkwvgipjgv6ud",
    "_id": "8fbb11a7dd77f7f64337e581ccbce2d62fc7cda0"
  }
]
```

## Mark account event(s) as seen

**POST**`https://api.sirv.com/v2/account/events/seen`

Add `seen` flag for specified account event(s).

Example request

-   [Node.js](#tab-panel-1-0)
-   [Python](#tab-panel-1-1)
-   [cURL](#tab-panel-1-2)
-   [Java](#tab-panel-1-3)
-   [C#](#tab-panel-1-4)
-   [PHP](#tab-panel-1-5)
-   [Go](#tab-panel-1-6)
-   [Ruby](#tab-panel-1-7)
-   [Swift](#tab-panel-1-8)

```js
// Your bearer token, from POST /v2/token, in the SIRV_TOKEN environment variable
const res = await fetch('https://api.sirv.com/v2/account/events/seen', {
  method: 'POST',
  headers: { authorization: `Bearer ${process.env.SIRV_TOKEN}`, 'content-type': 'application/json' },
  body: JSON.stringify([
    "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
    "199cf48046964f8567fe49e22107c4c5d27271e7"
  ]),
});
console.log(res.status, await res.text());
```

```python
import requests

res = requests.post(
    'https://api.sirv.com/v2/account/events/seen',
    headers={'authorization': 'Bearer BEARER_TOKEN', 'content-type': 'application/json'},
    json=[
      "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
      "199cf48046964f8567fe49e22107c4c5d27271e7"
    ],
)
print(res.status_code, res.text)
```

```bash
curl --request POST \
  --url 'https://api.sirv.com/v2/account/events/seen' \
  --header 'authorization: Bearer BEARER_TOKEN' \
  --header 'content-type: application/json' \
  --data '["f1f5d68ef232e5d27d10f28bcef836efbb7cdeba","199cf48046964f8567fe49e22107c4c5d27271e7"]'
```

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.sirv.com/v2/account/events/seen"))
    .header("authorization", "Bearer BEARER_TOKEN")
    .header("content-type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("""
        [
          "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
          "199cf48046964f8567fe49e22107c4c5d27271e7"
        ]
        """))
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode() + " " + response.body());
```

```csharp
using System.Net.Http.Headers;

using var client = new HttpClient();
var request = new HttpRequestMessage(new HttpMethod("POST"), "https://api.sirv.com/v2/account/events/seen");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "BEARER_TOKEN");
request.Content = new StringContent("""
[
  "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
  "199cf48046964f8567fe49e22107c4c5d27271e7"
]
""", System.Text.Encoding.UTF8, "application/json");
var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

```php
<?php
$ch = curl_init('https://api.sirv.com/v2/account/events/seen');
curl_setopt_array($ch, [
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_HTTPHEADER => ['authorization: Bearer BEARER_TOKEN', 'content-type: application/json'],
  CURLOPT_POSTFIELDS => json_encode([
    'f1f5d68ef232e5d27d10f28bcef836efbb7cdeba',
    '199cf48046964f8567fe49e22107c4c5d27271e7'
  ]),
  CURLOPT_RETURNTRANSFER => true,
]);
echo curl_exec($ch);
```

```go
package main

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

func main() {
  body := strings.NewReader(`[
    "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
    "199cf48046964f8567fe49e22107c4c5d27271e7"
  ]`)
  req, _ := http.NewRequest("POST", "https://api.sirv.com/v2/account/events/seen", body)
  req.Header.Set("authorization", "Bearer BEARER_TOKEN")
  req.Header.Set("content-type", "application/json")
  res, err := http.DefaultClient.Do(req)
  if err != nil {
    panic(err)
  }
  defer res.Body.Close()
  out, _ := io.ReadAll(res.Body)
  fmt.Println(res.Status, string(out))
}
```

```ruby
require 'net/http'

uri = URI('https://api.sirv.com/v2/account/events/seen')
req = Net::HTTP::Post.new(uri)
req['authorization'] = 'Bearer BEARER_TOKEN'
req['content-type'] = 'application/json'
req.body = <<~'JSON'
  [
    "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
    "199cf48046964f8567fe49e22107c4c5d27271e7"
  ]
JSON
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }
puts res.code, res.body
```

```swift
import Foundation

var request = URLRequest(url: URL(string: "https://api.sirv.com/v2/account/events/seen")!)
request.httpMethod = "POST"
request.setValue("Bearer BEARER_TOKEN", forHTTPHeaderField: "authorization")
request.setValue("application/json", forHTTPHeaderField: "content-type")
request.httpBody = #"""
[
  "f1f5d68ef232e5d27d10f28bcef836efbb7cdeba",
  "199cf48046964f8567fe49e22107c4c5d27271e7"
]
"""#.data(using: .utf8)
let (data, response) = try await URLSession.shared.data(for: request)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))
```

Response

HTTP 200 with an empty body when the command succeeds.
