> ## 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.

# Subscribe a URL to events (REST Hooks)

> At most 10 subscriptions per account. The response carries the signing secret once.



## OpenAPI

````yaml /api-reference/openapi.json post /api/integrations/v1/webhooks
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/webhooks:
    post:
      tags:
        - Integration API
        - Webhooks
      summary: Subscribe a URL to events (REST Hooks)
      description: >-
        At most 10 subscriptions per account. The response carries the signing
        secret once.
      operationId: postIntegrationsV1Webhooks
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookSubscriptionInput'
      responses:
        '201':
          description: Subscription created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookSubscriptionCreated'
              example:
                success: true
                subscription:
                  id: cmh6wh0001ab12cd34ef56
                  url: https://hooks.example.com/ai2fin
                  events:
                    - expense.created
                  fieldFilter: []
                  active: true
                  consecutiveFailures: 0
                  disabledAt: null
                  disabledReason: null
                  description: null
                  consentTextVersion: v1-2026-07
                  createdAt: '2026-11-12T03:00:00.000Z'
                  updatedAt: '2026-11-12T03:00:00.000Z'
                secret: whsec_<64 hex characters>
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: Webhooks need the Auto+ plan (or the token lacks webhooks:manage).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                success: false
                error: subscription_required
                error_description: Webhooks and automations require the Auto+ plan.
                requiredPlan: auto+
        '429':
          $ref: '#/components/responses/IntegrationTooManyRequests'
      security:
        - oauth2:
            - webhooks:manage
components:
  schemas:
    WebhookSubscriptionInput:
      type: object
      required:
        - url
        - events
        - consentAcknowledged
      properties:
        url:
          type: string
          format: uri
          description: >-
            https:// on port 443, a DNS name (no IP literal or local/internal
            host), at most 2048 characters. Every address the name resolves to
            must be public.
        events:
          type: array
          minItems: 1
          items:
            type: string
            enum:
              - transaction.categorized
              - expense.created
              - receipt.processed
        fieldFilter:
          type: array
          items:
            type: string
            enum:
              - description
              - reference
              - notes
          description: Extra fields to include beyond the base fields.
        description:
          type: string
          maxLength: 200
        consentAcknowledged:
          type: boolean
          const: true
          description: >-
            Must be true: show the consent text (from the list endpoint) to the
            person first.
      example:
        url: https://hooks.example.com/ai2fin
        events:
          - expense.created
        consentAcknowledged: true
    WebhookSubscriptionCreated:
      type: object
      properties:
        success:
          type: boolean
        subscription:
          $ref: '#/components/schemas/WebhookSubscription'
        secret:
          type: string
          description: The signing secret (`whsec_` + 64 hex). Returned only here.
    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
    WebhookSubscription:
      type: object
      properties:
        id:
          type: string
        url:
          type: string
          format: uri
        events:
          type: array
          items:
            type: string
            enum:
              - transaction.categorized
              - expense.created
              - receipt.processed
        fieldFilter:
          type: array
          items:
            type: string
            enum:
              - description
              - reference
              - notes
        active:
          type: boolean
        consecutiveFailures:
          type: integer
        disabledAt:
          type:
            - string
            - 'null'
          format: date-time
        disabledReason:
          type:
            - string
            - 'null'
          description: paused_by_user or auto_disabled_delivery_failures
        description:
          type:
            - string
            - 'null'
        consentTextVersion:
          type: string
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
  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
    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
  headers:
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  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.