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

# Link Existing Invoice To Contract

> Attach an existing AR invoice to a contract. The contract gets a mirrored
invoice row and lines plus the INVOICE subledger entry, posted against
the AR invoice's GL journal. The link is made from the contract only.



## OpenAPI

````yaml https://api.meetcampfire.com/api/schema?format=json post /rev/api/v1/contracts/{id}/link-invoice
openapi: 3.0.3
info:
  title: Campfire Developer APIs
  version: 1.0.0
  description: >
    ## Introduction

    Campfire's developer APIs offer granular access to Campfire's core
    accounting,

    revenue recognition, and financial data features.


    These APIs are designed to be used by developers to build custom
    integrations,

    automate workflows, and perform any other programmatic operations.


    ## Rate limits

    API users can make up to **5 requests per second**. This limit is shared
    across

    all endpoints for the same API user. Requests that exceed the limit receive
    a

    `429 Too Many Requests` response. Wait for the number of seconds specified
    in

    the `Retry-After` response header before retrying.
servers:
  - url: https://api.meetcampfire.com
    description: Production server
security: []
tags:
  - name: Cash Management
    description: Operations related to accounts, transactions, and other bank-related data.
  - name: Core Accounting
    description: >-
      Operations related to core accounting data, such as the chart of accounts,
      entity management, and the general ledger.
  - name: Revenue Recognition
    description: >-
      Operations related to revenue recognition, contract management, and
      contract data aggregation.
  - name: Accounts Receivable
    description: Operations related to invoicing and the AR subledger
  - name: Accounts Payable
    description: Operations related to billing and the AP subledger.
  - name: Financial Statements
    description: Operations related to financial statement generation and data aggregation.
  - name: Settings
    description: Operations related to system and accounting settings configuration.
paths:
  /rev/api/v1/contracts/{id}/link-invoice:
    post:
      tags:
        - Revenue
      summary: Link Existing Invoice To Contract
      description: >-
        Attach an existing AR invoice to a contract. The contract gets a
        mirrored

        invoice row and lines plus the INVOICE subledger entry, posted against

        the AR invoice's GL journal. The link is made from the contract only.
      operationId: rev_api_v1_contracts_link_invoice_create
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RevenueContractLinkInvoice'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/RevenueContractLinkInvoice'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/RevenueContractLinkInvoice'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RevenueContractInvoice'
          description: ''
components:
  schemas:
    RevenueContractLinkInvoice:
      type: object
      properties:
        invoice:
          type: integer
      required:
        - invoice
    RevenueContractInvoice:
      type: object
      description: |-
        Base serializer that injects the request user's customer on create and
        restricts related-object querysets to the same customer.
      properties:
        id:
          type: integer
          readOnly: true
        contract:
          type: integer
          readOnly: true
        contract_name:
          type: string
          readOnly: true
        contract_number:
          type: string
          readOnly: true
        entity:
          type: integer
          readOnly: true
        entity_name:
          type: string
          readOnly: true
          default: ''
        client:
          type: integer
          readOnly: true
        client_name:
          type: string
          readOnly: true
          default: ''
        invoice:
          type: integer
          readOnly: true
        journal_entry:
          type: integer
          readOnly: true
        journal_entry_number:
          type: string
          readOnly: true
        ordinal:
          type: integer
          maximum: 2147483647
          minimum: 0
        invoice_number:
          type: string
          maxLength: 255
        status:
          $ref: '#/components/schemas/RevenueContractInvoiceStatusEnum'
        issue_date:
          type: string
          format: date
        accounting_date:
          type: string
          format: date
          nullable: true
          description: >-
            Accounting date used as the issued AR invoice date; defaults to the
            issue date.
        due_date:
          type: string
          format: date
          nullable: true
        payment_term:
          type: integer
          nullable: true
          description: >-
            Terms behind the due date; None means due on receipt or a manually
            set date.
        bill_to_snapshot: {}
        currency:
          type: string
          maxLength: 3
        purchase_order_number:
          type: string
          nullable: true
          maxLength: 120
        period_start:
          type: string
          format: date
          nullable: true
        period_end:
          type: string
          format: date
          nullable: true
        shipping_date:
          type: string
          format: date
          nullable: true
        location_of_sale:
          type: string
          nullable: true
        vat_number:
          type: string
          nullable: true
          maxLength: 250
        billing_address:
          type: string
          nullable: true
        billing_addressee:
          type: string
          nullable: true
          maxLength: 255
        shipping_address:
          type: string
          nullable: true
        shipping_addressee:
          type: string
          nullable: true
          maxLength: 255
        message_on_invoice:
          type: string
          nullable: true
        tax_rate:
          type: integer
          nullable: true
        tax_rate_name:
          type: string
          readOnly: true
          default: ''
        anrok_connection:
          type: integer
          nullable: true
          description: >-
            Draft override for Anrok. Null inherits the entity's tax connector
            at issuance.
        anrok_connection_name:
          type: string
          readOnly: true
          default: ''
        avalara_connection:
          type: integer
          nullable: true
          description: >-
            Draft override for Avalara. Null inherits the entity's tax connector
            at issuance.
        avalara_connection_name:
          type: string
          readOnly: true
          default: ''
        sphere_connection:
          type: integer
          nullable: true
          description: >-
            Draft override for Sphere. Null inherits the entity's tax connector
            at issuance.
        sphere_connection_name:
          type: string
          readOnly: true
          default: ''
        stripe_connection:
          type: integer
          nullable: true
          description: >-
            Draft override for Stripe. Null inherits the contract's Stripe
            connection.
        stripe_connection_name:
          type: string
          readOnly: true
          default: ''
        use_stripe_auto_bill:
          type: boolean
          nullable: true
          description: >-
            Draft override for Stripe auto-bill. Null inherits the contract
            setting.
        subtotal:
          type: number
          format: double
          maximum: 10000000000000
          minimum: -10000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          readOnly: true
        discount:
          type: number
          format: double
          maximum: 10000000000000
          minimum: -10000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          description: This invoice's prorated share of the contract-wide discount.
        total_amount:
          type: number
          format: double
          maximum: 10000000000000
          minimum: -10000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        is_linked:
          type: boolean
          readOnly: true
          description: >-
            Created by attaching an existing AR invoice to the contract rather
            than by issuing a billing-schedule row. The AR invoice is the source
            of truth: this row mirrors it, and deleting the AR invoice removes
            the row instead of returning it to Draft.
        needs_live_date_fx_recalc:
          type: boolean
          readOnly: true
          description: >-
            Set when Create All Now issued this row before its invoice date in a
            currency other than the entity book currency. Cleared after FX is
            recalculated on the invoice date.
        lines:
          type: array
          items:
            $ref: '#/components/schemas/RevenueContractInvoiceLine'
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        last_modified_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - anrok_connection_name
        - avalara_connection_name
        - client
        - client_name
        - contract
        - contract_name
        - contract_number
        - created_at
        - entity
        - entity_name
        - id
        - invoice
        - is_linked
        - issue_date
        - journal_entry
        - journal_entry_number
        - last_modified_at
        - lines
        - needs_live_date_fx_recalc
        - sphere_connection_name
        - stripe_connection_name
        - subtotal
        - tax_rate_name
    RevenueContractInvoiceStatusEnum:
      enum:
        - DRAFT
        - SCHEDULED
        - OPEN
        - SENT
        - PAID
        - VOIDED
      type: string
      description: |-
        * `DRAFT` - Draft
        * `SCHEDULED` - Scheduled
        * `OPEN` - Open
        * `SENT` - Sent
        * `PAID` - Paid
        * `VOIDED` - Voided
    RevenueContractInvoiceLine:
      type: object
      description: |-
        Base serializer that injects the request user's customer on create and
        restricts related-object querysets to the same customer.
      properties:
        id:
          type: integer
          readOnly: true
        invoice:
          type: integer
        contract_line:
          type: integer
          nullable: true
        product:
          type: integer
          nullable: true
          description: >-
            The product the issued AR invoice line bills against. Seeded from
            the contract line at schedule generation; editable on drafts so
            manually added lines can pick one.
        product_name:
          type: string
          readOnly: true
          default: ''
        description:
          type: string
          maxLength: 500
        service_start:
          type: string
          format: date
          nullable: true
        service_end:
          type: string
          format: date
          nullable: true
        currency:
          type: string
          maxLength: 3
        quantity:
          type: number
          format: double
          maximum: 100000000000
          minimum: -100000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        rate:
          type: number
          format: double
          maximum: 1000000000000000
          minimum: -1000000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          nullable: true
        amount:
          type: number
          format: double
          maximum: 10000000000000
          minimum: -10000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        tax:
          type: number
          format: double
          maximum: 10000000000000
          minimum: -10000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
        tax_description:
          type: string
          nullable: true
          maxLength: 250
        discount:
          type: number
          format: double
          maximum: 10000000000000
          minimum: -10000000000000
          exclusiveMaximum: true
          exclusiveMinimum: true
          description: >-
            This occurrence's share of its contract line discount. Contract-wide
            discounts are stored on the invoice instead.
        department:
          type: integer
          nullable: true
        department_name:
          type: string
          readOnly: true
          default: ''
        tags:
          type: array
          items:
            type: integer
        created_at:
          type: string
          format: date-time
          readOnly: true
        last_modified_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - created_at
        - department_name
        - id
        - invoice
        - last_modified_at
        - product_name

````