# Tin nhắn SMS

Để gửi tin nhắn SMS trên CareSoft cần dịch vụ SMS Brandname đã được tích hợp vào tài khoản khách hàng.&#x20;

<figure><img src="https://2193274687-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw9FEMPuWidjTVayVtnJj%2Fuploads%2FRserOugBgJUKk6p03hsj%2FsmsService.png?alt=media&#x26;token=cd2a6d3f-5e4b-4d63-a672-1009cc560876" alt=""><figcaption><p>Cách kiểm tra dịch vụ SMS đã được tích hợp lên hệ thống và lấy ID dịch vụ để thực hiện gửi SMS </p></figcaption></figure>

Lập trình viên có thể sử dụng API SMS tích hợp vào hệ thống CRM/ERP để thực hiện các nghiệp vụ nhắn tin báo số dư, báo trạng thái đơn hàng cho khách hàng theo bối cảnh thực tế.

### Thông tin trường dữ liệu SMS&#x20;

<table><thead><tr><th width="88" data-type="number">STT</th><th width="133">Tên trường</th><th width="133">Kiểu dữ liệu<select><option value="0c41f215a0e941c9973e6b6b6b26a9b5" label="STRING (1000)" color="blue"></option><option value="663e68d0124341ef98fca59215b3d6bd" label="TELEPHONE" color="blue"></option><option value="e30534b0a730432fa57d9f37ca392a75" label="INT" color="blue"></option></select></th><th>Ý nghĩa</th></tr></thead><tbody><tr><td>1</td><td>service_id</td><td><span data-option="e30534b0a730432fa57d9f37ca392a75">INT</span></td><td>ID dịch vụ SMS đã tích hợp trên hệ thống CareSoft</td></tr><tr><td>2</td><td>content</td><td><span data-option="0c41f215a0e941c9973e6b6b6b26a9b5">STRING (1000)</span></td><td>Nội dung tin nhắn gửi đi</td></tr><tr><td>3</td><td>phone</td><td><span data-option="663e68d0124341ef98fca59215b3d6bd">TELEPHONE</span></td><td>Số điện thoại nhận SMS</td></tr><tr><td>4</td><td>ticket_id</td><td><span data-option="e30534b0a730432fa57d9f37ca392a75">INT</span></td><td>ID phiếu ghi trong trường hợp cần gán vào phiếu ghi đã có từ trước</td></tr></tbody></table>

#### Mẫu json body gửi SMS

```json
{
    "sms": {
        "service_id": "12",
        "content": "nội dung tin nhắn",
        "phone": "0980000000"
    }
}
```

#### Mẫu curl gửi tin nhắn SMS&#x20;

```powershell
curl --location --globoff 'https://api.caresoft.vn/{{domain}}/api/v1/sms' \
--header 'Authorization: Bearer {{apiToken}}' \
--header 'Content-Type: application/json' \
--data '{
    "sms": {
        "service_id": "12",
        "content": "Chúc mừng sinh nhật quý khách hàng.",
        "phone": "0980000000"
    }
}'
```

#### Mẫu POSTMAN cấu hình thông tin gửi SMS&#x20;

<figure><img src="https://2193274687-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fw9FEMPuWidjTVayVtnJj%2Fuploads%2FKxFnB1GjllvF1Mdi7KIS%2FPOST_MAN_SMS_SAMPLE.png?alt=media&#x26;token=cee1b285-f184-454a-b21d-187b6dbc427b" alt=""><figcaption></figcaption></figure>

## Gửi tin nhắn SMS&#x20;

<mark style="color:green;">`POST`</mark> `{{domain}}/api/v1/sms`

API gửi SMS&#x20;

#### Headers

| Name                                   | Type   | Description                                                                                |
| -------------------------------------- | ------ | ------------------------------------------------------------------------------------------ |
| \*\*<mark style="color:red;">\*</mark> | String | [Thông tin xác thực chung ](https://docs.caresoft.vn/thong-tin-chung#phuong-thuc-xac-thuc) |

#### Request Body

| Name                                  | Type   | Description                                                                   |
| ------------------------------------- | ------ | ----------------------------------------------------------------------------- |
| sms<mark style="color:red;">\*</mark> | Object | Theo [#thong-tin-truong-du-lieu-sms](#thong-tin-truong-du-lieu-sms "mention") |

{% tabs %}
{% tab title="200: OK " %}
{% tabs %}
{% tab title="Kết quả điển hình" %}

```json
{
  "code": "ok",
  "ticket": {
    "ticket_id": 291437,
    "ticket_no": 205025,
    "requester_id": 63203810,
    "assignee_id": 1
  }
}
```

{% endtab %}

{% tab title="Mô tả  kết quả" %}

{% endtab %}
{% endtabs %}

{% endtab %}

{% tab title="400: Bad Request " %}

{% endtab %}

{% tab title="500: Internal Server Error " %}

{% endtab %}
{% endtabs %}

<table><thead><tr><th width="91">STT</th><th width="112">Tên trường</th><th width="129">Kiểu</th><th>Ý nghĩa</th></tr></thead><tbody><tr><td>1</td><td>code</td><td>String</td><td>Trạng thái thành công</td></tr><tr><td>2</td><td>ticket</td><td>Object</td><td>Đối tượng phiếu ghi được tạo mới/Hoặc cập nhật khi gửi SMS <br><a data-footnote-ref href="#user-content-fn-1">(Xem thêm)</a></td></tr><tr><td></td><td></td><td></td><td></td></tr></tbody></table>

[^1]: `ticket_id`: Id Phiếu ghi\
    `ticket_no`: Số phiếu ghi\
    `assignee_id`: ID chuyên viên giữ phiếu\
    `requester_id`: ID khách hàng


---

# 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.caresoft.vn/danh-muc/restful-api-cua-caresoft/tin-nhan-sms.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.
