> For the complete documentation index, see [llms.txt](https://developer.casso.vn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.casso.vn/english-v2-new/casso-api/api/check-giao-dich-moi.md).

# API check giao dịch mới

### Trước khi bắt đầu

Một số lưu ý trước khi bắt đầu với các API liên quan tới webhook:

* Một tài khoản [Casso](https://my.casso.vn) đã liên kết một tài khoản ngân hàng. Để test với API này **hạn chế** sử dụng [tài khoản demo.](broken://pages/-McjWDNXLnazsGil8Lw0)
* Bạn cần có [API Key](/english-v2-new/casso-api/chung-thuc/tao-api-key-thu-cong.md) hoặc [Access token từ Oauth 2.0 của Casso](/english-v2-new/casso-api/chung-thuc/tich-hop-oauth2.md) để thiết lập ở trường Authorization HTTP Header.

## Đồng bộ giao dịch mới

<mark style="color:green;">`POST`</mark> `https://oauth.casso.vn/v2/sync`

Đồng bộ giao dịch mới tương ứng với số tài khoản của bạn trong business

#### Headers

| Name           | Type   | Description                                                               |
| -------------- | ------ | ------------------------------------------------------------------------- |
| Authentication | string | `Bearer <"access token từ Oauth2">` **hoặc** `Apikey <"API key của bạn">` |

#### Request Body

| Name          | Type   | Description                                                     |
| ------------- | ------ | --------------------------------------------------------------- |
| bank\_acc\_id | string | Số tài khoản ngân hàng của bạn liên kết trên hệ thống của Casso |

{% tabs %}
{% tab title="200 Sync successfully." %}
{% tabs %}
{% tab title="Đồng bộ giao dịch thành công" %}

```
{
    "error": 0,
    "message": "success",
    "data": null
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="401 Token sai hoặc hết hạn" %}

```
{
    "error": 401,
    "message": "Unauthorized Access",
    "data": null
}
```

{% endtab %}
{% endtabs %}

#### Ví dụ:&#x20;

{% tabs %}
{% tab title="CURL" %}

```javascript
curl --location --request POST 'https://oauth.casso.vn/v2/sync' \
--header 'Authorization: Bearer <"Access token nhận được từ OAuth 2.0 của Casso">' \
--header 'Content-Type: application/json' \
--data-raw '{
    "bank_acc_id": "Số tài khoản ngân hàng cần đồng bộ"
}'
```

{% endtab %}

{% tab title="PHP" %}

```php
$curl = curl_init();

$data = array(
  'bank_acc_id' => 'Số tài khoản ngân hàng cần đồng bộ',
);
$postdata = json_encode($data);

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://oauth.casso.vn/v2/sync",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => $postdata),
  CURLOPT_HTTPHEADER => array(
    "Authorization: Apikey <"API Key của bạn"> Hoặc Bearer <"access token từ OAuth2">",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);
```

{% endtab %}

{% tab title="JAVA" %}

```java
OkHttpClient client = new OkHttpClient();

RequestBody formBody = new FormBody.Builder()
  .add("bank_acc_id", "Số tài khoản ngân hàng cần đồng bộ")
  .build();

Request request = new Request.Builder()
  .url("https://oauth.casso.vn/v2/sync")
  .post(formBody)
  .addHeader("Content-Type", "application/json")
  .addHeader("Authorization", "Apikey <"API Key của bạn"> hoặc Bearer <"access token từ OAuth2">")
  .build();

Response response = client.newCall(request).execute();
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Sau khi bạn gọi API này, nếu hệ thống của Casso phát hiện có một hoặc nhiều giao dịch mới được đồng bộ thì ngay lúc đó hệ thống của Casso sẽ đẩy một Event chứa các giao dịch mới đó tới [Webhook của bạn đã thiết lập](/english-v2-new/casso-api/api/thiet-lap-webhook.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.casso.vn/english-v2-new/casso-api/api/check-giao-dich-moi.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
