> ## 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 a webhook subscription

> At most 10 per account. The signing secret is returned once.



## OpenAPI

````yaml /api-reference/openapi.json post /api/automations/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/automations/webhooks:
    post:
      tags:
        - Webhooks
      summary: Create a webhook subscription
      description: At most 10 per account. The signing secret is returned once.
      operationId: postAutomationsWebhooks
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WebhookSubscriptionInput'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WebhookSubscriptionCreated'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
        - bearerAuth: []
        - cookieAuth: []
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.
    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
    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
    RateLimitError:
      type: object
      description: Body of a 429 from the platform-wide limiter.
      properties:
        error:
          type: string
          example: Too Many Requests
        message:
          type: string
          example: Rate limit exceeded. Try again in 20 seconds.
        retryAfter:
          type: integer
          description: Seconds until you can retry.
        limit:
          type: integer
        windowMs:
          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
    Forbidden:
      description: Authenticated, but your plan or role does not include this.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            error: Access denied
            message: 'Feature not available in plan: automations'
            requiredPlan: auto+
    TooManyRequests:
      description: >-
        Rate limited. Wait `Retry-After` seconds. See the Rate limits guide for
        the limits that apply.
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
          example:
            error: Too Many Requests
            message: Rate limit exceeded. Try again in 20 seconds.
            retryAfter: 20
            limit: 2000
            windowMs: 900000
  headers:
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
    X-RateLimit-Limit:
      description: The request ceiling of the window that applies to you.
      schema:
        type: integer
    X-RateLimit-Remaining:
      description: Requests left in the current window.
      schema:
        type: integer
    X-RateLimit-Reset:
      description: When the current window resets (ISO 8601 date-time).
      schema:
        type: string
        format: date-time
  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

````

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