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

# Add Contract

> Register a new smart contract for event tracking by providing a chain ID, contract address, and optional ABI for automatic event decoding.



## OpenAPI

````yaml POST /v0/contracts
openapi: 3.1.0
info:
  title: Formo Public API
  description: >-
    REST API for managing Formo projects, analytics, alerts, boards, charts,
    contracts, segments, and AI chat.


    **Auth.** All endpoints require a workspace API key with the appropriate
    scopes (see `x-api-scopes`).


    **Response shape.** Successful responses return the resource directly (or `{
    data: [...], total, page, size, has_more }` for paginated lists). HTTP
    status carries success/failure; there is no envelope wrapping success
    bodies.


    **Errors.** Every non-2xx response uses the `Error` envelope: `{ error: {
    code, message, doc_url, param?, details? } }`. Branch on the
    machine-readable `code` (see `ErrorCode` enum) and follow `doc_url` to the
    matching section of the [errors
    reference](https://docs.formo.so/api/errors).


    **Idempotency.** Pass an `Idempotency-Key` header on POST/PUT/PATCH/DELETE
    to make retries safe; the response is cached for 24 h and replayed on
    duplicate keys.
  version: 0.1.0
  contact:
    name: Formo
    url: https://formo.so
servers:
  - url: https://api.formo.so
    description: API Server (boards, alerts, contracts, segments, profiles, query, import)
  - url: https://events.formo.so
    description: Events Server (event ingestion)
security:
  - WorkspaceApiKey: []
tags:
  - name: Alerts
    description: Manage project alerts and notifications
  - name: Boards
    description: Manage dashboard boards
  - name: Charts
    description: Manage charts within boards
  - name: Contracts
    description: Manage blockchain contract monitoring
  - name: Segments
    description: Manage user segments
  - name: Profiles
    description: Wallet profiles and import
  - name: Query
    description: >-
      Execute SQL queries and call pre-built analytics endpoints (KPIs, top
      pages, lifecycle, retention, revenue). Requires the query:read scope.
  - name: Events
    description: Event ingestion API (events.formo.so)
paths:
  /v0/contracts:
    post:
      tags:
        - Contracts
      summary: Create contract
      description: Add a blockchain contract to monitor.
      operationId: createContract
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                address:
                  type: string
                  description: EVM contract address
                chain:
                  type: integer
                  description: Chain ID
                name:
                  type: string
                abi:
                  type: string
                  description: JSON-stringified ABI
                events:
                  type: array
                  maxItems: 10
                  items:
                    type: object
                    properties:
                      anonymous:
                        type: boolean
                      inputs:
                        type: array
                        items:
                          type: object
                      name:
                        type: string
                      type:
                        type: string
                    required:
                      - anonymous
                      - inputs
                      - name
                      - type
                start_block:
                  type: integer
              required:
                - address
                - chain
                - name
                - abi
                - events
            examples:
              erc20Token:
                summary: Monitor ERC-20 Transfer events
                value:
                  address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
                  chain: 1
                  name: USDC
                  abi: >-
                    [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"}]
                  events:
                    - anonymous: false
                      inputs:
                        - indexed: true
                          internalType: address
                          name: from
                          type: address
                        - indexed: true
                          internalType: address
                          name: to
                          type: address
                        - indexed: false
                          internalType: uint256
                          name: value
                          type: uint256
                      name: Transfer
                      type: event
                  start_block: 18000000
      responses:
        '201':
          description: Contract created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contract'
components:
  schemas:
    Contract:
      type: object
      properties:
        name:
          type: string
        chain:
          type: integer
        address:
          type: string
        start_block:
          type: integer
        abi:
          type: string
        events:
          type: array
          items:
            type: object
            properties:
              anonymous:
                type: boolean
              inputs:
                type: array
                items:
                  type: object
              name:
                type: string
              type:
                type: string
            required:
              - anonymous
              - inputs
              - name
              - type
      required:
        - name
        - chain
        - address
        - abi
        - events
  securitySchemes:
    WorkspaceApiKey:
      type: http
      scheme: bearer
      description: >-
        Workspace API key (e.g. `formo_xxx`). Create one in the Formo dashboard
        under Team Settings > API Keys.

````