> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.insurgateway.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.insurgateway.com/_mcp/server.

# Offer Batch Premium

POST https://testgatewayapi.insurapps.net/api/Offline/jobs/{jobId}/Premiums/batch
Content-Type: application/json

## Toplu Teklif Primi Ver

### Endpoint Bilgileri

| Alan              | Değer                                                 |
| ----------------- | ----------------------------------------------------- |
| **Method**        | `POST`                                                |
| **URL**           | `{{baseUrl}}/api/Offline/jobs/{jobId}/Premiums/batch` |
| **Content-Type**  | `application/json`                                    |
| **Yetkilendirme** | Bearer Token + `Create` politikası                    |

***

Acentenin açtığı toplu prim isteğine karşılık, sigorta şirketinin **toplu teklif primlerini** iletmesi için kullanılır.

Başarılı istekte iş `Toplu Prim Verildi` (`BatchPremiumOffered`) aşamasına geçer, primler platform servisine yazılır, aksiyon kaydı oluşturulup platforma iletilir ve teklif PDF'leri asenkron olarak kaydedilir.

> İşin aşaması `Toplu Prim İsteği` (`BatchPremiumRequested`) olmalıdır; aksi halde geçiş reddedilir.

***

### Route Parametreleri

| Parametre | Tip       | Zorunlu | Açıklama                                         |
| --------- | --------- | ------- | ------------------------------------------------ |
| `jobId`   | `integer` | Evet    | Teklif primlerinin kaydedileceği işin Id bilgisi |

***

### Kimlik Doğrulama

Geçerli bir bearer token gerektirir. Token şunları içermelidir:

* Tanınan bir rol (`InsuranceCompanyAPIUser`, `InsuranceCompanyAPIAdmin` veya `Supervizor`)
* İlgili route için `Create` yetkisi
* Geçerli bir sigorta şirketi ataması
* Çözümlenebilir bir kullanıcı kimliği

> `InsuranceCompanyAPIUser` yalnızca kendi sahibi olduğu işleri işleyebilir. `InsuranceCompanyAPIAdmin` ve `Supervizor` şirketin tüm işlerine erişebilir.

***

### İstek Modeli — `CreateBatchPremiumRequest`

| Alan        | Tip                          | Zorunlu | Açıklama                   | Doğrulama                                                                                           |
| ----------- | ---------------------------- | ------- | -------------------------- | --------------------------------------------------------------------------------------------------- |
| `ProductId` | `integer`                    | Evet    | Teklifin verildiği ürün Id | Zorunlu: `"Product ID is required."` 0'dan büyük olmalı: `"Product ID must be greater than 0."`     |
| `Message`   | `string`                     | Hayır   | Teklife iliştirilen not    | Maks. 500 karakter: `"Message cannot exceed 500 characters."`                                       |
| `Premiums`  | `BatchPremiumEntryRequest[]` | Evet    | Toplu prim girişleri       | Zorunlu: `"Premium list is required."` Boş olamaz: `"Premium list cannot be empty."`                |
| `OfferPdfs` | `PremiumFileRequest[]`       | Evet    | Teklif PDF'leri            | Zorunlu: `"Offer PDF files are required."` Boş olamaz: `"At least one offer PDF file is required."` |

> `JobId` gövdeden alınmaz (`[JsonIgnore]`); route parametresinden set edilir. Bu uçta `JobId` için ayrı bir doğrulama kuralı tanımlı değildir; route kısıtı (`{jobId:int}`) yeterlidir.
>
> Teklif PDF'i zorunluluğu hem doğrulama katmanında hem de state transition içinde kontrol edilir; doğrulama önce çalıştığı için eksik PDF `400` döner.

#### Prim Girişi — `BatchPremiumEntryRequest`

| Alan                                | Tip       | Zorunlu | Açıklama                                | Doğrulama                                                                            |
| ----------------------------------- | --------- | ------- | --------------------------------------- | ------------------------------------------------------------------------------------ |
| `InsuranceCompanyProposalNumber`    | `string`  | Hayır   | Sigorta şirketi teklif numarası         | —                                                                                    |
| `InsuranceCompanyPolicyNumber`      | `string`  | Hayır   | Sigorta şirketi poliçe numarası         | —                                                                                    |
| `InsuranceCompanyEndorsementNumber` | `string`  | Hayır   | Sigorta şirketi zeyil numarası          | —                                                                                    |
| `RenewalNumber`                     | `integer` | Evet    | Yenileme numarası                       | 0'dan büyük veya eşit olmalı: `"Renewal number must be greater than or equal to 0."` |
| `GrossPremium`                      | `decimal` | Evet    | Brüt prim                               | 0'dan büyük olmalı: `"Gross premium must be greater than 0."`                        |
| `NetPremium`                        | `decimal` | Evet    | Net prim                                | 0'dan büyük olmalı: `"Net premium must be greater than 0."`                          |
| `Commision`                         | `decimal` | Evet    | Komisyon (alan adı tek `s` ile yazılır) | 0'dan büyük veya eşit olmalı: `"Commission must be greater than or equal to 0."`     |
| `PaymentOptionType`                 | `integer` | Evet    | Ödeme tipi                              | Tanımlı bir değer olmalı: `"A valid payment option type is required."`               |
| `CurrencyType`                      | `integer` | Evet    | Para birimi                             | Tanımlı bir değer olmalı: `"A valid currency type is required."`                     |

#### Ödeme Tipi Değerleri

| Değer | Ödeme Tipi  |
| ----- | ----------- |
| `1`   | Hesaptan    |
| `2`   | Kredi Kartı |
| `3`   | Tümü        |

#### Para Birimi Değerleri

| Değer | Para Birimi      |
| ----- | ---------------- |
| `1`   | TL               |
| `2`   | Dolar            |
| `3`   | Euro             |
| `4`   | İngiliz Sterlini |
| `5`   | Japon Yeni       |
| `6`   | İsviçre Frangı   |
| `7`   | İsveç Kronu      |

#### Teklif PDF'i — `PremiumFileRequest`

| Alan            | Tip      | Zorunlu | Açıklama                   | Doğrulama                                                                                                                                                                                            |
| --------------- | -------- | ------- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FileName`      | `string` | Evet    | Dosya adı                  | Boş olamaz: `"FileName must not be empty."` `.pdf` ile bitmeli: `"Only PDF files are allowed."`                                                                                                      |
| `Base64Content` | `string` | Evet    | Base64 kodlu dosya içeriği | Boş olamaz: `"Base64Content must not be empty."` Geçerli base64 olmalı: `"Base64Content must be a valid base64 encoded string."` İçerik geçerli bir PDF olmalı: `"File content is not a valid PDF."` |
| `ContentType`   | `string` | Hayır   | MIME türü                  | Doğrulanmaz; kayıt sırasında `application/pdf` olarak set edilir                                                                                                                                     |

***

### İş Kuralları

State geçişi sırasında sırasıyla aşağıdaki kontroller yapılır:

1. İş `Toplu Prim İsteği` aşamasında olmalıdır.
2. İşe ait teklif (`Proposal`) kaydı bulunmalıdır.
3. Teklif + ürün için `OperationWatch` kaydı bulunmalıdır.
4. Primler platform servisine yazılabilmelidir.
5. Aksiyonu karşılayacak platform kullanıcısı bulunmalı ve aksiyon platforma iletilebilmelidir.

> **Geri alma davranışı:** 4. kural başarısız olursa `OperationWatch` başarısız işaretlenir ve iş `Toplu Prim İsteği` aşamasına geri döndürülür. 5. kural başarısız olursa oluşturulan aksiyon kaydı silinir.

***

### Yanıt

#### `201 Created` — Başarılı Yanıt

Gövde boştur.

***

### Hata Senaryoları

#### `400 Bad Request` — Doğrulama Hatası

İstek modeli doğrulamadan geçemediğinde döner. Hatalı alanlar `Response` içinde listelenir.

```json
{
  "Status": false,
  "Code": "Validation.General",
  "Message": "One or more validation errors occurred",
  "Response": [
    {
      "Field": "ProductId",
      "Message": "Product ID is required."
    },
    {
      "Field": "OfferPdfs",
      "Message": "Offer PDF files are required."
    }
  ]
}

```

***

#### `403 Forbidden` — Geçerli Sigorta Şirketi Ataması Bulunamadı

Token'da geçerli bir sigorta şirketi ataması bulunmadığında döner.

```json
{
  "Status": false,
  "Code": "OfflineUsers.InsuranceCompanyNotFound",
  "Message": "No valid insurance company assignment found in token.",
  "Response": null
}

```

***

#### `403 Forbidden` — Kullanıcı Kimliği Çözümlenemedi

Token'dan kullanıcı kimliği okunamadığında döner.

```json
{
  "Status": false,
  "Code": "OfflineUsers.UserIdentityNotResolved",
  "Message": "User identity could not be resolved from token.",
  "Response": null
}

```

***

#### `403 Forbidden` — İşe Erişim Reddedildi

İş, çağıranın sahipliğinde değilse döner.

```json
{
  "Status": false,
  "Code": "OfflineJobs.JobOwnershipDenied",
  "Message": "You do not have permission to access this job.",
  "Response": null
}

```

***

#### `403 Forbidden` — Rol veya Yetki Yetersiz

Kullanıcı tanınan rollerden birine sahip değilse ya da `Create` yetkisi yoksa döner. **Gövde boştur.**

***

#### `401 Unauthorized` — Token Yok veya Geçersiz

Token gönderilmediğinde, geçersiz olduğunda veya süresi dolduğunda döner. **Gövde boştur.**

***

#### `404 Not Found` — İş Bulunamadı

Belirtilen `jobId` ile bir iş bulunamadığında döner.

```json
{
  "Status": false,
  "Code": "OfflineJobs.JobNotFound",
  "Message": "No job found for the requested JobId: 100931.",
  "Response": null
}

```

***

#### `404 Not Found` — Teklif Kaydı Bulunamadı

İşe ait teklif kaydı bulunamadığında döner.

```json
{
  "Status": false,
  "Code": "JobState.ProposalNotFound",
  "Message": "Proposal record not found for job 100931.",
  "Response": null
}

```

***

#### `404 Not Found` — Operation Watch Kaydı Bulunamadı

Teklif + ürün için operasyon kaydı bulunamadığında döner.

```json
{
  "Status": false,
  "Code": "JobState.OperationWatchNotFound",
  "Message": "Operation Watch record not found for job 100931.",
  "Response": null
}

```

***

#### `500 Internal Server Error` — Platform Servisi Hatası

Prim bilgileri platform servisine yazılamadığında döner.

```json
{
  "Status": false,
  "Code": "JobState.PlatformServiceFailure",
  "Message": "Failed to write premium information to the platform service. Platform returned: Prim bilgileri platform servisine yazdırılamadı! Servisten dönen hata: Timeout",
  "Response": null
}

```

***

#### `500 Internal Server Error` — İş Kuralı İhlali

İş uygun aşamada değilse, aksiyonu karşılayacak kullanıcı bulunamazsa veya aksiyon platforma iletilemezse döner.

```json
{
  "Status": false,
  "Code": "JobState.UnknownBusinessRule",
  "Message": "An unknown business rule error occurred: 'Toplu Prim Verildi' aşamasından 'Toplu Prim Verildi' aşamasına geçiş yapılamaz.",
  "Response": null
}

```

***

#### `500 Internal Server Error` — Beklenmeyen Hata

Geçiş sırasında iş kuralı dışında bir hata oluştuğunda döner.

```json
{
  "Status": false,
  "Code": "JobState.TransitionError",
  "Message": "An unexpected error occurred during job state transition.",
  "Response": null
}

```

Reference: https://docs.insurgateway.com/insurgateway-api/offline/offer-batch-premium

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://testgatewayapi.insurapps.net` (https://testgatewayapi.insurapps.net, default)
- `https://gatewayapi.insurapps.net` (https://gatewayapi.insurapps.net)

## Request

### Path parameters

- `jobId` (integer, required)

## Response

### 201

Created

## Errors

### 400 Bad Request Error

Bad Request

### 403 Forbidden Error

Forbidden

### 404 Not Found Error

Not Found

### 500 Internal Server Error

Internal Server Error

## Examples

**Request**

```json
{
  "ProductId": 2321,
  "Message": "Toplu teklif primleri iletilmiştir.",
  "Premiums": [
    {
      "InsuranceCompanyProposalNumber": "SKT2026001",
      "InsuranceCompanyPolicyNumber": null,
      "InsuranceCompanyEndorsementNumber": null,
      "RenewalNumber": 0,
      "GrossPremium": 5000,
      "NetPremium": 4500,
      "Commision": 500,
      "PaymentOptionType": 1,
      "CurrencyType": 1
    }
  ],
  "OfferPdfs": [
    {
      "FileName": "teklif.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    }
  ]
}
```

**Response**

```json
""
```

**SDK Code**

```python Offline_offerBatchPremium_example
import requests

url = "https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch"

payload = {
    "ProductId": 2321,
    "Message": "Toplu teklif primleri iletilmiştir.",
    "Premiums": [
        {
            "InsuranceCompanyProposalNumber": "SKT2026001",
            "InsuranceCompanyPolicyNumber": None,
            "InsuranceCompanyEndorsementNumber": None,
            "RenewalNumber": 0,
            "GrossPremium": 5000,
            "NetPremium": 4500,
            "Commision": 500,
            "PaymentOptionType": 1,
            "CurrencyType": 1
        }
    ],
    "OfferPdfs": [
        {
            "FileName": "teklif.pdf",
            "ContentType": "application/pdf",
            "Base64Content": "JVBERi0xLjAK"
        }
    ]
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Offline_offerBatchPremium_example
const url = 'https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"ProductId":2321,"Message":"Toplu teklif primleri iletilmiştir.","Premiums":[{"InsuranceCompanyProposalNumber":"SKT2026001","InsuranceCompanyPolicyNumber":null,"InsuranceCompanyEndorsementNumber":null,"RenewalNumber":0,"GrossPremium":5000,"NetPremium":4500,"Commision":500,"PaymentOptionType":1,"CurrencyType":1}],"OfferPdfs":[{"FileName":"teklif.pdf","ContentType":"application/pdf","Base64Content":"JVBERi0xLjAK"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Offline_offerBatchPremium_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch"

	payload := strings.NewReader("{\n  \"ProductId\": 2321,\n  \"Message\": \"Toplu teklif primleri iletilmiştir.\",\n  \"Premiums\": [\n    {\n      \"InsuranceCompanyProposalNumber\": \"SKT2026001\",\n      \"InsuranceCompanyPolicyNumber\": null,\n      \"InsuranceCompanyEndorsementNumber\": null,\n      \"RenewalNumber\": 0,\n      \"GrossPremium\": 5000,\n      \"NetPremium\": 4500,\n      \"Commision\": 500,\n      \"PaymentOptionType\": 1,\n      \"CurrencyType\": 1\n    }\n  ],\n  \"OfferPdfs\": [\n    {\n      \"FileName\": \"teklif.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Offline_offerBatchPremium_example
require 'uri'
require 'net/http'

url = URI("https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"ProductId\": 2321,\n  \"Message\": \"Toplu teklif primleri iletilmiştir.\",\n  \"Premiums\": [\n    {\n      \"InsuranceCompanyProposalNumber\": \"SKT2026001\",\n      \"InsuranceCompanyPolicyNumber\": null,\n      \"InsuranceCompanyEndorsementNumber\": null,\n      \"RenewalNumber\": 0,\n      \"GrossPremium\": 5000,\n      \"NetPremium\": 4500,\n      \"Commision\": 500,\n      \"PaymentOptionType\": 1,\n      \"CurrencyType\": 1\n    }\n  ],\n  \"OfferPdfs\": [\n    {\n      \"FileName\": \"teklif.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java Offline_offerBatchPremium_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"ProductId\": 2321,\n  \"Message\": \"Toplu teklif primleri iletilmiştir.\",\n  \"Premiums\": [\n    {\n      \"InsuranceCompanyProposalNumber\": \"SKT2026001\",\n      \"InsuranceCompanyPolicyNumber\": null,\n      \"InsuranceCompanyEndorsementNumber\": null,\n      \"RenewalNumber\": 0,\n      \"GrossPremium\": 5000,\n      \"NetPremium\": 4500,\n      \"Commision\": 500,\n      \"PaymentOptionType\": 1,\n      \"CurrencyType\": 1\n    }\n  ],\n  \"OfferPdfs\": [\n    {\n      \"FileName\": \"teklif.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}")
  .asString();
```

```php Offline_offerBatchPremium_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch', [
  'body' => '{
  "ProductId": 2321,
  "Message": "Toplu teklif primleri iletilmiştir.",
  "Premiums": [
    {
      "InsuranceCompanyProposalNumber": "SKT2026001",
      "InsuranceCompanyPolicyNumber": null,
      "InsuranceCompanyEndorsementNumber": null,
      "RenewalNumber": 0,
      "GrossPremium": 5000,
      "NetPremium": 4500,
      "Commision": 500,
      "PaymentOptionType": 1,
      "CurrencyType": 1
    }
  ],
  "OfferPdfs": [
    {
      "FileName": "teklif.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Offline_offerBatchPremium_example
using RestSharp;

var client = new RestClient("https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"ProductId\": 2321,\n  \"Message\": \"Toplu teklif primleri iletilmiştir.\",\n  \"Premiums\": [\n    {\n      \"InsuranceCompanyProposalNumber\": \"SKT2026001\",\n      \"InsuranceCompanyPolicyNumber\": null,\n      \"InsuranceCompanyEndorsementNumber\": null,\n      \"RenewalNumber\": 0,\n      \"GrossPremium\": 5000,\n      \"NetPremium\": 4500,\n      \"Commision\": 500,\n      \"PaymentOptionType\": 1,\n      \"CurrencyType\": 1\n    }\n  ],\n  \"OfferPdfs\": [\n    {\n      \"FileName\": \"teklif.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Offline_offerBatchPremium_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "ProductId": 2321,
  "Message": "Toplu teklif primleri iletilmiştir.",
  "Premiums": [
    [
      "InsuranceCompanyProposalNumber": "SKT2026001",
      "InsuranceCompanyPolicyNumber": ,
      "InsuranceCompanyEndorsementNumber": ,
      "RenewalNumber": 0,
      "GrossPremium": 5000,
      "NetPremium": 4500,
      "Commision": 500,
      "PaymentOptionType": 1,
      "CurrencyType": 1
    ]
  ],
  "OfferPdfs": [
    [
      "FileName": "teklif.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Premiums/batch")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```