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

# Create an deal

> Create an deal for the authenticated team. The behavior depends on deliveryType: 'create' generates and finalizes the deal immediately, 'create_and_send' also sends it to the merchant, 'scheduled' schedules the deal for automatic processing at the specified date.



## OpenAPI

````yaml post /deals
openapi: 3.1.0
info:
  version: 0.0.1
  title: Abacus API
  description: Abacus is the operating system for Merchant Cash Advance businesses.
  contact:
    name: Abacus Support
    email: support@abacuslabs.co
    url: https://abacuslabs.co
  license:
    name: AGPL-3.0 license
    url: https://github.com/Suphian/abacus/blob/main/LICENSE
servers:
  - url: https://api.abacuslabs.co
    description: Production API
security:
  - oauth2: []
  - token: []
paths:
  /deals:
    post:
      tags:
        - Deals
      summary: Create an deal
      description: >-
        Create an deal for the authenticated team. The behavior depends on
        deliveryType: 'create' generates and finalizes the deal immediately,
        'create_and_send' also sends it to the merchant, 'scheduled' schedules
        the deal for automatic processing at the specified date.
      operationId: createDeal
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                template:
                  type: object
                  properties:
                    customerLabel:
                      type: string
                    title:
                      type: string
                    fromLabel:
                      type: string
                    dealNoLabel:
                      type: string
                    issueDateLabel:
                      type: string
                    dueDateLabel:
                      type: string
                    descriptionLabel:
                      type: string
                    priceLabel:
                      type: string
                    quantityLabel:
                      type: string
                    totalLabel:
                      type: string
                    totalSummaryLabel:
                      type: string
                    subtotalLabel:
                      type: string
                    discountLabel:
                      type: string
                    timezone:
                      type: string
                    paymentLabel:
                      type: string
                    noteLabel:
                      type: string
                    logoUrl:
                      type: string
                      nullable: true
                    currency:
                      type: string
                    dateFormat:
                      type: string
                    includeDiscount:
                      type: boolean
                    includeDecimals:
                      type: boolean
                    includePdf:
                      type: boolean
                    sendCopy:
                      type: boolean
                    includeUnits:
                      type: boolean
                    includeQr:
                      type: boolean
                    size:
                      type: string
                      enum:
                        - a4
                        - letter
                    deliveryType:
                      type: string
                      enum:
                        - create
                        - create_and_send
                        - scheduled
                    locale:
                      type: string
                    paymentEnabled:
                      type: boolean
                    paymentTermsDays:
                      type: number
                      minimum: 0
                      maximum: 365
                    theme:
                      type: object
                      properties:
                        primaryColor:
                          type: string
                        secondaryColor:
                          type: string
                        backgroundColor:
                          type: string
                        textColor:
                          type: string
                        mutedTextColor:
                          type: string
                        borderColor:
                          type: string
                        fontFamily:
                          type: string
                      required:
                        - primaryColor
                        - backgroundColor
                        - textColor
                        - mutedTextColor
                        - borderColor
                    paymentDetails:
                      type: object
                      description: Payment details in TipTap JSONContent format
                      example:
                        type: doc
                        content:
                          - type: paragraph
                            content:
                              - type: text
                                text: Acme Inc
                                marks:
                                  - type: bold
                          - type: paragraph
                            content:
                              - type: text
                                text: 123 Main St, City, Country
                          - type: paragraph
                            content:
                              - type: text
                                text: 'Visit our website: '
                              - type: text
                                text: https://acme.com
                                marks:
                                  - type: link
                                    attrs:
                                      href: https://acme.com
                    fromDetails:
                      type: object
                      description: Sender details in TipTap JSONContent format
                      example:
                        type: doc
                        content:
                          - type: paragraph
                            content:
                              - type: text
                                text: Acme Inc
                                marks:
                                  - type: bold
                          - type: paragraph
                            content:
                              - type: text
                                text: 123 Main St, City, Country
                          - type: paragraph
                            content:
                              - type: text
                                text: 'Visit our website: '
                              - type: text
                                text: https://acme.com
                                marks:
                                  - type: link
                                    attrs:
                                      href: https://acme.com
                    noteDetails:
                      type: object
                      description: >-
                        Default footer notes in TipTap JSONContent format for
                        new deals
                      example:
                        type: doc
                        content:
                          - type: paragraph
                            content:
                              - type: text
                                text: Acme Inc
                                marks:
                                  - type: bold
                          - type: paragraph
                            content:
                              - type: text
                                text: 123 Main St, City, Country
                          - type: paragraph
                            content:
                              - type: text
                                text: 'Visit our website: '
                              - type: text
                                text: https://acme.com
                                marks:
                                  - type: link
                                    attrs:
                                      href: https://acme.com
                  description: Deal template details
                fromDetails:
                  type: object
                  description: Sender details in TipTap JSONContent format
                  example:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: Acme Inc, 123 Main St, City, Country
                merchantId:
                  type: string
                  format: uuid
                  description: Unique identifier for the merchant (required)
                  example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                paymentDetails:
                  type: object
                  description: Payment details in TipTap JSONContent format
                  example:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: 'Bank: 123456, IBAN: DE1234567890'
                noteDetails:
                  type: object
                  description: Additional notes for the deal in TipTap JSONContent format
                  example:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: Thank you for your business.
                dueDate:
                  type: string
                  format: date-time
                  description: >-
                    Due date of the deal in ISO 8601 format. Defaults to issue
                    date + payment terms (30 days) if not provided.
                  example: '2024-06-30T23:59:59.000Z'
                issueDate:
                  type: string
                  format: date-time
                  description: >-
                    Issue date of the deal in ISO 8601 format. Defaults to
                    current date if not provided.
                  example: '2024-06-01T00:00:00.000Z'
                dealNumber:
                  type: string
                  description: >-
                    Deal number as shown on the deal (auto-generated if not
                    provided)
                  example: D-0001
                logoUrl:
                  type: string
                  nullable: true
                  description: URL of the logo to display on the deal
                  example: https://example.com/logo.png
                discount:
                  type: number
                  nullable: true
                  description: Discount applied to the deal
                  example: 100
                topBlock:
                  type: object
                  description: >-
                    Custom content block to display at the top of the deal in
                    TipTap JSONContent format
                  example:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: Acme Inc
                            marks:
                              - type: bold
                      - type: paragraph
                        content:
                          - type: text
                            text: 123 Main St, City, Country
                      - type: paragraph
                        content:
                          - type: text
                            text: 'Visit our website: '
                          - type: text
                            text: https://acme.com
                            marks:
                              - type: link
                                attrs:
                                  href: https://acme.com
                bottomBlock:
                  type: object
                  description: >-
                    Custom content block to display at the bottom of the deal in
                    TipTap JSONContent format
                  example:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: Acme Inc
                            marks:
                              - type: bold
                      - type: paragraph
                        content:
                          - type: text
                            text: 123 Main St, City, Country
                      - type: paragraph
                        content:
                          - type: text
                            text: 'Visit our website: '
                          - type: text
                            text: https://acme.com
                            marks:
                              - type: link
                                attrs:
                                  href: https://acme.com
                amount:
                  type: number
                  nullable: true
                  description: Total amount of the deal
                  example: 1500.75
                lineItems:
                  type: array
                  items:
                    type: object
                    properties:
                      quantity:
                        type: number
                        minimum: 0
                      unit:
                        type: string
                        nullable: true
                      price:
                        type: number
                      name:
                        type: object
                        description: Line item description in TipTap JSONContent format
                        example:
                          type: doc
                          content:
                            - type: paragraph
                              content:
                                - type: text
                                  text: Web Development Services
                      productId:
                        type: string
                        format: uuid
                        description: Optional reference to a saved product
                        example: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                  description: List of line items for the deal
                deliveryType:
                  type: string
                  enum:
                    - create
                    - create_and_send
                    - scheduled
                  description: >-
                    How the deal should be processed: 'create' - finalize
                    immediately, 'create_and_send' - finalize and send to
                    merchant, 'scheduled' - schedule for automatic processing at
                    specified date
                  example: create
                scheduledAt:
                  type: string
                  format: date-time
                  description: >-
                    Scheduled date of the deal in ISO 8601 format with timezone
                    offset (e.g., Z or +00:00). Required when deliveryType is
                    'scheduled'. Must be in the future.
                  example: '2024-06-30T23:59:59.000Z'
              required:
                - template
                - merchantId
                - deliveryType
              description: >-
                Schema for creating an deal. The deliveryType determines if it
                stays as a draft, gets finalized immediately, or gets scheduled
                for later processing.
              example:
                template:
                  title: Deal
                  customerLabel: Bill To
                  fromLabel: From
                  dealNoLabel: 'Deal #'
                  issueDateLabel: Issue Date
                  dueDateLabel: Due Date
                  descriptionLabel: Description
                  priceLabel: Rate
                  quantityLabel: Qty
                  totalLabel: Amount
                  totalSummaryLabel: Total
                  paymentLabel: Payment Information
                  noteLabel: Notes
                  logoUrl: https://example.com/logo.png
                  currency: USD
                  paymentDetails:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: >-
                              Wire Transfer: Chase Bank, Account: 1234567890,
                              Routing: 021000021
                  fromDetails:
                    type: doc
                    content:
                      - type: paragraph
                        content:
                          - type: text
                            text: >-
                              TechCorp Inc, 123 Business Ave, San Francisco, CA
                              94105
                  size: letter
                  discountLabel: Discount
                  includeDiscount: false
                  includeUnits: true
                  includeDecimals: true
                  includePdf: true
                  sendCopy: true
                  includeQr: false
                  dateFormat: MM/dd/yyyy
                  deliveryType: create
                  timezone: America/Los_Angeles
                  locale: en-US
                fromDetails:
                  type: doc
                  content:
                    - type: paragraph
                      content:
                        - type: text
                          text: TechCorp Inc
                          marks:
                            - type: strong
                    - type: paragraph
                      content:
                        - type: text
                          text: 123 Business Ave
                    - type: paragraph
                      content:
                        - type: text
                          text: San Francisco, CA 94105
                merchantId: a1b2c3d4-e5f6-7890-abcd-ef1234567890
                paymentDetails:
                  type: doc
                  content:
                    - type: paragraph
                      content:
                        - type: text
                          text: 'Wire Transfer:'
                          marks:
                            - type: strong
                    - type: paragraph
                      content:
                        - type: text
                          text: 'Chase Bank, Account: 1234567890'
                    - type: paragraph
                      content:
                        - type: text
                          text: 'Routing: 021000021'
                noteDetails:
                  type: doc
                  content:
                    - type: paragraph
                      content:
                        - type: text
                          text: Payment is due within 30 days of deal date.
                    - type: paragraph
                      content:
                        - type: text
                          text: Thank you for your business!
                          marks:
                            - type: italic
                dueDate: '2024-07-15T23:59:59.000Z'
                issueDate: '2024-06-15T00:00:00.000Z'
                dealNumber: D-0001
                logoUrl: https://example.com/logo.png
                topBlock:
                  type: doc
                  content:
                    - type: paragraph
                      content:
                        - type: text
                          text: >-
                            Thank you for choosing TechCorp for your software
                            development needs.
                          marks:
                            - type: strong
                    - type: paragraph
                      content:
                        - type: text
                          text: >-
                            This deal covers the development work completed in
                            June 2024.
                bottomBlock:
                  type: doc
                  content:
                    - type: paragraph
                      content:
                        - type: text
                          text: 'Terms & Conditions:'
                          marks:
                            - type: strong
                    - type: bulletList
                      content:
                        - type: listItem
                          content:
                            - type: paragraph
                              content:
                                - type: text
                                  text: Payment is due within 30 days of deal date
                        - type: listItem
                          content:
                            - type: paragraph
                              content:
                                - type: text
                                  text: >-
                                    Late payments may incur a 1.5% monthly
                                    service charge
                        - type: listItem
                          content:
                            - type: paragraph
                              content:
                                - type: text
                                  text: >-
                                    All work is subject to our standard terms of
                                    service
                    - type: paragraph
                      content:
                        - type: text
                          text: >-
                            Questions? Contact us at billing@techcorp.com or
                            (555) 123-4567
                          marks:
                            - type: italic
                amount: 1085
                lineItems:
                  - name:
                      type: doc
                      content:
                        - type: paragraph
                          content:
                            - type: text
                              text: Web Development Services
                              marks:
                                - type: strong
                        - type: paragraph
                          content:
                            - type: text
                              text: Custom React application with TypeScript
                              marks:
                                - type: italic
                    quantity: 40
                    price: 75
                  - name:
                      type: doc
                      content:
                        - type: paragraph
                          content:
                            - type: text
                              text: UI/UX Design
                              marks:
                                - type: strong
                        - type: paragraph
                          content:
                            - type: text
                              text: >-
                                User interface design and user experience
                                optimization
                              marks:
                                - type: italic
                    quantity: 20
                    price: 50
                deliveryType: create
                scheduledAt: '2024-07-01T09:00:00.000Z'
      responses:
        '201':
          description: >-
            Deal created successfully. Status depends on deliveryType:
            'scheduled' for scheduled deals, 'unpaid' for
            create/create_and_send.
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                    description: Unique identifier for the draft deal
                    example: b3b7e6e2-8c2a-4e2a-9b1a-2e4b5c6d7f8a
                  status:
                    type: string
                    enum:
                      - draft
                      - overdue
                      - paid
                      - unpaid
                      - canceled
                      - scheduled
                    description: Current status of the deal
                    example: draft
                  createdAt:
                    type: string
                    description: Timestamp when the deal was created (ISO 8601)
                    example: '2024-06-01T07:00:00.000Z'
                  updatedAt:
                    type: string
                    description: Timestamp when the deal was last updated (ISO 8601)
                    example: '2024-06-01T07:00:00.000Z'
                  pdfUrl:
                    type: string
                    nullable: true
                    description: Direct URL to download the deal PDF
                    example: https://app.abacuslabs.co/api/download/deal?token=eyJ...
                  previewUrl:
                    type: string
                    nullable: true
                    description: Direct URL to preview the deal in browser
                    example: https://app.abacuslabs.co/i/eyJ...
                required:
                  - id
                  - status
                  - createdAt
                  - updatedAt
                  - pdfUrl
                  - previewUrl
                description: Response after creating a draft deal
        '400':
          description: Bad request. Invalid input data or validation errors.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message describing the validation failure
                    examples:
                      - scheduledAt is required for scheduled delivery
                      - scheduledAt must be in the future
                      - >-
                        Deal number 'D-0001' is already used. Please provide a
                        different deal number or omit it to auto-generate one.
                required:
                  - message
        '404':
          description: Merchant not found.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Merchant not found
                required:
                  - message
        '409':
          description: Conflict. Deal number already exists.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message about the conflict
                    example: >-
                      Deal number 'D-0001' is already used. Please provide a
                      different deal number or omit it to auto-generate one.
                required:
                  - message
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    description: Error message
                    example: Failed to create deal
                required:
                  - message
components:
  securitySchemes:
    token:
      type: http
      scheme: bearer
      description: Default authentication mechanism
      x-speakeasy-example: ABACUS_API_KEY

````

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