# Sitedeki teslimat kuyruğuna bakiyeli Residential siparişi

`POST /account/api/v1/residential/orders/create`

## Yetkilendirme

`Authorization: Bearer YOUR_ARNPROXY_API_KEY`

`Accept: application/json`

Gerekli izin: `purchases`

`Content-Type: application/json`

`Idempotency-Key` · 16–100 harf, rakam, _ veya -. Aynı işlem için değeri saklayıp tekrar kullanın.

## Parametreler

| Ad | Tür | Zorunlu / Koşula bağlı | Varsayılan | Açıklama |
|---|---|---|---|---|
| `Idempotency-Key` (header) | string | Zorunlu | — | 16–100 harf/rakam/_/-. Aynı işlem ve durum sorgusunda aynı değer; farklı gövdeyle yeniden kullanmayın. |
| `mode` (body) | string | Zorunlu | — | new: yeni paket; topup: kendi mevcut paketine GB ekleme. |
| `time_id` (body) | integer | Zorunlu | — | İlgili katalog/options yanıtındaki süre veya GB planı ID’si; doğrudan gün/GB sayısı değildir. |
| `location_id` (body) | integer | Koşula bağlı | — | Yalnız mode=new için zorunlu; topup ile gönderilmez. |
| `package_id` (body) | integer | Koşula bağlı | — | Yalnız mode=topup için zorunlu; new ile gönderilmez. |
| `promo_code` (body) | string | İsteğe bağlı | `""` | İsteğe bağlı promosyon; en fazla 100 bayt. Fiyat ve satın alma/uzatma isteğinde aynı değeri koruyun. |
| `currency` (body) | string | Zorunlu | — | Aynı fiyat yanıtındaki TRY veya USD. Hesabın para birimiyle eşleşmeli. |
| `expected_total_minor` (body) | integer | Zorunlu | — | Aynı fiyat yanıtındaki total_minor; küsuratlı tutar veya metin göndermeyin. En az 1. |
| `expected_selection_hash` (body) | string | Zorunlu | — | Aynı fiyat yanıtındaki selection_hash; 64 küçük harfli onaltılık karakter. |
| `terms` (body) | boolean | Zorunlu | — | Gerçek işlem onayı için tam olarak true; "true" metni kabul edilmez. |

## İstek gövdesi

YOUR_/FROM_ alanlarını ilgili katalog, fiyat veya kapsam değerleriyle değiştirin. Örneklerde onay false bırakılır; gerçek işlemi yalnız bilinçli olarak onaylayın.

```json
{
  "mode": "topup",
  "package_id": "YOUR_PACKAGE_ID",
  "time_id": "FROM_RESIDENTIAL_CATALOG",
  "promo_code": "",
  "currency": "FROM_QUOTE",
  "expected_total_minor": "FROM_QUOTE_TOTAL_MINOR",
  "expected_selection_hash": "FROM_QUOTE_SELECTION_HASH",
  "terms": false
}
```

## Ek kullanım örnekleri

Kimlik ve fiyatlar temsilidir; gerçek değerleri katalog ve aynı fiyat yanıtından alın. JSON kimlikleri ve expected_total_minor sayısal olmalıdır. Güvenlik için örneklerde terms=false bırakılmıştır; gerçek ücretli işlem ancak açık müşteri onayıyla terms=true gönderildiğinde başlatılmalıdır.

### Residential: yeni paket ve GB ekleme farkı · mode=new

Residential siparişlerinde müşteri kullanım amacı seçmez. Yeni pakette kullanım amacı, web sitesindeki siparişle aynı sabit değerle sunucuda otomatik atanır; purpose_id, subpurpose_id veya other_purpose göndermeniz gerekmez. GB ekleme mevcut paketin kullanım amacını korur.

```json
{
  "mode": "new",
  "location_id": 20,
  "time_id": 201,
  "promo_code": "",
  "currency": "TRY",
  "expected_total_minor": 1000,
  "expected_selection_hash": "0000000000000000000000000000000000000000000000000000000000000000",
  "terms": false
}
```

### Residential: yeni paket ve GB ekleme farkı · mode=topup

Residential siparişlerinde müşteri kullanım amacı seçmez. Yeni pakette kullanım amacı, web sitesindeki siparişle aynı sabit değerle sunucuda otomatik atanır; purpose_id, subpurpose_id veya other_purpose göndermeniz gerekmez. GB ekleme mevcut paketin kullanım amacını korur.

```json
{
  "mode": "topup",
  "package_id": 10001,
  "time_id": 201,
  "promo_code": "",
  "currency": "TRY",
  "expected_total_minor": 1000,
  "expected_selection_hash": "0000000000000000000000000000000000000000000000000000000000000000",
  "terms": false
}
```

## İstek örneği

### 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 \
    --header 'Idempotency-Key: YOUR_SAVED_OPERATION_KEY' \
    --request POST --header 'Content-Type: application/json' \
    --data-binary @request.json \
    'https://www.arnproxy.com/account/api/v1/residential/orders/create'
```

### python

```python
import os, requests

headers = {"Authorization": "Bearer " + os.environ["ARNPROXY_API_KEY"]}
headers["Idempotency-Key"] = "YOUR_SAVED_OPERATION_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/orders/create",
    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}` };
headers['Idempotency-Key'] = 'YOUR_SAVED_OPERATION_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/orders/create", {
  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[] = 'Idempotency-Key: YOUR_SAVED_OPERATION_KEY';
$headers[] = 'Content-Type: application/json';
$ch = curl_init('https://www.arnproxy.com/account/api/v1/residential/orders/create');
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/orders/create", body)
  if err != nil { panic(err) }
  req.Header.Set("Authorization", "Bearer "+os.Getenv("ARNPROXY_API_KEY"))
  req.Header.Set("Idempotency-Key", "YOUR_SAVED_OPERATION_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/orders/create");
request.Headers.Authorization = new AuthenticationHeaderValue(
    "Bearer", Environment.GetEnvironmentVariable("ARNPROXY_API_KEY"));
request.Headers.Add("Idempotency-Key", "YOUR_SAVED_OPERATION_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/orders/create"))
    .header("Authorization", "Bearer " + System.getenv("ARNPROXY_API_KEY"))
    .header("Accept", "application/json")
    .header("Idempotency-Key", System.getenv("ARNPROXY_OPERATION_KEY"))
    .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());
```

## Yanıtlar · HTTP 201, 200

```json
{
  "ok": true,
  "data": {
    "state": "accepted",
    "mode": "topup",
    "delivery_state_at_acceptance": "queued",
    "currency": "TRY",
    "total": "15.00",
    "total_minor": 1500,
    "gb": 1,
    "days": 30,
    "target_package_id": 20001,
    "order": {
      "id": 20002,
      "number": "1000020002",
      "location_id": 20,
      "time_id": 201,
      "last_service_date": "2030-02-01"
    },
    "accepted_at": "2030-01-01T12:00:00+00:00",
    "automatic_renewal": false,
    "source": "existing_website_residential_delivery",
    "replayed": false
  },
  "meta": {
    "request_id": "000000000000000000000001",
    "phase": "public_v1",
    "source": "arnproxy_records"
  }
}
```

| Ad | Tür | Koşula bağlı | Açıklama |
|---|---|---|---|
| `ok` | boolean | — | Başarılı istek zarfı; false ise error.code alanını okuyun. |
| `data` | object | — | İşleme özel sonuç. Örnekler temsili ve sentetiktir. |
| `data.state` | string | — | Bu kaydın/işlemin durumu. accepted teslimat, completed bağlantı testi anlamına gelmez. |
| `data.mode` | string | — | mode alanının işleme özel değeri; örnekteki türü ve ilgili davranış notlarını esas alın. |
| `data.delivery_state_at_acceptance` | string | — | delivery state at acceptance alanının işleme özel değeri; örnekteki türü ve ilgili davranış notlarını esas alın. |
| `data.currency` | string | — | Hesabın işlem para birimi: TRY veya USD. |
| `data.total` | string | — | Para tutarı; hassasiyet için yanıtın metin/tam sayı türünü koruyun. |
| `data.total_minor` | integer | — | En küçük para biriminde tam sayı: 1000 = 10.00 TRY/USD. |
| `data.gb` | integer | — | Trafik miktarı; liste/ayar işlemleri kota satın almaz. |
| `data.days` | integer | — | Katalogdaki planın gün sayısı; GB planında kota miktarından ayrıdır. |
| `data.target_package_id` | integer | — | target package id alanının işleme özel değeri; örnekteki türü ve ilgili davranış notlarını esas alın. |
| `data.order` | object | — | order alanının işleme özel değeri; örnekteki türü ve ilgili davranış notlarını esas alın. |
| `data.order.id` | integer | — | İlgili ARNPROXY kayıt kimliği. Sağlayıcının iç kimliği yerine bunu kullanın. |
| `data.order.number` | string | — | Görünen sipariş numarası; API’de id isteyen alanlarla karıştırmayın. |
| `data.order.location_id` | integer | — | Yerel katalogdaki lokasyon veya ürün türü kimliği. |
| `data.order.time_id` | integer | — | Süre/GB planının yerel kayıt kimliği; gün veya GB sayısı değildir. |
| `data.order.last_service_date` | string | — | Son hizmet günü; mevcut, önceki veya fiyatın öngördüğü tarih. Öngörü tek başına uzatma yapmaz. |
| `data.accepted_at` | string | — | Kodun döndürdüğü zaman değeri; örnekte sentetik tarih kullanılır. |
| `data.automatic_renewal` | boolean | — | automatic renewal alanının işleme özel değeri; örnekteki türü ve ilgili davranış notlarını esas alın. |
| `data.source` | string | — | Bu alanın veri kaynağı; yerel kayıt ile canlı sağlayıcı okuması aynı şey değildir. |
| `data.replayed` | boolean | — | Aynı işlem kimliğinin kayıtlı sonucu döndü; tek başına yeni ücret/işlem anlamına gelmez. |
| `meta` | object | — | İstek izleme ve veri kaynağı bilgileri. |
| `meta.request_id` | string | — | Bu HTTP isteğinin kimliği; işlem anahtarı veya sipariş ID’si değildir. |
| `meta.phase` | string | — | phase alanının işleme özel değeri; örnekteki türü ve ilgili davranış notlarını esas alın. |
| `meta.source` | string | — | Bu alanın veri kaynağı; yerel kayıt ile canlı sağlayıcı okuması aynı şey değildir. |

## Davranış ve önemli notlar

- Paket ve liste kimlikleri ARNPROXY kayıt ID’leridir; sağlayıcının paket anahtarını veya liste ID’sini göndermeyin. Eski paket gözlemi erişim için yeterli değildir; gerekirse residential_package_refresh kullanın.
- mode=new yeni paket, mode=topup mevcut pakete GB eklemedir. Önce residential_catalog/quote ile fiyatı kontrol edin. Bakiye kabulü ile arka plan teslimatı ayrıdır; aynı işlem anahtarıyla takip edin.
- Yazma sonucunda zaman aşımı/5xx, başarısızlık kanıtı değildir. Aynı Idempotency-Key ile durum sorgusunu kullanın. Yeni anahtarla tekrar başlatmayın; GET değişikliği tekrar göndermez.
- Residential siparişlerinde müşteri kullanım amacı seçmez. Yeni pakette kullanım amacı, web sitesindeki siparişle aynı sabit değerle sunucuda otomatik atanır; purpose_id, subpurpose_id veya other_purpose göndermeniz gerekmez. GB ekleme mevcut paketin kullanım amacını korur.
- Eski entegrasyonlarla uyumluluk için mode=new ile gönderilen geçerli subpurpose_id/other_purpose alanları kabul edilebilir, ancak yeni siparişin otomatik kullanım amacını değiştirmez. Yeni entegrasyonlar bu alanları göndermemelidir. mode=topup ile bu alanlar desteklenmez. Önceden kabul edilmiş işlemler aynı Idempotency-Key ve aynı istekle sorgulanabilir; yeni anahtarla tekrar sipariş vermeyin.
- Otomatik kullanım amacı yapılandırması uygun değilse RESIDENTIAL_DEFAULT_PURPOSE_UNAVAILABLE (HTTP 503) döner; sipariş oluşturulmaz ve bakiye kesilmez. Bu durumda yönetici yapılandırmayı kontrol etmelidir.

Kimlik doğrulama ve alan denetimleri işlemi başlamadan reddedebilir. Hata rehberini inceleyin; destek için request_id saklayın. Anahtar veya şifre göndermeyin.

[Hatalar ve limitler](https://docs.arnproxy.com/tr/api-v1/errors)

[Aynı işlemi takip edin: Kaydedilmiş ödeme ve güncel Residential teslimat durumu](https://docs.arnproxy.com/tr/api-v1/residential/orders/status)
