# 续期报价

`POST /account/api/v1/renewals/quote`

## 授权

`Authorization: Bearer YOUR_ARNPROXY_API_KEY`

`Accept: application/json`

所需权限: `read`

`Content-Type: application/json`

## 参数

| 名称 | 类型 | 必填 / 条件必填 | 默认值 | 说明 |
|---|---|---|---|---|
| `proxy_ids` (body) | integer[] | 必填 | — | 1–1000 个自己的唯一代理 ID。要求共同范围/价格时不要混用产品类型；部分操作限制更严格。 |
| `time_id` (body) | integer | 必填 | — | 对应目录/options 中的租期或 GB 方案 ID，不是天数或 GB 数量。 |
| `promo_code` (body) | string | 可选 | `""` | 可选优惠码，最多 100 字节。报价与购买/续期时必须保持相同。 |

## 请求体

请用相应目录、报价或范围中的值替换 YOUR_/FROM_。示例中的确认值为 false；只有明确同意真实操作时才确认。

```json
{
  "proxy_ids": [
    "YOUR_PROXY_ID"
  ],
  "time_id": "FROM_RENEWAL_OPTIONS",
  "promo_code": ""
}
```

## 请求示例

### curl

```curl
printf 'Authorization: Bearer %s\n' "$ARNPROXY_API_KEY" |
  curl --silent --show-error --header @- \
    --header 'Accept: application/json' \
    --connect-timeout 10 --max-time 30 \
    --request POST --header 'Content-Type: application/json' \
    --data-binary @request.json \
    'https://www.arnproxy.com/account/api/v1/renewals/quote'
```

### python

```python
import os, requests

headers = {"Authorization": "Bearer " + os.environ["ARNPROXY_API_KEY"]}
import json
with open("request.json", encoding="utf-8") as f:
    payload = json.load(f)
response = requests.post(
    "https://www.arnproxy.com/account/api/v1/renewals/quote",
    headers=headers, json=payload,
    timeout=(10, 30), allow_redirects=False
)
print(response.status_code, response.text)
# No automatic write retry.
```

### javascript

```javascript
const headers = { Authorization: `Bearer ${process.env.ARNPROXY_API_KEY}` };
const { readFile } = await import('node:fs/promises');
headers['Content-Type'] = 'application/json';
const body = await readFile('request.json', 'utf8');
const response = await fetch("https://www.arnproxy.com/account/api/v1/renewals/quote", {
  method: 'POST', headers, redirect: 'error',
  signal: AbortSignal.timeout(30000), body
});
console.log(response.status, await response.text());
// A write timeout is ambiguous; query its saved operation.
```

### php

```php
<?php
$headers = ['Accept: application/json',
    'Authorization: Bearer '.getenv('ARNPROXY_API_KEY')];
$headers[] = 'Content-Type: application/json';
$ch = curl_init('https://www.arnproxy.com/account/api/v1/renewals/quote');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2,
    CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 30,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => file_get_contents('request.json'),
]);
$result = curl_exec($ch);
if ($result === false) {
    // Do not repeat a write; use the original operation key.
    throw new RuntimeException('Transport result unknown');
}
echo curl_getinfo($ch, CURLINFO_HTTP_CODE).PHP_EOL.$result;
curl_close($ch);
```

### go

```go
package main

import (
  "fmt"
  "io"
  "net/http"
  "os"
  "time"
)

func main() {
  client := &http.Client{Timeout: 30*time.Second,
    CheckRedirect: func(req *http.Request, via []*http.Request) error {
      return http.ErrUseLastResponse
    }}
  var body io.Reader
  file, err := os.Open("request.json"); if err != nil { panic(err) }
  defer file.Close(); body = file
  req, err := http.NewRequest("POST", "https://www.arnproxy.com/account/api/v1/renewals/quote", body)
  if err != nil { panic(err) }
  req.Header.Set("Authorization", "Bearer "+os.Getenv("ARNPROXY_API_KEY"))
  req.Header.Set("Content-Type", "application/json")
  res, err := client.Do(req); if err != nil { panic(err) }
  defer res.Body.Close()
  data, err := io.ReadAll(res.Body); if err != nil { panic(err) }
  fmt.Println(res.StatusCode, string(data))
}
```

### csharp

```csharp
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

using var handler = new HttpClientHandler { AllowAutoRedirect = false };
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(30) };
using var request = new HttpRequestMessage(HttpMethod.Post,
    "https://www.arnproxy.com/account/api/v1/renewals/quote");
request.Headers.Authorization = new AuthenticationHeaderValue(
    "Bearer", Environment.GetEnvironmentVariable("ARNPROXY_API_KEY"));
request.Content = new StringContent(
    await File.ReadAllTextAsync("request.json"), Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
Console.WriteLine((int)response.StatusCode);
Console.WriteLine(await response.Content.ReadAsStringAsync());
// Never automatically retry an ambiguous write.
```

### java

```java
import java.net.URI;
import java.net.http.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;

// Inside your application method:
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create("https://www.arnproxy.com/account/api/v1/renewals/quote"))
    .header("Authorization", "Bearer " + System.getenv("ARNPROXY_API_KEY"))
    .header("Accept", "application/json")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(
        Files.readString(Path.of("request.json"), StandardCharsets.UTF_8)))
    .build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
```

## 响应 · HTTP 200

```json
{
  "ok": true,
  "data": {
    "product_id": 5,
    "currency": "TRY",
    "proxy_ids": [
      12345
    ],
    "quantity": 1,
    "selection_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
    "time_id": 101,
    "period": "7 days",
    "days": 7,
    "base_total": "10.00",
    "quantity_discount_amount": "0.00",
    "subtotal": "10.00",
    "promotion": {
      "code": "",
      "rate": "0.00",
      "amount": "0.00"
    },
    "total": "10.00",
    "total_minor": 1000,
    "lines": [
      {
        "location_id": 10,
        "country": "Example country",
        "quantity": 1,
        "base_unit_price": "10.0000",
        "unit_price": "10.0000",
        "quantity_discount_rate": "0.00",
        "total_minor": 1000,
        "total": "10.00"
      }
    ],
    "proxies": [
      {
        "id": 12345,
        "location_id": 10,
        "last_service_date": "2030-02-01",
        "projected_last_service_date": "2030-02-08",
        "total": "10.00",
        "total_minor": 1000
      }
    ],
    "discount_scope": "country",
    "timezone": "Europe/Istanbul",
    "estimate_only": true,
    "renewal_available": true,
    "provider_checked": false,
    "calculated_at": "2030-01-01T12:00:00+00:00"
  },
  "meta": {
    "request_id": "000000000000000000000001",
    "phase": "public_v1",
    "source": "arnproxy_records"
  }
}
```

| 名称 | 类型 | 条件必填 | 说明 |
|---|---|---|---|
| `ok` | boolean | — | 成功标志；为 false 时请检查 error.code。 |
| `data` | object | — | 操作特定结果；示例均为演示用合成数据。 |
| `data.product_id` | integer | — | 本地目录的位置或产品类型 ID。 |
| `data.currency` | string | — | 账户交易币种：TRY 或 USD。 |
| `data.proxy_ids` | array | — | 此账户可见范围内的代理 ID。 |
| `data.proxy_ids[]` | integer | — | 此账户可见范围内的代理 ID。 |
| `data.quantity` | integer | — | 所选或订购的代理数量。 |
| `data.selection_hash` | string | — | 应原样返回至对应写操作/报价确认的新鲜度摘要。 |
| `data.time_id` | integer | — | 本地租期/GB 方案记录 ID，不是天数或 GB 数量。 |
| `data.period` | string | — | 可读的目录租期名称。 |
| `data.days` | integer | — | 方案天数，与 GB 方案流量数量分开。 |
| `data.base_total` | string | — | 金额；为避免精度损失，请保留返回的字符串/整数类型。 |
| `data.quantity_discount_amount` | string | — | quantity discount amount 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.subtotal` | string | — | 金额；为避免精度损失，请保留返回的字符串/整数类型。 |
| `data.promotion` | object | — | promotion 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.promotion.code` | string | — | code 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.promotion.rate` | string | — | rate 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.promotion.amount` | string | — | 金额；为避免精度损失，请保留返回的字符串/整数类型。 |
| `data.total` | string | — | 金额；为避免精度损失，请保留返回的字符串/整数类型。 |
| `data.total_minor` | integer | — | 最小货币单位整数：1000 表示 10.00 TRY/USD。 |
| `data.lines` | array | — | lines 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.lines[]` | object | — | lines 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.lines[].location_id` | integer | — | 本地目录的位置或产品类型 ID。 |
| `data.lines[].country` | string | — | country 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.lines[].quantity` | integer | — | 所选或订购的代理数量。 |
| `data.lines[].base_unit_price` | string | — | base unit price 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.lines[].unit_price` | string | — | unit price 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.lines[].quantity_discount_rate` | string | — | quantity discount rate 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.lines[].total_minor` | integer | — | 最小货币单位整数：1000 表示 10.00 TRY/USD。 |
| `data.lines[].total` | string | — | 金额；为避免精度损失，请保留返回的字符串/整数类型。 |
| `data.proxies` | array | — | proxies 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.proxies[]` | object | — | proxies 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.proxies[].id` | integer | — | 相关 ARNPROXY 记录 ID，请勿替换为上游内部 ID。 |
| `data.proxies[].location_id` | integer | — | 本地目录的位置或产品类型 ID。 |
| `data.proxies[].last_service_date` | string | — | 最后服务日：当前、之前或报价预测日期。预测本身不会执行续期。 |
| `data.proxies[].projected_last_service_date` | string | — | 最后服务日：当前、之前或报价预测日期。预测本身不会执行续期。 |
| `data.proxies[].total` | string | — | 金额；为避免精度损失，请保留返回的字符串/整数类型。 |
| `data.proxies[].total_minor` | integer | — | 最小货币单位整数：1000 表示 10.00 TRY/USD。 |
| `data.discount_scope` | string | — | discount scope 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.timezone` | string | — | 相关日期字段的时区；null 表示没有已验证时区。 |
| `data.estimate_only` | boolean | — | estimate only 的操作特定值。请保留返回类型并查阅行为说明。 |
| `data.renewal_available` | boolean | — | 根据响应条件/权限确定的可用性，不代表库存或上游可用性保证。 |
| `data.provider_checked` | boolean | — | 仅凭价格/本地结果不能保证上游可用性或库存。 |
| `data.calculated_at` | string | — | API 返回格式的时间戳；示例日期为合成数据。 |
| `meta` | object | — | 请求关联与数据来源元信息。 |
| `meta.request_id` | string | — | 此 HTTP 请求的跟踪 ID，不是操作键或订单 ID。 |
| `meta.phase` | string | — | phase 的操作特定值。请保留返回类型并查阅行为说明。 |
| `meta.source` | string | — | 数据来源；本地记录与实时上游查询属于不同证据。 |

## 行为与重要说明

- 续期使用现有网站定价和余额流程。金额、天数和选择摘要必须来自同一 renewal_quote；此操作不会开启自动续期。
- 同一次续费请求中的代理必须属于同一产品类型。数量折扣按各国所选数量单独计算，不合并不同国家的数量。

身份验证和参数校验可能在执行前拒绝请求。请查阅错误参考，联系支持时保留 request_id。切勿发送密钥或密码。

[错误与限制](https://docs.arnproxy.com/zh/api-v1/errors)
