> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.omicx.one/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.omicx.one/_mcp/server.

# Lịch sử gửi Webhook

POST https://api.omicx.one/webhooks/history/search
Content-Type: application/json

Các filter đều tuỳ chọn: `webhookId`, `events[]` (`"{TYPE}:{ACTION}"` hoặc chỉ `"{TYPE}"`, khớp kiểu OR), `success`, `from`/`to` (epoch millis), `page` (bắt đầu từ 1), `size` (tối đa 100). Body rỗng trả về các lượt gửi mới nhất. Các dòng có `type: "SYSTEM"` cùng action `UNBLOCKED_*`/`BLOCKED_*` là bản ghi audit của control-plane, không phải lượt gửi thật. **Scope yêu cầu:** `webhook:read`.

Reference: https://developers.omicx.one/integrations/webhooks/search-webhook-history

## Request

### Headers

- `X-Api-Key` (string, required)

### Body (application/json)

This endpoint expects a WebhookHistorySearchRequest.

- `webhookId` (string, optional, nullable)
- `events` (list of string, optional, nullable) — Khớp kiểu OR — `"{TYPE}:{ACTION}"` hoặc chỉ `"{TYPE}"`.
- `success` (boolean, optional, nullable)
- `from` (long, optional, nullable) — Epoch millis, giới hạn dưới.
- `to` (long, optional, nullable) — Epoch millis, giới hạn trên.
- `page` (integer, optional, default: 1)
- `size` (integer, optional, default: 20)

## Response

### 200

Trang bản ghi lịch sử gửi (request/response body đã che dữ liệu cá nhân).

- `data` (list of WebhookHistoryEntry, optional)
- `page` (integer, optional)
- `size` (integer, optional)

## Errors

### 400 Bad Request Error

Filter không hợp lệ (ví dụ giá trị `events` sai định dạng).

- `error` (ErrorResponseError, optional)

### 401 Unauthorized Error

Thiếu hoặc sai API key.

- `error` (ErrorResponseError, optional)

### 403 Forbidden Error

Thiếu scope `webhook:read`.

- `error` (ErrorResponseError, optional)

### 502 Bad Gateway Error

webhook-service tạm thời không khả dụng.

- `error` (ErrorResponseError, optional)

## Types

### WebhookHistoryEntry

- `id` (string, optional)
- `webhookId` (string, optional)
- `type` (string, optional) — `SYSTEM` cho bản ghi audit của control-plane (`UNBLOCKED_*`/`BLOCKED_*`); ngược lại là mã sự kiện thật (`AI_TTS`, `AI_STT`, ...).
- `event` (string, optional)
- `success` (boolean, optional)
- `httpStatus` (integer, optional, nullable)
- `requestBody` (map from string to any, optional, nullable) — Payload đã gửi đi (dữ liệu cá nhân đã được che).
- `responseBody` (string, optional, nullable) — Nội dung phản hồi từ endpoint đích (đã cắt bớt nếu quá dài).
- `attempt` (integer, optional) — Lần thử thứ mấy (tính cả các lần retry).
- `createdAt` (long, optional)

### ErrorResponseError

- `code` (string, optional) — Nhóm lỗi (dạng máy đọc được), ổn định theo từng HTTP status.
- `subCode` (string, optional) — Mã cụ thể, ổn định — dùng để phân nhánh xử lý / dịch i18n. Hãy xử lý logic dựa trên `subCode`, không dựa vào chuỗi `message`.
- `message` (string, optional) — Mô tả cho con người đọc (dùng để debug), không nên dịch trực tiếp.
- `timestamp` (datetime, optional)
- `path` (string, optional) — Đường dẫn request đầy đủ.
- `details` (list of ErrorResponseErrorDetailsItems, optional) — Chỉ xuất hiện khi `code` là `VALIDATION_ERROR` — danh sách lỗi theo từng trường.

### ErrorResponseErrorDetailsItems

## Examples

**Request**

```json
{
  "webhookId": "your-webhook-id",
  "events": [
    "AI_TTS:FAILED"
  ],
  "success": false,
  "page": 1,
  "size": 20
}
```

**Response**

```json
{
  "data": [
    {
      "id": "b1e2a3c4-d5e6-4f70-8a9b-0c1d2e3f4a5b",
      "webhookId": "your-webhook-id",
      "type": "AI_TTS",
      "event": "AI_TTS:COMPLETED",
      "success": true,
      "httpStatus": 200,
      "requestBody": {},
      "responseBody": "string",
      "attempt": 1,
      "createdAt": 1767225600000
    }
  ],
  "page": 1,
  "size": 1
}
```

**SDK Code**

```python Tìm các lượt gửi thất bại của 1 webhook
import requests

url = "https://api.omicx.one/webhooks/history/search"

payload = {
    "webhookId": "your-webhook-id",
    "events": ["AI_TTS:FAILED"],
    "success": False,
    "page": 1,
    "size": 20
}
headers = {
    "X-Api-Key": "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Tìm các lượt gửi thất bại của 1 webhook
const url = 'https://api.omicx.one/webhooks/history/search';
const options = {
  method: 'POST',
  headers: {
    'X-Api-Key': 'omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: '{"webhookId":"your-webhook-id","events":["AI_TTS:FAILED"],"success":false,"page":1,"size":20}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Tìm các lượt gửi thất bại của 1 webhook
package main

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

func main() {

	url := "https://api.omicx.one/webhooks/history/search"

	payload := strings.NewReader("{\n  \"webhookId\": \"your-webhook-id\",\n  \"events\": [\n    \"AI_TTS:FAILED\"\n  ],\n  \"success\": false,\n  \"page\": 1,\n  \"size\": 20\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Api-Key", "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Tìm các lượt gửi thất bại của 1 webhook
require 'uri'
require 'net/http'

url = URI("https://api.omicx.one/webhooks/history/search")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = 'omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"webhookId\": \"your-webhook-id\",\n  \"events\": [\n    \"AI_TTS:FAILED\"\n  ],\n  \"success\": false,\n  \"page\": 1,\n  \"size\": 20\n}"

response = http.request(request)
puts response.read_body
```

```java Tìm các lượt gửi thất bại của 1 webhook
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.omicx.one/webhooks/history/search")
  .header("X-Api-Key", "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
  .header("Content-Type", "application/json")
  .body("{\n  \"webhookId\": \"your-webhook-id\",\n  \"events\": [\n    \"AI_TTS:FAILED\"\n  ],\n  \"success\": false,\n  \"page\": 1,\n  \"size\": 20\n}")
  .asString();
```

```php Tìm các lượt gửi thất bại của 1 webhook
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.omicx.one/webhooks/history/search', [
  'body' => '{
  "webhookId": "your-webhook-id",
  "events": [
    "AI_TTS:FAILED"
  ],
  "success": false,
  "page": 1,
  "size": 20
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Api-Key' => 'omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  ],
]);

echo $response->getBody();
```

```csharp Tìm các lượt gửi thất bại của 1 webhook
using RestSharp;

var client = new RestClient("https://api.omicx.one/webhooks/history/search");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Api-Key", "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"webhookId\": \"your-webhook-id\",\n  \"events\": [\n    \"AI_TTS:FAILED\"\n  ],\n  \"success\": false,\n  \"page\": 1,\n  \"size\": 20\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Tìm các lượt gửi thất bại của 1 webhook
import Foundation

let headers = [
  "X-Api-Key": "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "Content-Type": "application/json"
]
let parameters = [
  "webhookId": "your-webhook-id",
  "events": ["AI_TTS:FAILED"],
  "success": false,
  "page": 1,
  "size": 20
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.omicx.one/webhooks/history/search")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```