# Sapo

the Sapo node provides solutions for developers to synchronize product, order, customer, and transaction data... between Sapo and other systems; it allows you to set up most of the features from your applications on the CMS platform. Web app or third-party software compatible with Sapo's platform.. These solutions are suitable for both normal websites (websites of an individual or company) and e-commerce platforms with many stores.

On this page, you'll find a list of operations the Sapo node supports and links to more resources.

{% hint style="info" %}
**Authentication:** Refer to [Sapo API](https://support.sapo.vn/oauth) for guidance on setting up authentication about Sapo API.
{% endhint %}

## Basic Operations&#x20;

* Customer
  * Lấy về danh sách tất cả các Customer
  * Lấy về một Customer&#x20;
  * Tạo mới một Customer
  * Chỉnh sửa một Customer
  * Xóa một Customer khỏi cơ sở dữ liệu
  * Lấy về tổng số tất cả các Customer
  * Tìm kiếm đơn hàng của Customer
* Customer Address
  * Lấy ra danh sách tất cả các CustomerAddresses
  * Lấy ra một Customer Address
  * Tạo mới một CustomerAddress
  * Chỉnh sửa một CustomerAddress đã tồn tại
  * Xóa CustomerAddress khỏi cơ sở dữ liệu
  * Đặt địa chỉ mặc định cho khách hàng
* Customer Collection
  * Lấy về danh sách tất cả các CustomCollection
  * Lấy về tổng số các CustomCollection
  * Lấy về một CustomCollection
  * Tạo mới một CustomCollection
  * Chỉnh sửa một CustomCollection
  * Xóa một CustomCollection ra khỏi cơ sở dữ liệu
* Discount Code
  * Tạo mới một DiscountCode
  * Cập nhật một DiscountCode đã tồn tại
  * Lấy ra một danh sách mã khuyến mãi
  * Lấy ra một DiscountCode
  * Xóa một DiscountCode
* Event
  * Lấy danh sách Event
  * Lấy một Event
  * Lấy tổng số Event
* Fulfillment
  * Lấy danh sách tất cả các Fulfillment
  * Lấy tổng số Fulfillment
  * Lấy một Fulfillment
  * Tạo mới một Fulfillment
  * Cập nhật một Fulfillment
  * Hoàn thành một Fulfillment
  * Hủy một Fulfillment
* Metafield
  * Lấy toàn bộ Metafields trong Shop
  * Lấy toàn bộ Metafields của một sản phẩm
  * Lấy toàn bộ Metafields của ảnh sản phẩm
  * Lấy tổng số metafield của shop
  * Lấy tổng số metafield của một sản phẩm
  * Lấy một metafield bằng ID
  * Lấy một metafield của sản phẩm bằng ID
  * Tạo mới một metafield
  * Tạo mới một metafield cho một sản phẩm
  * Cập nhật metafield
  * Cập nhật một metafield của sản phẩm
  * Xóa một metafield
  * Xóa một metafield của sản phẩm
* Order
  * Lấy danh sách Order
  * Lấy một Order
  * Lấy tổng số Order
  * Lưu trữ một Order
  * Bỏ lưu trữ một Order
  * Hủy một Order
  * Tạo mới một Order
  * Cập nhật một Order
  * Xóa một Order khỏi cơ sở dữ liệu
* Product
  * Lấy danh sách tất cả Product
  * Lấy tổng số Product
  * Lấy một Product
  * Tạo mới một Product
  * Chỉnh sửa một Product
  * Xóa một Product khỏi cơ sở dữ liệu
* Product Variant
  * Lấy về danh sách các Product Variant
  * Lấy về tổng số các Prodcut Variant
  * Lấy về một Product Variant
  * Tạo mới một Product Variant
  * Chỉnh sửa một Product Variant
  * Xóa một Product Variant khỏi cơ sở dữ liệu
* Refund
  * Lấy một Refund
* SmartCollection
  * Lấy danh sách các SmartCollection
  * Lấy tổng số SmartCollection
  * Lấy một SmartCollection
  * Tạo mới một SmartCollection
  * Cập nhật một SmartCollection
  * Xóa một SmartCollection khỏi cơ sở dữ liệu
* Store
  * Lấy một Store
* Transaction
  * Lấy danh sách các Transaction
  * Lấy tổng số Transaction
  * Lấy một Transaction
  * Tạo mới một Transaction
* Carrier Service
  * Tạo mới một Carrier Service
  * Cập nhật một Carrier Service đã tồn tại
  * Lấy ra danh sách Carrier Service
  * Lấy ra một Carrier Service
  * Xóa một Carrier Service

## Example Usage

This workflow allows you can create a new product in your store. This example usage workflow would use the following nodes.&#x20;

If you use private apps authentication type. Your workflow is. - [Start](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.start/) – Sapo.

<figure><img src="/files/0uux6QaCOR8JGaeXRqyx" alt=""><figcaption><p>Workflow if user have an access token</p></figcaption></figure>

If you use OAuth authentication type. Your workflow is. - [Start](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.start/) – Sapo Authentication – Sapo.

<figure><img src="/files/ILTGMgjp7tiKSbEXn2Ws" alt=""><figcaption><p>Workflow if the user doesn't have an access token yet</p></figcaption></figure>

### 1. Start Node

&#x20; The start node exists by default when you create a new workflow.

### 2. Sapo Authentication

To use Sapo Authentication node, you must have partner account, if you don't have partner account yet, register at <https://developers.sapo.vn/services/partners/auth/register>.

Then you will log in to your partner account <https://developers.sapo.vn/services/partners/auth/login>

If you use **Private Apps,** see this guide <https://support.sapo.vn/ung-dung-rieng-private-apps>.

**note**: If you use **Private app** authentication type please skip this section and move to section *3. Sapo Node*

If you use **OAuth,** see the instructions below:

1. Click to open the [Apps list page in the Partner management screen](https://developers.sapo.vn/services/partners/api_clients)
2. Choose "Tạo ứng dụng"

<figure><img src="/files/kC5U4VDQOUFvw5kixGyu" alt=""><figcaption></figcaption></figure>

3. Create new app

Provide app information

<figure><img src="/files/HX9DMPN6PwgBANksEsnr" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/WxVHTXQUsr00hmNg10mP" alt=""><figcaption></figcaption></figure>

Click "Lưu" to save your app

<figure><img src="/files/4RIRHT3FUMlh6yi871F9" alt=""><figcaption></figcaption></figure>

After creating an app, the browser will redirect to a screen displaying detailed information about your app.

<figure><img src="/files/OmRPMGu61ynx6UbKUyLQ" alt=""><figcaption></figcaption></figure>

Storage app information above to use in the next step(**Callback URL**, **API key**, **Secret key**).

Starting to create a new store for you. Click "Development stores" section in your sapo partner web and click "Tạo development store" to create your store.

<figure><img src="/files/l1SZubRj6dpr02cXe9ei" alt=""><figcaption></figcaption></figure>

Provide your **store name** and **password** and click "Lưu"

<figure><img src="/files/GJmjST3EYvL9Uy2Y1Juh" alt=""><figcaption></figcaption></figure>

Click "Đăng nhập" to access your store

<figure><img src="/files/HCV5RAxT6fZXSWuIuASI" alt=""><figcaption></figcaption></figure>

Your store name is follow this format [https://**{YOUR-STORE-NAME}**.mysapo.net/admin](https://sapo-test-5.mysapo.net/admin)

<figure><img src="/files/oZEwsaES5TTBWcvsagBh" alt=""><figcaption></figcaption></figure>

Back to n8n workflow

You will use the Sapo Authentication node to get an **access token** to use other actions in the Sapo node. Before that, you had to create new credentials to get the **code**.

* Click on the Add node or drag to connect button and enter Sapo Authentication in the search nodes box.
* Select **Create new Credential** at **Credential to connect with** field.

<figure><img src="/files/JJqk7Rm27vGh7JpOfmzn" alt=""><figcaption><p>Create your new credentials</p></figcaption></figure>

The screenshots below are required fields for your connect information needed to get the **code**.

<figure><img src="/files/6Rl7Cw35ANAWNt0g42Qw" alt=""><figcaption></figcaption></figure>

Client ID: is your **API key** in your app.

Client Secret: is your **Secret key** in your app.

Store Name: is your **Store Name**.

Redirect Uri: is your **Callback URL** in your app.

After providing your **Client ID, Client Secret, Store Name,** and **Redirect URI** and clicking **Connect my account** button the permissions window appears and shows the permissions for your app.&#x20;

<figure><img src="/files/a6ZCaiDjzoykYRwd5BpK" alt=""><figcaption></figcaption></figure>

After that, you can click "Cài đặt" to redirect your **Redirect URI** attached to the **code**. Your code is the string between "code=" and "\&hmac". You can copy it to use in the next step.

<figure><img src="/files/4jKrD3QceJdYxSs4WZLq" alt=""><figcaption></figcaption></figure>

After getting a **code** you can close the **get code window** and back to the credential screen. Now you can turn it off and just click close when **Close without connecting** popup appears because Sapo doesn't have Authorization server support OAuth 2.0 protocol. This will not affect the further processes.

<figure><img src="/files/U8S8DTdRYxpmRcE2VpuQ" alt=""><figcaption></figcaption></figure>

Next, you will paste code that was provided in the previous step to the **Code** field. After that, you will click the **Execute node** button to get **access Token.**

<figure><img src="/files/cP3VDd2U2n61k8D7fSo4" alt=""><figcaption></figcaption></figure>

After executing Sapo Authentication node:

<figure><img src="/files/QkulqKKq2iOhLiqDLlmR" alt=""><figcaption></figcaption></figure>

### 3. Sapo node

You will use the **Tạo mới một Product** action in the Sapo node to create a new product in your store that includes the information you just entered.

* Click on the Add node or drag to connect button and enter Sapo in the search nodes box.
* Search **Tạo mới một Product** in the search Sapo Actions box.
* Select **Create new credential** at **Credential to connect with** field.

<figure><img src="/files/YY5y0snMUXebGHcp8MQp" alt=""><figcaption></figcaption></figure>

You will choose Authentication type **Private App** or **OAuth**

1. If you use **Private App** provide information about your app

Client ID: is your **API key** in your app.

Client Secret: is your **Secret key** in your app.

Store Name: is your **Store Name**.

<figure><img src="/files/6l04UyfuX3Z1Y8B9YMaK" alt=""><figcaption><p>Private app credentials</p></figcaption></figure>

Click "Save" to store your credentials

2. If you use OAuth provide accessToken you have taken of the previous step.

Access Token: is **access\_token** you have taken of the Sapo Authentication node.

Store Name: is your **Store Name**.

<figure><img src="/files/Ko5QulyeHJhO7LyW2TcE" alt=""><figcaption><p>OAuth credentials</p></figcaption></figure>

Click "Save" to store your credentials.

Now you can start creating a new product. This example will use the OAuth authentication type.

* Enter the value of fields that you want to set product information.
* Click *Execute node to run a node.*

The screenshots below are examples of input fields for product information creation.

<figure><img src="/files/NESNAKWdGdd9WogL2s7Z" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/DDsoGx9uLrs9askVdEwB" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/er9h6apnt6Jr5NpfuwN2" alt=""><figcaption></figcaption></figure>

After executing **Tạo mới một Product** action of Sapo node:

<figure><img src="/files/GqGbPqVhYhLiV5NPaquv" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: 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:

```
GET https://docs-tech.n8n.vn/sapo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
