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

# Firmaya yeni banka bağlantısı ekle

> Bir firma aynı banka için birden fazla bağımsız bağlantı oluşturabilir. Para birimi ve fiziksel hesaplar provider setup sırasında keşfedilir ve subAccounts alanında döner. Demo ve production bağlantıları ayrı credential modları kullanır.



## OpenAPI

````yaml /openapi/openapi.yaml post /banks/accounts
openapi: 3.1.0
info:
  title: Tahsil API
  version: 1.0.0
  description: >-
    Tahsil banka bağlantıları, provider senkronizasyonu, değiştirilemez
    hareketler, zamanlamalar ve hareket otomasyonu için tenant-scoped public API
    sözleşmesi.
servers:
  - url: https://api.tahsil.dev
    description: Production
security:
  - apiKeyAuth: []
    apiSecretAuth: []
tags:
  - name: Sistem - Sağlık
    description: Servis canlılığı ve bağımlılık hazır olma kontrolleri.
  - name: Banka - Bağlantılar
    description: Banka bağlantısı, credential, setup, sync, health ve kullanım işlemleri.
  - name: Banka - Hareketler
    description: >-
      Provider senkronizasyonuyla oluşan değiştirilemez banka hareketleri ve CSV
      dışa aktarımı.
  - name: Banka - Otomasyon
    description: Hareket atamaları, kurallar, preview ve backfill çalışmaları.
  - name: Banka - Zamanlamalar
    description: Banka sorgularının zamanlama ve çalışma durumu yönetimi.
  - name: Banka - Analitik
    description: Tenant kapsamlı dashboard sorgu kataloğu ve analitik sonuçları.
  - name: Denetim - Connector Logları
    description: Maskelenmiş banka connector istek ve yanıt kayıtları.
paths:
  /banks/accounts:
    post:
      tags:
        - Banka - Bağlantılar
      summary: Firmaya yeni banka bağlantısı ekle
      description: >-
        Bir firma aynı banka için birden fazla bağımsız bağlantı oluşturabilir.
        Para birimi ve fiziksel hesaplar provider setup sırasında keşfedilir ve
        subAccounts alanında döner. Demo ve production bağlantıları ayrı
        credential modları kullanır.
      operationId: postBanksAccounts
      parameters:
        - name: x-company-id
          in: header
          required: true
          schema:
            type: string
          description: Yazma işleminin hedef firma kimliği.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BankAccountCreate'
      responses:
        '200':
          $ref: '#/components/responses/BankAccountResponse'
        '402':
          $ref: '#/components/responses/ErrorResponse'
        '409':
          $ref: '#/components/responses/ErrorResponse'
components:
  schemas:
    BankAccountCreate:
      type: object
      required:
        - bankCode
        - title
      example:
        bankCode: akbank
        title: Mavi Rota ana tahsilat hesabı
        environment: production
      properties:
        bankCode:
          type: string
        title:
          type: string
        environment:
          type: string
          enum:
            - demo
            - production
          default: production
          description: >-
            Değiştirilemez bağlantı modu. Demo bağlantıları yalnız server
            tarafından sınırlandırılmış demo credential değerlerini kabul eder.
    BankAccount:
      type: object
      required:
        - id
        - companies
        - status
        - bankCode
        - environment
        - subAccounts
      properties:
        id:
          type: string
          description: MongoDB kaynak kimliği.
        companies:
          type: string
          description: Bağlantının ait olduğu firma kimliği.
        status:
          type: boolean
        bankCode:
          type: string
          example: akbank
        environment:
          type: string
          enum:
            - demo
            - production
        title:
          type:
            - string
            - 'null'
          example: Ana Akbank Bağlantısı
        lastProviderSetupAt:
          type:
            - string
            - 'null'
          format: date-time
        lastProviderSyncAt:
          type:
            - string
            - 'null'
          format: date-time
        syncHealth:
          $ref: '#/components/schemas/BankSyncHealth'
        subAccounts:
          type: array
          items:
            $ref: '#/components/schemas/BankSubAccount'
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
        updatedAt:
          type:
            - string
            - 'null'
          format: date-time
      additionalProperties: false
    BankSyncHealth:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - never
            - running
            - healthy
            - error
        lastAttemptAt:
          type:
            - string
            - 'null'
          format: date-time
        lastSuccessAt:
          type:
            - string
            - 'null'
          format: date-time
        lastErrorAt:
          type:
            - string
            - 'null'
          format: date-time
        lastErrorCode:
          type:
            - string
            - 'null'
        lastErrorMessage:
          type:
            - string
            - 'null'
        lastDurationMs:
          type:
            - integer
            - 'null'
          minimum: 0
        lastTriggerType:
          type:
            - string
            - 'null'
          enum:
            - manual
            - cron
            - retry
            - null
        lastResult:
          $ref: '#/components/schemas/BankSyncResultSummary'
      additionalProperties: false
    BankSubAccount:
      type: object
      required:
        - subAccountKey
        - bankCode
        - currency
        - balance
      properties:
        id:
          type: string
          description: MongoDB kaynak kimliği.
        subAccountKey:
          type: string
          readOnly: true
          description: Provider hesabından üretilen kararlı alt hesap kimliği.
        providerAccountId:
          type:
            - string
            - 'null'
        bankCode:
          type:
            - string
            - 'null'
        customerNo:
          type:
            - string
            - 'null'
        accountNo:
          type:
            - string
            - 'null'
        iban:
          type:
            - string
            - 'null'
        accountType:
          type:
            - string
            - 'null'
        accountName:
          type:
            - string
            - 'null'
        branchId: {}
        branchName:
          type:
            - string
            - 'null'
        currency:
          type: string
          example: TRY
        balance:
          type: number
        blockedBalance:
          type: number
        availableBalance:
          type: number
        openingDate:
          type:
            - string
            - 'null'
          format: date-time
        lastTransactionDate:
          type:
            - string
            - 'null'
          format: date-time
        createdAt:
          type:
            - string
            - 'null'
          format: date-time
        updatedAt:
          type:
            - string
            - 'null'
          format: date-time
      additionalProperties: false
    BankSyncResultSummary:
      type: object
      properties:
        fetched:
          type:
            - integer
            - 'null'
          minimum: 0
        inserted:
          type:
            - integer
            - 'null'
          minimum: 0
        duplicates:
          type:
            - integer
            - 'null'
          minimum: 0
      additionalProperties: false
  responses:
    BankAccountResponse:
      description: Banka bağlantısı.
      content:
        application/json:
          schema:
            type: object
            required:
              - status
              - result
            properties:
              status:
                type: boolean
                const: true
              result:
                $ref: '#/components/schemas/BankAccount'
            additionalProperties: false
    ErrorResponse:
      description: İstek başarısız oldu.
      content:
        application/json:
          schema:
            type: object
            required:
              - status
            properties:
              status:
                type: boolean
                const: false
              code:
                type: string
                description: >-
                  Kararlı hata kodu; kodlanmış domain ve güvenlik hatalarında
                  döner.
              message:
                type: string
                description: >-
                  İnsan tarafından okunabilir hata açıklaması; mevcutsa
                  entegrasyon kararı için kullanılmamalıdır.
              meta:
                type: object
                additionalProperties: true
              result:
                type: array
                deprecated: true
                description: Legacy Joi doğrulama hatalarında dönen alan listesi.
                items:
                  type: object
                  properties:
                    type:
                      type: string
                    joiType:
                      type: string
                    path:
                      type:
                        - string
                        - number
                    label:
                      type: string
                  additionalProperties: false
              description:
                type: string
            additionalProperties: false
          example:
            status: false
            code: TRANSACTION_AMOUNT_RANGE_INVALID
            message: minAmount, maxAmount değerinden büyük olamaz.
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: Tenant admin tarafından oluşturulan API anahtarının kimliği.
    apiSecretAuth:
      type: apiKey
      in: header
      name: x-api-secret
      description: >-
        Yalnız oluşturma anında gösterilen API anahtarı secret değeri. x-api-key
        ile aynı istekte gönderilir.

````