# 대상 지정 세션 연결

`POST /account/api/v1/residential/sessions/export`

## 권한 인증

`Authorization: Bearer YOUR_ARNPROXY_API_KEY`

`Accept: application/json`

필요한 권한: `credentials`

`Content-Type: application/json`

## 매개변수

| 이름 | 유형 | 필수 / 조건부 | 기본값 | 설명 |
|---|---|---|---|---|
| `list_id` (body) | integer | 필수 | — | 본인 ARNPROXY 연결 목록 기록 ID이며 공급자 목록 ID가 아닙니다. |
| `country` (body) | string | 선택 | — | 대문자 두 글자 국가 코드, 예: US. |
| `subdivision` (body) | integer | 선택 | — | 양수 지역 코드이며 country가 필요합니다. |
| `city` (body) | string | 선택 | — | country 필요. 문자/숫자를 단일 공백/하이픈으로 구분하며 최대 80바이트입니다. |
| `isp_id` (body) | integer | 선택 | — | residential_isp_codes의 ID, 1~2147483647. |
| `asn` (body) | integer | 선택 | — | ASN 1~4294967295. |
| `zip` (body) | string | 선택 | — | 문자/숫자/하이픈 1~16자, country 필요. |
| `session` (body) | string | 선택 | — | ASCII 문자/숫자 1~64자. |
| `ttl` (body) | string | 선택 | — | 양수와 s/m/h(예: 15m). 최대 86400초이며 session이 필요합니다. |
| `format` (body) | string | 선택 | `"uri"` | uri \| host_port_user_pass \| user_pass_host_port. 인증 정보 형식은 credentials 권한 필요. csv \| custom도 지원. |
| `protocol` (body) | string | 선택 | `"http"` | http 또는 socks5. uri 출력의 접두사만 제어합니다. |
| `offset` (body) | integer | 선택 | `0` | 0~999, 포트 수보다 작아야 합니다. |
| `limit` (body) | integer | 선택 | `10` | 1~1000, 기본 10. |
| `columns` (body) | string[] | 조건부 | — | CSV 전용: id, endpoint, ip, port, login, password. 기본 ["id","endpoint"]. login/password에는 credentials 권한이 필요합니다. |
| `template` (body) | string | 조건부 | — | custom에서 필수, 최대 200자. %endpoint%, %ip%, %port%, %id%, %login%, %username%, %password%, %login_url%, %password_url% 사용 가능. 제어 문자와 알 수 없는 자리표시자는 거부됩니다. |

## 요청 본문

YOUR_/FROM_을 해당 카탈로그, 견적 또는 범위의 값으로 바꾸세요. 예제의 동의 값은 false입니다. 실제 작업에 동의할 때만 승인하세요.

```json
{
  "list_id": "YOUR_SPECIAL_LIST_ID",
  "session": "Example001",
  "ttl": "15m",
  "format": "uri",
  "limit": 1
}
```

## 요청 예제

### 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/residential/sessions/export'
```

### 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/residential/sessions/export",
    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/residential/sessions/export", {
  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/residential/sessions/export');
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/residential/sessions/export", 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/residential/sessions/export");
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/residential/sessions/export"))
    .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": {
    "list_id": 30002,
    "package_id": 20001,
    "format": "uri",
    "protocol": "http",
    "items": [
      "http://ExampleUser_s_Example001_ttl_15m:ExamplePassword@res.arnproxy.com:10000"
    ],
    "count": 1,
    "next_offset": 1,
    "session": "Example001",
    "ttl": "15m",
    "credentials_included": true,
    "provider_requests": 0,
    "database_changes": 0,
    "proxy_connections_tested": false,
    "connection_success_guaranteed": false,
    "snapshot": {
      "source": "arnproxy_records",
      "observed_at": "2030-01-01T12:00:00+00:00",
      "fresh": true,
      "max_age_seconds": 3600,
      "reason": null
    },
    "source": "arnproxy_records"
  },
  "meta": {
    "request_id": "000000000000000000000001",
    "phase": "public_v1",
    "source": "arnproxy_records"
  }
}
```

| 이름 | 유형 | 조건부 | 설명 |
|---|---|---|---|
| `ok` | boolean | — | 성공 여부. false이면 error.code를 확인하세요. |
| `data` | object | — | 작업별 결과이며 예제는 설명용 합성 데이터입니다. |
| `data.list_id` | integer | — | 관련 ARNPROXY 기록 ID. 공급자 내부 ID 대신 사용하세요. |
| `data.package_id` | integer | — | 관련 ARNPROXY 기록 ID. 공급자 내부 ID 대신 사용하세요. |
| `data.format` | string | — | format의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.protocol` | string | — | protocol의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.items` | array | — | 현재 페이지 기록 또는 형식화된 연결 문자열. 빈 목록도 유효할 수 있습니다. |
| `data.items[]` | string | — | 현재 페이지 기록 또는 형식화된 연결 문자열. 빈 목록도 유효할 수 있습니다. |
| `data.count` | integer | — | 결과에 표시되는 기록 수 또는 생성된 연결 수. |
| `data.next_offset` | integer | — | 연결 출력의 다음 오프셋이며 완료 시 null입니다. |
| `data.session` | string | — | session의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.ttl` | string | — | ttl의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.credentials_included` | boolean | — | 결과/키가 민감한 인증 정보를 포함하거나 허용하는지 여부. |
| `data.provider_requests` | integer | — | provider requests의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.database_changes` | integer | — | database changes의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.proxy_connections_tested` | boolean | — | proxy connections tested의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.connection_success_guaranteed` | boolean | — | connection success guaranteed의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `data.snapshot` | object | — | 패키지 관측의 출처/시간/최신성. 오래된 스냅샷은 관리 권한을 주지 않습니다. |
| `data.snapshot.source` | string | — | 데이터 출처. 로컬 기록과 실시간 공급자 조회는 서로 다른 근거입니다. |
| `data.snapshot.observed_at` | string | — | API가 반환하는 형식의 타임스탬프. 예제 날짜는 합성값입니다. |
| `data.snapshot.fresh` | boolean | — | 관측이 최신성 허용 범위에 들어가는지 여부. |
| `data.snapshot.max_age_seconds` | integer | — | 최신 관측으로 인정하는 최대 경과 초. |
| `data.snapshot.reason` | string|null | — | 고정 사유 코드 또는 null이며 원본 공급자 오류 텍스트가 아닙니다. |
| `data.source` | string | — | 데이터 출처. 로컬 기록과 실시간 공급자 조회는 서로 다른 근거입니다. |
| `meta` | object | — | 요청 추적 및 데이터 출처 메타데이터. |
| `meta.request_id` | string | — | 이 HTTP 요청의 추적 ID이며 작업 키나 주문 ID가 아닙니다. |
| `meta.phase` | string | — | phase의 작업별 값입니다. 반환된 유형을 유지하고 동작 설명을 확인하세요. |
| `meta.source` | string | — | 데이터 출처. 로컬 기록과 실시간 공급자 조회는 서로 다른 근거입니다. |

## 동작 및 주요 참고 사항

- 패키지와 목록 ID는 ARNPROXY 기록 ID이며 공급자 키가 아닙니다. 오래된 스냅샷은 접근을 허용하지 않습니다. 필요 시 residential_package_refresh를 사용하세요.
- 세션 접미사는 별도로 만든 검증된 전용 목록에서만 사용합니다. TTL에는 문자/숫자 1~64자의 session이 필요하며 양수 s/m/h는 최대 24시간입니다. 텍스트 생성은 연결하지 않고 실제 사용은 트래픽을 소비합니다.
- 인증 정보가 포함된 출력에는 credentials 권한이 필요합니다. 연결 문자열, 비밀번호, Authorization 헤더를 로그에 남기거나 지원팀에 보내지 마세요.

인증 및 검증 단계에서 실행 전에 요청이 거부될 수 있습니다. 오류 문서를 확인하고 지원 문의용 request_id를 보관하세요. 키나 비밀번호를 보내지 마세요.

[오류 및 제한](https://docs.arnproxy.com/ko/api-v1/errors)
