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

# Create an expense

> Creates an expense (and, when isTaxDeductible is true, its tax deduction in the same database transaction). Emits `expense.created` to your webhooks.



## OpenAPI

````yaml /api-reference/openapi.json post /api/integrations/v1/expenses
openapi: 3.1.0
info:
  title: AI2Fin Financial Management API
  description: >-
    Financial management platform with AI-powered categorization, tax
    optimization, and bill management. Guides: authentication and scopes, rate
    limits, idempotency, webhooks, versioning and the changelog are under API
    Reference → Guides at https://docs.ai2fin.com.
  version: 1.0.0
  contact:
    name: AI2Fin Support
    url: https://ai2fin.com/contact
    email: support@ai2fin.com
  license:
    name: Proprietary
servers:
  - url: https://api.ai2fin.com
    description: Production
security:
  - bearerAuth: []
  - cookieAuth: []
tags:
  - name: Authentication
    description: User authentication and authorization
  - name: Bank Transactions
    description: >-
      First-party endpoints for managing your own transactions and CSV imports.
      These return your own account data in your own authenticated session; they
      are not a third-party integration surface. Data synced from connected bank
      feeds (open-banking / CDR data) stays within your account and is only ever
      returned to you.
  - name: Bills & Recurring Payments
    description: Bill management with pattern recognition and auto-linking
  - name: Expenses
    description: Expense tracking with tax deduction support
  - name: AI Services
    description: AI-powered categorization and tax analysis
  - name: Automation
    description: Custom rules engine for automated workflows
  - name: Categories
    description: Transaction and expense category management
  - name: Smart Categories
    description: >-
      Category sets, multi-category assignments, and transaction history (Elite+
      only)
  - name: Analytics & Reports
    description: Financial analytics and tax report generation
  - name: Travel & Vehicles
    description: Vehicle registration and business trip tracking
  - name: Search
    description: AI-powered unified search across all entities
  - name: Subscription
    description: Subscription and quota management
  - name: AI Analysis
    description: AI-driven categorization and tax analysis endpoints
  - name: AI Assistant
    description: Chat conversations, messaging, and assistant file handling
  - name: GST & Tax
    description: Global GST/VAT rate lookup and calculations
  - name: Receipts & Attachments
    description: Receipt ingestion, AI analysis, and linkage APIs
  - name: MCP Server
    description: >-
      Model Context Protocol endpoints for AI integrations. Finance MCP server
      with 65+ tools for expense tracking, tax deductions, bill management, and
      financial analysis. Supports OAuth (JWT) and API key authentication.
  - name: Integration API
    description: >-
      Versioned third-party surface at /api/integrations/v1, authenticated with
      OAuth access tokens carrying explicit scopes. Writes accept a durable
      Idempotency-Key.
  - name: Webhooks
    description: >-
      Manage outbound webhook subscriptions (Auto+ plan). Event payloads are
      described in the top-level `webhooks` section.
  - name: Data history & undo
    description: >-
      What changed in your books, and undo for batch edits. Batches can be
      undone for 30 days.
paths:
  /api/integrations/v1/expenses:
    post:
      tags:
        - Integration API
      summary: Create an expense
      description: >-
        Creates an expense (and, when isTaxDeductible is true, its tax deduction
        in the same database transaction). Emits `expense.created` to your
        webhooks.
      operationId: postIntegrationsV1Expenses
      parameters:
        - $ref: '#/components/parameters/IntegrationIdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - description
                - amount
                - date
              properties:
                description:
                  type: string
                  maxLength: 500
                amount:
                  type: number
                  exclusiveMinimum: 0
                  maximum: 100000000
                date:
                  type: string
                  format: date-time
                merchant:
                  type: string
                  maxLength: 200
                isTaxDeductible:
                  type: boolean
                  default: false
                businessUsePercentage:
                  type: number
                  minimum: 0
                  maximum: 100
                  default: 100
            example:
              description: Mobile plan November
              amount: 89
              date: '2026-11-11T00:00:00Z'
              merchant: Telstra
              isTaxDeductible: true
              businessUsePercentage: 50
      responses:
        '200':
          description: Replay of an earlier completed request with the same Idempotency-Key
          headers:
            Idempotency-Replayed:
              $ref: '#/components/headers/Idempotency-Replayed'
        '201':
          description: Expense created
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  expense:
                    type: object
                    properties:
                      id:
                        type: string
                      description:
                        type: string
                      amount:
                        type: number
                      date:
                        type: string
                        format: date-time
                      merchant:
                        type:
                          - string
                          - 'null'
                      isTaxDeductible:
                        type: boolean
              example:
                success: true
                expense:
                  id: cmh1x3a4b0002ab12cd34ef56
                  description: Mobile plan November
                  amount: 89
                  date: '2026-11-11T00:00:00.000Z'
                  merchant: Telstra
                  isTaxDeductible: true
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/InsufficientScope'
        '409':
          $ref: '#/components/responses/IdempotencyInProgress'
        '429':
          $ref: '#/components/responses/IntegrationTooManyRequests'
      security:
        - oauth2:
            - write:expenses
components:
  parameters:
    IntegrationIdempotencyKey:
      name: Idempotency-Key
      in: header
      required: false
      description: >-
        Optional. 1 to 128 characters of letters, digits, `_`, `.`, `:` or `-`.
        Stored in the database for 24 hours per account and endpoint. A
        completed request with the same key is replayed (200,
        `Idempotency-Replayed: true`); a request still in progress with the same
        key returns 409 `IDEMPOTENCY_IN_PROGRESS`. A failed request releases its
        key so a retry runs. A key that does not match the pattern is ignored
        (the request runs without idempotency).
      schema:
        type: string
        maxLength: 128
        pattern: ^[\w.:-]+$
      example: order-1042
  headers:
    Idempotency-Replayed:
      description: >-
        Integration API: present and `true` when this response replays an
        earlier completed request with the same Idempotency-Key.
      schema:
        type: string
        enum:
          - 'true'
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  responses:
    BadRequest:
      description: >-
        The request is not valid (missing or malformed fields, bad query values,
        or an Idempotency-Key over 256 characters).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Description, amount, and date are required
    Unauthorized:
      description: >-
        No valid credentials were sent, or the token is expired, revoked or for
        another audience.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Access token required
    InsufficientScope:
      description: >-
        The OAuth token lacks the scope this endpoint needs (`WWW-Authenticate:
        Bearer error="insufficient_scope"`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: 'Missing required scope: write:expenses'
            errorType: INSUFFICIENT_SCOPE
            grantedScopes:
              - read:transactions
    IdempotencyInProgress:
      description: >-
        Another request with this Idempotency-Key is still in progress. Retry
        shortly.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: A request with this Idempotency-Key is already in progress
            errorType: IDEMPOTENCY_IN_PROGRESS
    IntegrationTooManyRequests:
      description: >-
        More than 60 Integration API requests in a minute for this account. Wait
        `Retry-After` seconds.
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Rate limit exceeded for integration API
            errorType: RATE_LIMITED
  schemas:
    Error:
      type: object
      required:
        - error
      properties:
        success:
          type: boolean
          default: false
        error:
          type: string
        code:
          type: string
        errorType:
          type: string
          description: >-
            Machine-readable error kind where the endpoint sets one, e.g.
            VALIDATION_ERROR, INSUFFICIENT_SCOPE, RATE_LIMITED.
        message:
          type: string
          description: Human-readable detail, where provided.
        requiredPlan:
          type: string
          description: 'On a plan refusal (403): the plan that includes the feature.'
        hint:
          type: string
      description: >-
        Error body used across the API. `success` is false and `error` is a
        short message; the other fields appear only where the endpoint sets
        them. Some handlers return `{ error }` without `success`.
      additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        First-party access token for your own signed-in session, obtained from
        the /api/enterprise-auth/login endpoint. The REST API returns your own
        account data to you — it is a first-party consumer surface, not a
        third-party integration channel. Data from connected bank feeds
        (open-banking / CDR data) is your own data, returned only to you in your
        own authenticated session.
    cookieAuth:
      type: apiKey
      in: cookie
      name: ai2_sess
      description: Session cookie for web applications
    oauth2:
      type: oauth2
      description: >-
        OAuth 2.1 authorization code flow with PKCE (S256 only) and exact
        redirect-URI matching. Clients register by Dynamic Client Registration
        (`/api/oauth/register`) or a Client ID Metadata Document. Discovery:
        `/.well-known/oauth-authorization-server` and
        `/.well-known/oauth-protected-resource/mcp`. Access tokens last one hour
        and refresh tokens rotate. Tokens carry the audience
        `https://api.ai2fin.com/mcp` and are accepted on `/mcp` and
        `/api/integrations/v1` only. A request with no `scope` gets
        read:transactions write:transactions read:bills write:bills;
        write:expenses and webhooks:manage must be asked for explicitly.
      flows:
        authorizationCode:
          authorizationUrl: https://api.ai2fin.com/api/oauth/authorize
          tokenUrl: https://api.ai2fin.com/api/oauth/token
          refreshUrl: https://api.ai2fin.com/api/oauth/token
          scopes:
            read:transactions: >-
              MCP: every read tool over transactions, spending, tax summaries,
              categories, lenses, budgets, income, insights, assets, places,
              expected income, upcoming money, account and plan.
            write:transactions: >-
              MCP: the write tools. Integration API: POST /transactions and POST
              /statements.
            read:bills: 'MCP: read tools over bills and bill occurrences.'
            write:bills: >-
              MCP: the same write gate as write:transactions (either unlocks the
              write tools).
            write:expenses: 'Integration API: POST /expenses. Does not unlock MCP write tools.'
            webhooks:manage: >-
              Integration API: list, create and delete webhook subscriptions
              (Auto+ plan also required). Does not unlock MCP write tools.

````

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