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

# Tìm quy trình chăm sóc của khách hàng

POST https://api.omicx.one/customers/journey/workflow/search
Content-Type: application/json

**Scope yêu cầu:** `customer:read`. Agent cần quyền xem (`crm.customer` → view) và khách hàng phải nằm trong phạm vi xem của agent. Trả về `id` bản ghi — dùng cho [Cập nhật quy trình chăm sóc của khách hàng](/customers/interactions/update-customer-workflow) và [Gỡ quy trình chăm sóc khỏi khách hàng](/customers/interactions/remove-customer-workflow). Một khách hàng có thể chạy cùng một quy trình nhiều lần, mỗi lần là một bản ghi riêng. Bản ghi đã gỡ không bao giờ xuất hiện. Mặc định sắp xếp mới nhất trước.

Reference: https://developers.omicx.one/customers/interactions/search-customer-workflows

## Request

### Headers

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

### Body (application/json)

This endpoint expects a CustomerWorkflowSearchRequest.

- `customerId` (string, required)
- `workflowIds` (list of string, optional) — Chỉ giữ các quy trình này (xem `GET /workflows`).
- `statusIds` (list of string, optional) — Chỉ giữ bản ghi đang ở đúng các trạng thái này.
- `zones` (list of enum, optional) — `[MAIN_FLOW]` = chỉ lấy bản ghi đang mở (chưa đóng).
  - Allowed values: `MAIN_FLOW`, `SUCCESS`, `FAILED`, `CLOSED`
- `sort` (list of CustomerWorkflowSearchRequestSortItems, optional)
- `pagination` (CustomerWorkflowSearchRequestPagination, optional)

## Response

### 200

Một trang bản ghi quy trình chăm sóc của khách hàng.

- `items` (list of CustomerWorkflowRecord, optional)
- `page` (integer, optional)
- `size` (integer, optional)
- `totalItems` (long, optional)
- `totalPages` (integer, optional)

## Errors

### 400 Bad Request Error

`customerId` thiếu hoặc không đúng định dạng 11 ký tự · filter/sort/pagination không hợp lệ.

- `error` (ErrorResponseError, optional)

### 401 Unauthorized Error

`API_KEY_REQUIRED` hoặc `API_KEY_INVALID`.

- `error` (ErrorResponseError, optional)

### 403 Forbidden Error

`INSUFFICIENT_SCOPE` · `API_KEY_PRINCIPAL_REQUIRED` · `API_KEY_PRINCIPAL_NOT_ELIGIBLE` · `FEATURE_ACCESS_DENIED` · `CUSTOMER_ACCESS_DENIED` — cùng ý nghĩa như `POST /customers/search`.

- `error` (ErrorResponseError, optional)

### 404 Not Found Error

Không tìm thấy khách hàng.

- `error` (ErrorResponseError, optional)

### 429 Too Many Requests Error

`RATE_LIMIT_EXCEEDED`.

- `error` (ErrorResponseError, optional)

### 502 Bad Gateway Error

`CUSTOMER_SERVICE_UNAVAILABLE` — customer-service timeout/lỗi 5xx, kèm `Retry-After: 5`. Platform không tự động thử lại.

- `error` (ErrorResponseError, optional)

### 503 Service Unavailable Error

Không xác thực được quyền hạn, hệ thống từ chối theo hướng an toàn (fail closed).

- `error` (ErrorResponseError, optional)

## Types

### CustomerWorkflowSearchRequestSortItems

- `field` (enum, optional)
  - Allowed values: `createdAt`, `lastModifiedAt`, `statusChangedAt`, `startAt`, `dueAt`, `priority`, `title`
- `direction` (enum, optional)
  - Allowed values: `ASC`, `DESC`

### CustomerWorkflowSearchRequestPagination

- `page` (integer, optional, default: 1)
- `size` (integer, optional, default: 20)

### CustomerWorkflowRecord

- `id` (string, optional) — id bản ghi — dùng cho `update`/`remove`.
- `customerId` (string, optional)
- `workflowId` (string, optional)
- `statusId` (string, optional)
- `zone` (enum, optional)
  - Allowed values: `MAIN_FLOW`, `SUCCESS`, `FAILED`, `CLOSED`
- `title` (string, optional, nullable)
- `note` (string, optional, nullable)
- `priority` (string, optional, nullable)
- `joinedAt` (long, optional)
- `statusChangedAt` (long, optional)
- `startAt` (long, optional, nullable)
- `dueAt` (long, optional, nullable)
- `overdue` (boolean, optional)
- `createdAt` (long, optional)
- `lastModifiedAt` (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, nullable) — 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` (long, optional) — Epoch millis.
- `path` (string, optional) — Đường dẫn request đầy đủ.
- `traceId` (string, optional, nullable) — Mã tương quan request, có khi lỗi đi qua bộ xử lý lỗi chung.
- `details` (list of ErrorResponseErrorDetailsItems, optional, nullable) — Chỉ xuất hiện khi `code` là `VALIDATION_ERROR` — danh sách lỗi theo từng trường.

### ErrorResponseErrorDetailsItems

- `field` (string, optional)
- `message` (string, optional)
- `rejectedValue` (any, optional, nullable)

## Examples

**Request**

```json
{
  "customerId": "your-customer-id",
  "workflowIds": [
    "wf-1"
  ]
}
```

**Response**

```json
{
  "items": [
    {
      "id": "string",
      "customerId": "string",
      "workflowId": "string",
      "statusId": "string",
      "zone": "MAIN_FLOW",
      "title": "string",
      "note": "string",
      "priority": "string",
      "joinedAt": 1,
      "statusChangedAt": 1,
      "startAt": 1,
      "dueAt": 1,
      "overdue": true,
      "createdAt": 1,
      "lastModifiedAt": 1
    }
  ],
  "page": 1,
  "size": 1,
  "totalItems": 1,
  "totalPages": 1
}
```

**SDK Code**

```python Lọc theo 1 quy trình cụ thể
import requests

url = "https://api.omicx.one/customers/journey/workflow/search"

payload = {
    "customerId": "your-customer-id",
    "workflowIds": ["wf-1"]
}
headers = {
    "X-Api-Key": "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Lọc theo 1 quy trình cụ thể
const url = 'https://api.omicx.one/customers/journey/workflow/search';
const options = {
  method: 'POST',
  headers: {
    'X-Api-Key': 'omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: '{"customerId":"your-customer-id","workflowIds":["wf-1"]}'
};

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

```go Lọc theo 1 quy trình cụ thể
package main

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

func main() {

	url := "https://api.omicx.one/customers/journey/workflow/search"

	payload := strings.NewReader("{\n  \"customerId\": \"your-customer-id\",\n  \"workflowIds\": [\n    \"wf-1\"\n  ]\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 Lọc theo 1 quy trình cụ thể
require 'uri'
require 'net/http'

url = URI("https://api.omicx.one/customers/journey/workflow/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  \"customerId\": \"your-customer-id\",\n  \"workflowIds\": [\n    \"wf-1\"\n  ]\n}"

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

```java Lọc theo 1 quy trình cụ thể
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.omicx.one/customers/journey/workflow/search")
  .header("X-Api-Key", "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
  .header("Content-Type", "application/json")
  .body("{\n  \"customerId\": \"your-customer-id\",\n  \"workflowIds\": [\n    \"wf-1\"\n  ]\n}")
  .asString();
```

```php Lọc theo 1 quy trình cụ thể
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.omicx.one/customers/journey/workflow/search', [
  'body' => '{
  "customerId": "your-customer-id",
  "workflowIds": [
    "wf-1"
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Api-Key' => 'omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  ],
]);

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

```csharp Lọc theo 1 quy trình cụ thể
using RestSharp;

var client = new RestClient("https://api.omicx.one/customers/journey/workflow/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  \"customerId\": \"your-customer-id\",\n  \"workflowIds\": [\n    \"wf-1\"\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Lọc theo 1 quy trình cụ thể
import Foundation

let headers = [
  "X-Api-Key": "omx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "Content-Type": "application/json"
]
let parameters = [
  "customerId": "your-customer-id",
  "workflowIds": ["wf-1"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.omicx.one/customers/journey/workflow/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()
```