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

# Upload bank statements

> Uploading bank statements is a three-step flow:
  1. Request upload slots with `PUT /documents/bank-statements/presign`,
     providing each PDF file name (and optional external identifier).
     The response includes `presigned_url` and `path` values for every
     requested file.
  2. Upload the PDF content to every `presigned_url` using an HTTP `PUT`
     request with `Content-Type: application/octet-stream`.
  3. Call this endpoint with the JSON payload returned in step one,
     echoing the `path` (and optional `external_document_id`) for every
     uploaded file so Teal can extract and store the bank statement data.
The `path` values you submit must match the ones returned by the presign
step. Any files that failed validation or extraction are reported in the
`bank_statement_errors` array.




## OpenAPI

````yaml PUT /documents/bank-statements
openapi: 3.0.1
info:
  title: Payroll API
  description: A full flagged payroll api provided by Teal
  version: 1.0.0
servers:
  - url: https://api.sandbox.goteal.co
    description: Sandbox server for experiments
  - url: https://api.goteal.co
    description: Production server
security:
  - ApiKeyAuth: []
  - MemberBearerAuth: []
paths:
  /documents/bank-statements:
    put:
      summary: Submit previously uploaded bank statements for processing
      description: |
        Uploading bank statements is a three-step flow:
          1. Request upload slots with `PUT /documents/bank-statements/presign`,
             providing each PDF file name (and optional external identifier).
             The response includes `presigned_url` and `path` values for every
             requested file.
          2. Upload the PDF content to every `presigned_url` using an HTTP `PUT`
             request with `Content-Type: application/octet-stream`.
          3. Call this endpoint with the JSON payload returned in step one,
             echoing the `path` (and optional `external_document_id`) for every
             uploaded file so Teal can extract and store the bank statement data.
        The `path` values you submit must match the ones returned by the presign
        step. Any files that failed validation or extraction are reported in the
        `bank_statement_errors` array.
      parameters:
        - $ref: '#/components/parameters/XAuthorisationId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BankStatementJsonRequestFileRequest'
      responses:
        '200':
          description: OK — all files successfully extracted
          content:
            application/json:
              schema:
                type: object
                properties:
                  bank_statement_submissions:
                    type: array
                    description: Successfully processed bank statements
                    items:
                      $ref: '#/components/schemas/BankStatementSubmission'
                  bank_statement_errors:
                    type: array
                    description: Files that failed extraction
                    items:
                      type: object
                      properties:
                        error:
                          type: string
                        file_name:
                          type: string
        '201':
          description: Created — bank statement(s) extracted and saved
          content:
            application/json:
              schema:
                type: object
                properties:
                  bank_statement_submissions:
                    type: array
                    description: Successfully processed bank statements
                    items:
                      $ref: '#/components/schemas/BankStatementSubmission'
                  bank_statement_errors:
                    type: array
                    description: Files that failed extraction
                    items:
                      type: object
                      properties:
                        error:
                          type: string
                        file_name:
                          type: string
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/UnauthorizedBearer'
      security:
        - BearerAuth: []
components:
  parameters:
    XAuthorisationId:
      name: x-teal-authorisation-id
      in: header
      required: false
      description: >-
        Optional authorisation ID to associate with this request. If not
        provided, the system will attempt to resolve a valid authorisation for
        the user automatically.
      schema:
        type: string
        format: uuid
        example: 7f3b8c2a-1d4e-5f6g-7h8i-9j0k1l2m3n4o
  schemas:
    BankStatementJsonRequestFileRequest:
      type: object
      required:
        - files
      properties:
        files:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/BankStatementJsonRequestFile'
    BankStatementSubmission:
      type: object
      required:
        - id
        - created_at
      properties:
        id:
          type: string
          format: uuid
          description: Unique bank statement submission identifier
          example: 95a0e70b-fe02-4f47-aef9-2efff279df71
        created_at:
          $ref: '#/components/schemas/Date'
        document_id:
          type: string
          format: uuid
          description: ID of the linked raw document, if available
          nullable: true
        document_external_id:
          type: string
          description: External ID provided during upload, if any
          nullable: true
        document_filename:
          type: string
          description: File name of the uploaded document
          nullable: true
        account_information:
          $ref: '#/components/schemas/BankStatementAccountInformation'
          nullable: true
        statement_period:
          $ref: '#/components/schemas/BankStatementStatementPeriod'
          nullable: true
        balance_information:
          $ref: '#/components/schemas/BankStatementBalanceInformation'
          nullable: true
        transactions:
          type: array
          description: List of transactions extracted from the bank statement
          nullable: true
          items:
            $ref: '#/components/schemas/BankStatementTransaction'
        bank_statement_probability:
          type: number
          format: float
          description: Confidence score (0-1) that the document is a genuine bank statement
          nullable: true
          example: 0.95
    BankStatementJsonRequestFile:
      type: object
      required:
        - path
      properties:
        path:
          type: string
          description: Storage path returned by the presign endpoint.
          example: client/acct123/users/user456/stmt1.pdf
        external_document_id:
          type: string
          description: Optional identifier shown in submissions when present.
          example: ext-stmt-2024-01
    Date:
      type: string
      format: date-time
      example: '2019-05-17T00:00:00.000Z'
    BankStatementAccountInformation:
      type: object
      description: Account holder and bank details extracted from the bank statement
      properties:
        account_holder_name:
          type: string
          description: Name of the account holder
          nullable: true
          example: JANE DOE
        account_number:
          type: string
          description: Bank account number
          nullable: true
          example: '12345678'
        sort_code:
          type: string
          description: Sort code of the bank account
          nullable: true
          example: 12-34-56
        bank_name:
          type: string
          description: Name of the bank
          nullable: true
          example: HSBC
        iban:
          type: string
          description: IBAN of the bank account
          nullable: true
    BankStatementStatementPeriod:
      type: object
      description: Time period covered by the bank statement
      properties:
        start_date:
          type: string
          description: Start date of the statement period
          nullable: true
          example: '2024-01-01'
        end_date:
          type: string
          description: End date of the statement period
          nullable: true
          example: '2024-01-31'
    BankStatementBalanceInformation:
      type: object
      description: Opening and closing balances from the bank statement
      properties:
        opening_balance:
          type: string
          description: Opening balance at the start of the statement period
          nullable: true
          example: 1,000.00
        closing_balance:
          type: string
          description: Closing balance at the end of the statement period
          nullable: true
          example: 1,250.00
    BankStatementTransaction:
      type: object
      description: A single transaction from the bank statement
      properties:
        date:
          type: string
          description: Date of the transaction
          nullable: true
          example: '2024-01-15'
        description:
          type: string
          description: Transaction description
          nullable: true
          example: Salary Payment
        amount:
          type: string
          description: Transaction amount
          nullable: true
          example: 2,500.00
        type:
          type: string
          description: Transaction type (credit or debit)
          nullable: true
          example: credit
    Error:
      required:
        - errors
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: An array of messages describing the errors
          example:
            - The request is missing the required field `name`
    UnauthorizedBarer:
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: An array of messages describing the errors
          example:
            - 'Not Authorization: Bearer <token> provided or wrong value'
  responses:
    BadRequest:
      description: Bad request if one of the required parameters is missing
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnauthorizedBearer:
      description: Unauthorized if the X-API-KEY is not provided or is wrong
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UnauthorizedBarer'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    MemberBearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token for authentication. The token should be the one returned by
        the "/members/signin"
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token for authentication. The token should be the one returned by
        the /user-tokens endpoint.

````