> 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.

# Create Message

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

## İşe Mesaj Gönder

### Endpoint Bilgileri

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

***

Sigorta şirketinin, bir iş üzerinden platformdaki ilgili kullanıcıya **mesaj** ve isteğe bağlı **ek dosya** iletmesi için kullanılır.

Başarılı istekte işe `Mesaj` (`Message`) tipinde aksiyon kaydı eklenir, aksiyon platforma iletilir, varsa ek dosyalar kaydedilir ve acentede mailing kapalı değilse platform kullanıcısına bilgilendirme maili gönderilir.

> Mesaj işin aşamasını **değiştirmez** ve işin **her aşamasında** gönderilebilir; kaynak aşama kısıtı yoktur.

***

### Route Parametreleri

| Parametre | Tip       | Zorunlu | Açıklama                              |
| --------- | --------- | ------- | ------------------------------------- |
| `jobId`   | `integer` | Evet    | Mesajın gönderileceği işin Id bilgisi |

***

***

### İstek Modeli — `CreateMessageRequest`

| Alan          | Tip             | Zorunlu | Açıklama                  | Doğrulama                                                                                           |
| ------------- | --------------- | ------- | ------------------------- | --------------------------------------------------------------------------------------------------- |
| `Message`     | `string`        | Evet    | İletilecek mesaj metni    | Boş olamaz: `"Message is required."`  Maks. 500 karakter: `"Message cannot exceed 500 characters."` |
| `Attachments` | `FileRequest[]` | Hayır   | Mesaja eklenecek dosyalar | Gönderilirse her eleman için `FileRequest` doğrulamaları uygulanır                                  |

#### Ek Dosya — `FileRequest`

| Alan            | Tip      | Zorunlu | Açıklama                                             | Doğrulama                                                                                                                                               |
| --------------- | -------- | ------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `FileName`      | `string` | Evet\*  | Dosya adı                                            | Boş olamaz: `"Attachment FileName must not be empty."`                                                                                                  |
| `Base64Content` | `string` | Evet\*  | Base64 kodlu dosya içeriği                           | Boş olamaz: `"Attachment Base64Content must not be empty."`  Geçerli base64 olmalı: `"Attachment Base64Content must be a valid base64 encoded string."` |
| `ContentType`   | `string` | Hayır   | MIME türü. Dosyanın uzantı bilgisi olarak kaydedilir | Doğrulanmaz                                                                                                                                             |

> \* Bu alanlar yalnızca `Attachments` dizisi gönderildiğinde doğrulanır. Dosya türü kısıtı yoktur; uzantı ve içerik PDF olmak zorunda değildir. Ekler `Diğer` (`Other`) doküman tipiyle kaydedilir.

***

### İş Kuralları

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

1. Mesajı karşılayacak platform kullanıcısı bulunmalıdır:

   * İş `Prim Reddedildi` aşamasındaysa → son `Prim İsteği`ni gönderen kullanıcı

   * İş `Toplu Prim Reddedildi` aşamasındaysa → son `Toplu Prim İsteği`ni gönderen kullanıcı

   * Diğer tüm aşamalarda → işteki son platform kullanıcısı aksiyonunu gönderen kullanıcı

2. Mesajı gönderen kullanıcı sistemde kayıtlı olmalıdır.

3. Aksiyon platforma iletilebilmelidir.

> **Geri alma davranışı:** 3. kural başarısız olursa oluşturulan aksiyon kaydı silinir; ek dosyalar kaydedilmez ve mail gönderilmez.

***

### 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": "Message",
      "Message": "Message is required."
    },
    {
      "Field": "Attachments[0].Base64Content",
      "Message": "Attachment Base64Content must be a valid base64 encoded string."
    }
  ]
}

```

***

#### `400 Bad Request` — İstek Gövdesi Boş

İstek gövdesi boş, yalnızca boşluk veya `null` gönderildiğinde döner. Yanıt standart zarf formatında değildir; `text/plain` olarak yalnızca hata metnini içerir.

```text
A non-empty request body is required.

```

***

#### `400 Bad Request` — Geçersiz JSON

İstek gövdesi geçerli bir JSON olmadığında döner. Yanıt `text/plain` olarak JSON ayrıştırıcısının hata metnini içerir; metin, hatanın konumuna göre değişir.

```text
Unexpected character encountered while parsing value: a. Path '', line 0, position 0.

```

***

#### `415 Unsupported Media Type` — Content-Type Eksik

`Content-Type: application/json` header'ı gönderilmediğinde döner.

```json
{
  "type": "https://tools.ietf.org/html/rfc7231#section-6.5.13",
  "title": "Unsupported Media Type",
  "status": 415,
  "traceId": "00-7f3f31cf39efddb07e9cce2ee0f1fb89-4f59c837bd4e4cb9-00"
}

```

***

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

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

```json
{
  "Status": false,
  "Code": "OfflineMessage.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": "OfflineMessage.UserNotFound",
  "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.** Süresi dolmuş token için yanıtta `Token-Expired: true` header'ı bulunur.

***

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

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

```json
{
  "Status": false,
  "Code": "OfflineMessage.JobNotFound",
  "Message": "Job 100931 not found.",
  "Response": null
}

```

***

#### `500 Internal Server Error` — State Geçişi Başarısız

Mesajı karşılayacak platform kullanıcısı bulunamazsa, gönderen kullanıcı sistemde kayıtlı değilse veya aksiyon platforma iletilemezse döner. `Message` alanı iş kuralı hatasının detayını içerir.

```json
{
  "Status": false,
  "Code": "OfflineMessage.StateTransitionFailed",
  "Message": "Message state transition failed: Aksiyon bilgileri platforma iletilemedi! Hata Mesajı: Timeout",
  "Response": null
}

```

> Aksiyon platforma iletilemediğinde oluşturulan aksiyon silinir; işte kalıcı bir değişiklik olmaz.

***

#### `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
}

```

***

#### `500 Internal Server Error` — İşlenmeyen Hata

State geçişinden önce beklenmeyen bir hata oluştuğunda (örn. iş okunurken veritabanı hatası) döner. **Gövde boştur.**

Reference: https://docs.insurgateway.com/insurgateway-api/offline/create-message

## 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

### 415 Unsupported Media Type Error

Unsupported Media Type

### 500 Internal Server Error

Internal Server Error

## Examples

### Success Response

**Request**

```json
{
  "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
  "Attachments": [
    {
      "FileName": "ruhsat.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    }
  ]
}
```

**Response**

```json
""
```

**SDK Code**

```python Success Response
import requests

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

payload = {
    "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
    "Attachments": [
        {
            "FileName": "ruhsat.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 Success Response
const url = 'https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Messages';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"Message":"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.","Attachments":[{"FileName":"ruhsat.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 Success Response
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.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 Success Response
require 'uri'
require 'net/http'

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

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  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}"

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

```java Success Response
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/Messages")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Messages', [
  'body' => '{
  "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
  "Attachments": [
    {
      "FileName": "ruhsat.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Success Response
using RestSharp;

var client = new RestClient("https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Success Response
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
  "Attachments": [
    [
      "FileName": "ruhsat.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/Messages")! 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()
```

### Success Response - Without Attachment

**Request**

```json
{
  "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
  "Attachments": [
    {
      "FileName": "ruhsat.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    }
  ]
}
```

**Response**

```json
""
```

**SDK Code**

```python Success Response - Without Attachment
import requests

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

payload = {
    "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
    "Attachments": [
        {
            "FileName": "ruhsat.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 Success Response - Without Attachment
const url = 'https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Messages';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"Message":"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.","Attachments":[{"FileName":"ruhsat.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 Success Response - Without Attachment
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.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 Success Response - Without Attachment
require 'uri'
require 'net/http'

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

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  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}"

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

```java Success Response - Without Attachment
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/Messages")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}")
  .asString();
```

```php Success Response - Without Attachment
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Messages', [
  'body' => '{
  "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
  "Attachments": [
    {
      "FileName": "ruhsat.pdf",
      "ContentType": "application/pdf",
      "Base64Content": "JVBERi0xLjAK"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Success Response - Without Attachment
using RestSharp;

var client = new RestClient("https://testgatewayapi.insurapps.net/api/Offline/jobs/1/Messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"Message\": \"Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.\",\n  \"Attachments\": [\n    {\n      \"FileName\": \"ruhsat.pdf\",\n      \"ContentType\": \"application/pdf\",\n      \"Base64Content\": \"JVBERi0xLjAK\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Success Response - Without Attachment
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "Message": "Talep edilen ruhsat fotokopisi ve hasarsızlık belgesi ektedir.",
  "Attachments": [
    [
      "FileName": "ruhsat.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/Messages")! 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()
```