> For the complete documentation index, see [llms.txt](https://docs.kangal.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kangal.dev/tr/sdklar/security-and-errors.md).

# Authentication, retry ve hatalar

## Authentication

Üretilmiş client'lar iki runtime credential destekler:

* API key: `X-API-Key: <value>`
* Bearer token: `Authorization: Bearer <value>`

Yalnızca gateway policy'nin gerektirdiği mekanizmayı yapılandırın. Credential değerini üretilmiş package, source repository, mobil uygulama veya secret koruyamayan browser bundle içine gömmeyin.

## Scope header'ları

Yayınlanmış tenant ve gateway değerleri varsayılan header olarak üretilir:

* `X-Tenant-ID`
* `X-Gateway-ID`

Client-wide ve request-level header'lar varsayılanları değiştirebilir. Authentication header'ları en son uygulanır. Scope override işlemlerini ayrıcalıklı kabul edin.

## Timeout ve retry davranışı

Her hedef varsayılan olarak deneme başına 30 saniye timeout, en fazla iki retry (toplam üç deneme) ve 200 ms ile başlayan üstel gecikme kullanır. Yerleşik retry sözleşmesi hedefe göre şöyledir:

| Hedef      | Retry sınırına kadar yeniden denenen hatalar                                                                                |
| ---------- | --------------------------------------------------------------------------------------------------------------------------- |
| TypeScript | Çağıran tarafından iptal edilen istekler dışında Fetch ve deneme timeout hataları; `408`, `429`, `500`, `502`, `503`, `504` |
| Python     | `URLError` transport hataları; `408`, `429`, `500`, `502`, `503`, `504`                                                     |
| Go         | Context etkin kaldığı sürece HTTP istek transport hataları; `408`, `429` ve tüm `5xx` yanıtları                             |
| Java       | `IOException` transport/timeout hataları; `408`, `429` ve tüm `5xx` yanıtları                                               |
| C#         | Çağıranın iptali dışında `HttpRequestException` ve deneme timeout iptali; `408`, `429` ve tüm `5xx` yanıtları               |
| PHP        | Status `0` olarak bildirilen cURL transport hataları; `408`, `429`, `500`, `502`, `503`, `504`                              |

Yerleşik retry davranışı HTTP metoduyla sınırlandırılmaz. Non-idempotent iş işlemleri için retry sayısını sıfır yapın veya uygulama düzeyinde idempotency stratejisi ve genel deadline kullanın.

## API hataları

Her client HTTP status ve response body taşıyan dile uygun API error sunar:

| Status | Önerilen işlem                                                           |
| ------ | ------------------------------------------------------------------------ |
| 401    | Credential'ı yenileyin veya değiştirin.                                  |
| 403    | Consumer, scope ve policy yetkilerini kontrol edin.                      |
| 404    | Base URL, route ve path parameter değerlerini doğrulayın.                |
| 408    | Application deadline'a uyun; yalnızca güvenliyse retry yapın.            |
| 429    | Backoff uygulayın; uygulama `Retry-After` değerini okuyup uygulayabilir. |
| 5xx    | Request ID'yi Kangal telemetry ile eşleştirip retry policy'yi inceleyin. |

Request ID ve temizlenmiş hata metadata'sını loglayın. Authorization header, API key, secret içeren request body veya maskelenmemiş kişisel veriyi loglamayın.

Üretilmiş client'lar şu anda kendi exponential retry gecikmesini kullanır; `Retry-After` değerini otomatik olarak yorumlamaz.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kangal.dev/tr/sdklar/security-and-errors.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
