# Báo giá hoặc yêu cầu nâng cấp

`POST /v1/service/@id/upgrade` · quyền `services:write`

Tính giá nâng cấp; gửi `send=true` để gửi yêu cầu nâng cấp.

Dạng tham số `resources`:

```json
{
  "resource_id": "qty_value",
  "resource_id": "item_id",
  "resource_id": { "item_id": "qty_value" }
}
```

- `"qty_value"`: thanh trượt và ô số lượng
- `"item_id"`: danh sách chọn và nút chọn
- `{ "item_id": "qty_value" }`: danh sách chọn có ô số lượng

## HTTP request

| Mục | Giá trị |
| --- | --- |
| URL | `https://api.tino.vn/v1/service/@id/upgrade` |
| Method | `POST` |
| Quyền (scope) | `services:write` |
| Header | `Authorization: Bearer <token>` |
| Content-Type | `application/json` |
| Token gọi được | token ứng dụng (`tinoat_`), token API cá nhân (`tinopat_`) |

## Tham số

| Tên | Vị trí | Kiểu | Bắt buộc | Mô tả |
| --- | --- | --- | --- | --- |
| `id` | đường dẫn | string | có | ID dịch vụ |
| `resources` | body | array | không | array with resource values |
| `package` | body | integer | không | New package id, optonal when upgrading resources |
| `cycle` | body | string | không | New billing cycle, optonal when upgrading resources |
| `send` | body | boolean | không | Set to true when you want to send your upgrade request |

## Example request

```bash
curl -X POST "https://api.tino.vn/v1/service/100001/upgrade" \
  -H "Authorization: Bearer $TINO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "resources": "<resources>",
  "package": "<package>",
  "cycle": "<cycle>",
  "send": "<send>"
}'
```

`$TINO_TOKEN` là token có quyền `services:write`. Tham số đường dẫn trong ví dụ là giá trị mẫu.

SDK ([SDK & Ví dụ](/docs/sdk)): Python `client.services.request_upgrade(id, id=...)`, Node.js `await client.services.requestUpgrade(id, { id: ... });`, PHP `$client->services->requestUpgrade($id, ['id' => ...]);`.

## Example response

```json
{
 "total": {
  "subtotal": 0,
  "total": 0,
  "credit": 0,
  "items": [
   {
    "amount": 0,
    "taxed": 1,
    "tax_group_id": 3,
    "type": "Other",
    "qty": 1,
    "tax_rate": null,
    "level": {
     "L1": {
      "priority": 1,
      "type": "L1",
      "name": "VAT",
      "rate": "8.00",
      "tax_group_id": 3,
      "applyto": "net",
      "negative": true,
      "condition": null,
      "id": "4",
      "country": "0",
      "state": "0",
      "source": "region",
      "taxtotal": 8,
      "tax": 0
     }
    },
    "linetotal": 0,
    "discount": 0,
    "net_discount": 0,
    "off": 0,
    "net_off": 0,
    "net": 0,
    "gross": 0,
    "tax": 0
   }
  ],
  "recurring": {
   "m_taxed": "85320"
  },
  "taxes": {
  … 52 more line(s)
```

Mẫu thật từ tài khoản thử, đã che dữ liệu cá nhân; mảng và chuỗi dài được rút gọn (`… N more item(s)`, `… N more line(s)`).
