> ## Documentation Index
> Fetch the complete documentation index at: https://docs.muhasip.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# Banka fatura otomasyonu kaydet

> id gönderilmezse otomasyon taslağı oluşturur; gönderilirse ilgili kaydı günceller.

## Ne yapar?

id gönderilmezse otomasyon taslağı oluşturur; gönderilirse ilgili kaydı günceller. Çalışmakta olan otomasyon için 409 döner. Tek invoice aksiyonu desteklenir. Etkinleştirme için en az bir TRY banka hesabı, etkin fatura bağlantısı, seri, belge şablonu, alıcı adresi ve toplamı yüzde 100 olan satır oranları gerekir. settings ve actions gönderildiğinde mevcut değerleri bütünüyle değiştirir. Kaydetme isteği otomasyonu çalıştırmaz; çalıştırma ve sonuç takibi ayrı işlemlerdir.

## Ön koşullar ve izin

Etkin API anahtarı ve `muhasip:bank:write` izni gerekir.

İlişkili kayıtlar aynı firmaya ait olmalıdır. Erişim ayarları için [kimlik ve izinler](/baslangic/kimlik-ve-izinler) rehberini inceleyin.

[İstek ve cevap şemalarını indirin](/openapi.json).

## İstek örnekleri

Örnekler temsilîdir. Kimlikleri, belge tarihlerini ve iş verisini kendi yetkili kayıtlarınızla değiştirin. Node.js örnekleri **Node.js 20 veya üzeri** içindir; PHP örnekleri cURL uzantısını kullanır. Hiçbiri otomatik tekrar yapmaz.

<CodeGroup>
  ```bash cURL theme={null}
  curl --request PATCH 'https://api.muhasip.pro/apps/bank/ws/automations' \
    --user "$MUHASIP_API_USER_ID:$MUHASIP_API_SECRET" \
    --header 'Accept: */*' \
    --header 'Content-Type: application/json' \
    --data-binary @- <<'JSON'
  {
    "title": "Banka hareketinden fatura",
    "status": "draft",
    "template": "bankInvoice",
    "integration": "bank",
    "type": "integration",
    "settings": {
      "accounts": []
    },
    "actions": [
      {
        "type": "integration",
        "integration": "invoice",
        "settings": {}
      }
    ]
  }
  JSON
  ```

  ```php PHP theme={null}
  <?php
  $apiUserId = getenv('MUHASIP_API_USER_ID');
  $secretKey = getenv('MUHASIP_API_SECRET');
  if (!$apiUserId || !$secretKey) {
      throw new RuntimeException('API kimlik bilgileri eksik.');
  }
  $headers = ['Accept: */*', 'Content-Type: application/json'];
  $body = <<<'JSON'
  {
    "title": "Banka hareketinden fatura",
    "status": "draft",
    "template": "bankInvoice",
    "integration": "bank",
    "type": "integration",
    "settings": {
      "accounts": []
    },
    "actions": [
      {
        "type": "integration",
        "integration": "invoice",
        "settings": {}
      }
    ]
  }
  JSON;
  $handle = curl_init('https://api.muhasip.pro/apps/bank/ws/automations');
  curl_setopt_array($handle, [
      CURLOPT_CUSTOMREQUEST => 'PATCH',
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_FOLLOWLOCATION => false,
      CURLOPT_HTTPHEADER => $headers,
      CURLOPT_CONNECTTIMEOUT => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
      CURLOPT_USERPWD => $apiUserId . ':' . $secretKey,
      CURLOPT_POSTFIELDS => $body,
  ]);
  $response = curl_exec($handle);
  $httpStatus = curl_getinfo($handle, CURLINFO_RESPONSE_CODE);
  curl_close($handle);
  if ($response === false) {
      throw new RuntimeException('Bağlantı tamamlanamadı; mali işlemi otomatik tekrarlamayın.');
  }
  if ($httpStatus < 200 || $httpStatus >= 300) {
      throw new RuntimeException('HTTP ' . $httpStatus . '; kaynak hata açıklamasını değerlendirin.');
  }
  // $response gövdesini bu işlemin cevap biçimine göre işleyin; ham cevabı loglamayın.
  echo 'HTTP ' . $httpStatus . PHP_EOL;
  ```

  ```javascript Node.js theme={null}
  async function main() {
    const apiUserId = process.env.MUHASIP_API_USER_ID
    const secretKey = process.env.MUHASIP_API_SECRET
    if (!apiUserId || !secretKey) throw new Error("API kimlik bilgileri eksik.")
    const response = await fetch("https://api.muhasip.pro/apps/bank/ws/automations", {
      method: "PATCH",
      redirect: "manual",
      headers: {
        Accept: "*/*",
        Authorization: "Basic " + Buffer.from(`${apiUserId}:${secretKey}`).toString("base64"),
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        title: "Banka hareketinden fatura",
        status: "draft",
        template: "bankInvoice",
        integration: "bank",
        type: "integration",
        settings: {
          accounts: []
        },
        actions: [
          {
            type: "integration",
            integration: "invoice",
            settings: {}
          }
        ]
      }),
      signal: AbortSignal.timeout(30000)
    })
    const data = await response.arrayBuffer()
    if (!response.ok) throw new Error(`HTTP ${response.status}; kaynak hata açıklamasını değerlendirin.`)
    // data gövdesini bu işlemin cevap biçimine göre işleyin; ham cevabı loglamayın.
    console.log("HTTP", response.status)
  }

  main().catch(() => {
    console.error("İstek tamamlanamadı; mali işlemi otomatik tekrarlamayın.")
    process.exitCode = 1
  })
  ```
</CodeGroup>

## Cevabı değerlendirin

Önce HTTP durumunu, ardından bu kaynağın `status` ve sonuç alanlarını değerlendirin. Bütün uçlar aynı sonuç zarfını veya oluşturma için `201` kodunu kullanmaz.

Temsilî başarılı cevap; gerçek hizmet çağrısından alınmamıştır:

```json theme={null}
{
  "status": true,
  "result": {
    "acknowledged": true,
    "matchedCount": 0,
    "modifiedCount": 0,
    "upsertedCount": 1,
    "upsertedId": "507f1f77bcf86cd799439011"
  }
}
```

## Hata durumunda

| HTTP | Bu işlemde anlamı | İzlenecek adım |
| - | - | - |
| 400 | İstek alanları veya kimlik geçersiz. | Alan adını, türünü ve zorunluluğunu kontrol edin; değişmeyen hatalı isteği tekrar göndermeyin. |
| 401 | API kimliği/parolası, erişim süresi veya firma doğrulanamadı. | Anahtar kimliğini, gizli değeri, erişim süresini ve firma erişimini kontrol edin. |
| 403 | API izni, IP kısıtı veya kayıt erişimi uygun değil. | Anahtarın izinlerini, IP kısıtını ve kayıt kimliğini kontrol edin. |
| 404 | Kayıt bulunamadı veya bu erişim bağlamında kullanılamıyor. | Hedef kimliğini ve aynı firmaya ait olduğunu doğrulayın; bu cevap başka firmanın kaydını açmaz. |
| 409 | Çalışan, aktif olmayan veya durumu değişmiş otomasyon. | Mevcut işlem ve hedefi inceleyin. Kilit veya içerik çatışmasını yeni anahtarla aşmaya çalışmayın. |
| 429 | Ortak istek sınırı aşıldı; sayısal status alanı kullanılır. | Varsa Retry-After bilgisini değerlendirin. Mali çağrıyı otomatik yeniden göndermeyin. |
| 500 | İşlem gerçekleştirilemedi. | İşlem sonucunu inceleyin; bağlantı/hata oluşması mali etkinin hiç başlamadığını kanıtlamaz. |

Ağ kesintisi, zaman aşımı veya JSON olmayan cevap mali etkinin oluşmadığını kanıtlamaz. Ham istek/cevapları genel loglara yazmayın. [Hata yönetimi](/rehberler/hata-yonetimi)

## Sonraki adım

İlgili liste veya detay çağrısıyla kaydı ve bağlı iş sonucunu doğrulayın. Fiziksel silme, arşiv ve mali iptali ayrı değerlendirin.

[Kaynak akışı](/rehberler/kaynaklar/banka-otomasyonlari) · [İşlem takibi](/rehberler/islem-takibi) · [Kapsam ve sınırlamalar](/rehberler/kapsam-ve-sinirlamalar)


## OpenAPI

````yaml openapi.json PATCH /apps/bank/ws/automations
openapi: 3.0.3
info:
  title: Muhasip API
  version: 2026-10-18.1
  description: >-
    Fatura, banka, POS ve tahsilat, GİB e-Arşiv, pazaryeri, online işlemler,
    görevler, ajanda ve takvim entegrasyonları. İşlem alanları, izinler, istek
    ve cevap örnekleri ile hata yönetimi.
servers:
  - url: https://api.muhasip.pro
    description: Muhasip API
security:
  - BasicAuth: []
tags:
  - name: Uygulamalar
  - name: Görev yönetimi
  - name: Ajanda ve takvim
  - name: Fatura
    description: Fatura bağlantısı, belge işlemleri ve muhasebeye aktarım.
  - name: Banka
    description: >-
      Banka hesapları, hareketler, mahsup ve mevcut çalışma alanı alt
      kaynakları.
  - name: POS ve tahsilat
    description: POS hesapları, komisyonlar ve tahsilat bağlantıları.
  - name: GİB e-Arşiv
    description: GİB hesabı, sorgu, taslak ve SMS imzalama.
  - name: Pazaryeri
    description: Trendyol bağlantısı ve sipariş aktarımı.
  - name: Online işlemler
    description: Online işlem ekranı yapılandırması.
  - name: İşlem takibi
    description: Mali işlem durumu ve tekrar çağrı makbuzları.
paths:
  /apps/bank/ws/automations:
    patch:
      tags:
        - Banka
      summary: Banka fatura otomasyonu kaydet
      description: >-
        id gönderilmezse otomasyon taslağı oluşturur; gönderilirse ilgili kaydı
        günceller. Çalışmakta olan otomasyon için 409 döner. Tek invoice
        aksiyonu desteklenir. Etkinleştirme için en az bir TRY banka hesabı,
        etkin fatura bağlantısı, seri, belge şablonu, alıcı adresi ve toplamı
        yüzde 100 olan satır oranları gerekir. settings ve actions
        gönderildiğinde mevcut değerleri bütünüyle değiştirir. Kaydetme isteği
        otomasyonu çalıştırmaz; çalıştırma ve sonuç takibi ayrı işlemlerdir.
      operationId: muhasipPatchAppsBankWsAutomations
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FinanceBankAutomationWrite'
            example:
              title: Banka hareketinden fatura
              status: draft
              template: bankInvoice
              integration: bank
              type: integration
              settings:
                accounts: []
              actions:
                - type: integration
                  integration: invoice
                  settings: {}
      responses:
        '200':
          description: İşlem cevabı; örnek temsilîdir.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                  result:
                    $ref: '#/components/schemas/FinanceWriteResult'
                required:
                  - status
                  - result
              example:
                status: true
                result:
                  acknowledged: true
                  matchedCount: 0
                  modifiedCount: 0
                  upsertedCount: 1
                  upsertedId: 507f1f77bcf86cd799439011
        '400':
          description: İstek alanları veya kimlik geçersiz.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: false
                message: İstek alanları veya kimlik geçersiz.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          description: Çalışan, aktif olmayan veya durumu değişmiş otomasyon.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: false
                message: Çalışan, aktif olmayan veya durumu değişmiş otomasyon.
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: İşlem gerçekleştirilemedi.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                status: false
                message: İşlem gerçekleştirilemedi.
components:
  schemas:
    FinanceBankAutomationWrite:
      type: object
      properties:
        id:
          type: string
          pattern: ^[a-fA-F0-9]{24}$
          description: 24 karakterli Muhasip kayıt kimliği.
        title:
          type: string
          minLength: 1
          maxLength: 300
        description:
          type: string
          maxLength: 5000
          nullable: true
        status:
          type: string
          enum:
            - active
            - draft
            - archive
          description: Yeni kayıtta verilmezse draft.
        template:
          type: string
          enum:
            - bankInvoice
          description: Yeni kayıtta bankInvoice.
        type:
          type: string
          enum:
            - integration
            - manuel
          description: Yeni kayıtta integration.
        integration:
          type: string
          enum:
            - bank
          description: Yeni kayıtta bank.
        settings:
          $ref: '#/components/schemas/FinanceBankAutomationSettings'
        actions:
          type: array
          minItems: 1
          maxItems: 1
          items:
            $ref: '#/components/schemas/FinanceBankAutomationAction'
      required:
        - title
      additionalProperties: false
      description: >-
        id yoksa yeni taslak, varsa firma kaydı güncellenir; yeni kayıtta
        actions zorunludur. Gönderilen settings/actions nesneleri bütün olarak
        değiştirilir. Aktif durumda hesap, tam fatura ayarları ve oran toplamı
        100 gerekir.
    FinanceWriteResult:
      type: object
      properties:
        acknowledged:
          type: boolean
        matchedCount:
          type: integer
        modifiedCount:
          type: integer
        upsertedCount:
          type: integer
        upsertedId:
          type: string
          nullable: true
        deletedCount:
          type: integer
      additionalProperties: true
      description: >-
        İşleme göre yalnız ilgili sayımlar bulunur. matchedCount eşleşen,
        modifiedCount değişen, deletedCount silinen kayıt sayısıdır.
    Error:
      type: object
      properties:
        status:
          type: boolean
        code:
          type: string
        message:
          type: string
        description:
          type: string
        retryable:
          type: boolean
        reviewRequired:
          type: boolean
        operationId:
          type: string
      required:
        - status
      additionalProperties: true
    FinanceBankAutomationSettings:
      type: object
      properties:
        accounts:
          type: array
          maxItems: 250
          uniqueItems: true
          items:
            type: string
            pattern: ^[a-fA-F0-9]{24}$
            description: 24 karakterli Muhasip kayıt kimliği.
          description: Firma içindeki arşivlenmemiş TRY banka hesapları.
        hour:
          type: string
          pattern: ^(?:[01][0-9]|2[0-3]):[0-5][0-9]$
          description: >-
            Saat bilgisi; API otomatik zamanlayıcı çalıştırma güvencesi vermez.
            Boş metin de kabul edilir.
          nullable: true
        operationType:
          type: string
          enum:
            - incoming
            - outgoing
          nullable: true
        filterStatus:
          type: string
          enum:
            - '0'
            - '1'
            - '2'
          description: Metin olarak gönderin; sayısal 0 kabul edilmez.
          nullable: true
        setStatus:
          type: boolean
        negativeWords:
          type: array
          maxItems: 100
          items:
            type: string
            maxLength: 300
          description: Düz metin sözcükleri; düzenli ifade metakarakterleri kabul edilmez.
      additionalProperties: false
    FinanceBankAutomationAction:
      type: object
      properties:
        id:
          type: string
          pattern: ^[a-fA-F0-9]{24}$
          description: 24 karakterli Muhasip kayıt kimliği.
        type:
          type: string
          enum:
            - integration
        integration:
          type: string
          enum:
            - invoice
        order:
          type: integer
          minimum: 0
        settings:
          $ref: '#/components/schemas/FinanceBankAutomationInvoiceSettings'
      required:
        - type
        - integration
        - settings
      additionalProperties: false
    RateLimitError:
      type: object
      properties:
        status:
          type: integer
          enum:
            - 429
        error:
          type: string
        message:
          type: string
      required:
        - status
        - error
        - message
    FinanceBankAutomationInvoiceSettings:
      type: object
      properties:
        lines:
          type: array
          minItems: 1
          maxItems: 100
          items:
            $ref: '#/components/schemas/FinanceBankAutomationLine'
        series:
          type: string
          maxLength: 30
        templates:
          type: string
          format: uuid
        eSeries:
          type: string
          maxLength: 30
        eTemplates:
          type: string
          format: uuid
        nameSurname:
          type: string
          maxLength: 300
        address:
          type: string
          maxLength: 1000
        cities:
          type: string
          maxLength: 100
        states:
          type: string
          maxLength: 100
        notes:
          type: array
          maxItems: 100
          items:
            type: string
            maxLength: 1000
      additionalProperties: false
    FinanceBankAutomationLine:
      type: object
      properties:
        lineName:
          type: string
          minLength: 1
          maxLength: 300
        ratio:
          type: number
          minimum: 0
          exclusiveMinimum: true
          maximum: 100
        KDV:
          type: number
          minimum: 0
          maximum: 100
        quantity:
          type: number
          minimum: 0
          exclusiveMinimum: true
          default: 1
        unitType:
          type: string
          minLength: 2
          maxLength: 10
      required:
        - lineName
        - ratio
        - KDV
        - unitType
      additionalProperties: false
  responses:
    Unauthorized:
      description: API kimliği/parolası, erişim süresi veya firma doğrulanamadı.
      headers:
        WWW-Authenticate:
          schema:
            type: string
          description: Basic realm="Muhasip API", charset="UTF-8"
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: false
            code: UNAUTHORIZED
            message: API kimlik bilgileri doğrulanamadı.
    Forbidden:
      description: Ürün, IP, modül izni veya kaynak kapsamı uygun değil.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: false
            message: Ürün, IP, modül izni veya kaynak kapsamı uygun değil.
    NotFound:
      description: Kayıt bulunamadı veya bu erişim bağlamında kullanılamıyor.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            status: false
    RateLimited:
      description: Ortak istek sınırı aşıldı; sayısal status alanı kullanılır.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          example:
            status: 429
            error: Too Many Requests
            message: Rate limit exceeded. Please try again later.
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
      description: >-
        Kullanıcı adı apiUserId, parola secretKey. Aktif ve süresi geçmemiş API
        kullanıcısı ve uygun firma gerekir.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.