API Reference

Overview

Welcome to the API Documentation — your definitive guide to integrating with our platform. Whether you're automating billing, managing products, or handling customer onboarding, this documentation provides the specifications and examples you need to get up and running.

AUTHENTICATION

All requests to our APIs require authentication using an API key.
Authorization: Bearer YOUR_API_KEY
You can generate and manage your API keys from our Admin Console under Key Management System.

API OVERVIEW

Our APIs are organized into several categories based on functionality:

  • Invoice Management APIs
  • Product & Inventory APIs
  • Customer Management API
  • Sales Communication API

INVOICE MANAGEMENT API GUIDE

This guide provides a comprehensive breakdown of the Invoice Management APIs, including endpoints, required/optional parameters, sample requests, and responses.

The Invoice Management APIs let you:

  • Create invoice drafts
  • Retrieve all or specific invoices
  • Void specific invoices
  • Delete specific invoices

API ENDPOINTS

1. Create A New Invoice

EndPoint: POST /api/invoices

Description: Drafts a new invoice without sending it, perfect for saving work in progress.

SAMPLE REQUEST

curl -X POST 'https://api.mochaaccounting.com/sales_service/api/invoices' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key' \
  -d '{"amount": 1500, "currency": "USD"}'

CREATE INVOICE PAYLOAD

{
  "customer_id": 966,
  "customer_emails": [],
  "attachments": [],
  "payment_date": "",
  "invoice_date": "2026-06-05",
  "due_date": "2026-06-05",
  "shipping_date": "",
  "term_id": 4,
  "invoice_no": "INVOICE-105",
  "reference_no": "INVOICE-105",
  "tracking_no": "INVOICE-105",
  "tags": [],
  "addresses": [
    null,
    {
      "postal_code": "400003",
      "locality": "Mumbai",
      "is_google_address": true,
      "street_number": "",
      "route": "Grant Rd",
      "latitude": 18.9619634,
      "longitude": 72.8218121,
      "formatted_address": "Grant Road",
      "administrative_area_level_1": "MH",
      "country": "IN",
      "administrative_area_level_2": "Konkan Division",
      "google_place_id": "ElBHcmFudCBSZCwgR3JhbnQgUm9hZCBFYXN0...",
      "type": "location"
    },
    null,
    null
  ],
  "lines": [
    {
      "item_type": "",
      "item_id": 0,
      "product_id": 75,
      "description": "This is a dummy description",
      "pricing_plan_ids": [],
      "quantity": "1.0000000000",
      "rate": "100.00",
      "amount": 100,
      "unit_list": [],
      "unit_id": null,
      "base_unit": true,
      "conversion_rate": 1,
      "type": "service",
      "available_stock": 0,
      "warehouse_id": null,
      "is_taxable": false,
      "added_tax": 0,
      "tax_amount": 0,
      "tax_rates": [],
      "tax_desc": "",
      "bin_locations": [],
      "preferences": null,
      "category": null,
      "custom_fields": [],
      "units_id": 0,
      "property_id": 0,
      "tax_classification_id": null,
      "tax_snapshot": {
        "tax_classification_id": null,
        "tax_rates": [],
        "tax_amount": 0,
        "tax_desc": "",
        "tax_snapshot": null
      },
      "selected_component_ids": [],
      "discount_amount": 5,
      "discounts": [
        {
          "campaign_id": 1,
          "campaign_discount_id": 1,
          "discount_source": "CAMPAIGN",
          "discount_level": "TRANSACTION",
          "discount_type": "VOLUME",
          "discount_value": "2.00-4.00: 10.00%",
          "discount_amount": 5,
          "discount_tax_type": "BEFORE_TAX",
          "discount_meta": {
            "campaign_name": "VOLUME (Txn - 2-4: 10%)",
            "rule_applied": true,
            "tier_info": [
              {
                "id": 1,
                "discount_id": 1,
                "min_value_or_qty": "2.00",
                "max_value_or_qty": "4.00",
                "discount_type": "PERCENTAGE",
                "discount_value": "10.00",
                "tier_order": 1,
                "deleted_at": null,
                "created_at": "2026-05-04T11:48:12.000000Z",
                "updated_at": "2026-05-04T11:48:12.000000Z",
                "appliedQty": 1,
                "tierDiscount": 7.5
              }
            ]
          }
        }
      ]
    },
    {
      "item_type": "",
      "item_id": 0,
      "product_id": 73,
      "description": "This is a dummy description",
      "pricing_plan_ids": [],
      "quantity": "1.0000000000",
      "rate": "50.00",
      "amount": 50,
      "unit_list": [
        {
          "value": 27,
          "label": "PCS (Pieces)",
          "unit_type": 0
        }
      ],
      "unit_id": 27,
      "base_unit": true,
      "conversion_rate": 1,
      "type": "inventory",
      "available_stock": 3,
      "warehouse_id": null,
      "is_taxable": false,
      "added_tax": 0,
      "tax_amount": 0,
      "tax_rates": [],
      "tax_desc": "",
      "bin_locations": [],
      "preferences": null,
      "category": {
        "id": 5,
        "tenant_id": "umer",
        "name": "MALPANI BAKELITE",
        "preferences": {
          "price": { "userInput": null, "roundOffTo": null },
          "quantity": { "userInput": null, "roundOffTo": null }
        }
      },
      "custom_fields": [],
      "units_id": 0,
      "property_id": 0,
      "tax_classification_id": null,
      "tax_snapshot": {
        "tax_classification_id": null,
        "tax_rates": [],
        "tax_amount": 0,
        "tax_desc": "",
        "tax_snapshot": null
      },
      "selected_component_ids": [],
      "discount_amount": 2.5,
      "discounts": [
        {
          "campaign_id": 1,
          "campaign_discount_id": 1,
          "discount_source": "CAMPAIGN",
          "discount_level": "TRANSACTION",
          "discount_type": "VOLUME",
          "discount_value": "2.00-4.00: 10.00%",
          "discount_amount": 2.5,
          "discount_tax_type": "BEFORE_TAX",
          "discount_meta": {
            "campaign_name": "VOLUME (Txn - 2-4: 10%)",
            "rule_applied": true,
            "tier_info": [
              {
                "id": 1,
                "discount_id": 1,
                "min_value_or_qty": "2.00",
                "max_value_or_qty": "4.00",
                "discount_type": "PERCENTAGE",
                "discount_value": "10.00",
                "tier_order": 1,
                "deleted_at": null,
                "created_at": "2026-05-04T11:48:12.000000Z",
                "updated_at": "2026-05-04T11:48:12.000000Z",
                "appliedQty": 1,
                "tierDiscount": 7.5
              }
            ]
          }
        }
      ]
    }
  ],
  "message_on_invoice": "",
  "message_on_statement": "",
  "is_recurring": false,
  "installments": [],
  "discount_amount": 0,
  "discount_level": "",
  "discount_tax_type": "",
  "discount_type": "",
  "discount_value": null,
  "custom_fields": [],
  "_billable_expense_ids": null,
  "amount": 142.5,
  "balance": 142.5,
  "unique_no": "INVOICE-105",
  "is_scheduled": 0,
  "recurring_template_id": null,
  "isManage": false
}

SAMPLE RESPONSE

{
  "customer_id": 966,
  "term_id": 4,
  "property_id": null,
  "unit_id": null,
  "customer": {
    "id": 966,
    "title": "",
    "first_name": "",
    "middle_name": "",
    "last_name": "",
    "display_name": "Arav test 3",
    "name": "Arav test 3",
    "email": "",
    "phone_number": null,
    "mobile_number": null
  },
  "term": {
    "id": 4,
    "name": "Due on Receipt",
    "amount": 0,
    "type": "days",
    "is_default": 1,
    "deleted_at": null
  },
  "lines": [
    {
      "id": 1934,
      "tenant_id": "umer",
      "item_type": "",
      "item_id": 0,
      "invoice_id": 670,
      "product_id": 75,
      "pricing_plan_id": null,
      "text": "This is a dummy description",
      "rate": "100.0000000000",
      "amount": "100.0000000000",
      "quantity": "1.0000000000",
      "discount_amount": null,
      "gst": "0.00",
      "gst_amount": "0.00",
      "unit_id": null,
      "warehouse_id": null,
      "bin_locations": [],
      "discount_line_detail_id": 1,
      "is_taxable": false,
      "type": "product",
      "gst_rate": "0.0000000000",
      "tax_amount": "0.0000000000",
      "returned_quantity": 0,
      "product": {
        "id": 75,
        "tenant_id": "umer",
        "code": "BAS6WHBYBY",
        "name": "Basic Service",
        "type": "service",
        "is_active": "1",
        "available_stock": 0,
        "revenue_account": 15,
        "expense_account": 20,
        "inventory_account": 0,
        "unit_id": null,
        "sku": "BAS6WHBYBY"
      },
      "discount_detail": {
        "id": 1,
        "discount_source": "CAMPAIGN",
        "discount_level": "TRANSACTION",
        "discount_type": "",
        "discount_value": 2,
        "discount_amount": 5,
        "discount_tax_type": "BEFORE_TAX",
        "discount_meta": {
          "campaign_name": "VOLUME (Txn - 2-4: 10%)",
          "rule_applied": true,
          "tier_info": [
            {
              "id": 1,
              "discount_id": 1,
              "min_value_or_qty": "2.00",
              "max_value_or_qty": "4.00",
              "discount_type": "PERCENTAGE",
              "discount_value": "10.00",
              "tier_order": 1,
              "appliedQty": 1,
              "tierDiscount": 7.5
            }
          ]
        },
        "is_active": true,
        "created_at": "2026-06-05T11:42:32.000000Z",
        "updated_at": "2026-06-05T11:42:32.000000Z",
        "deleted_at": null
      }
    },
    {
      "id": 1935,
      "tenant_id": "umer",
      "item_type": "",
      "item_id": 0,
      "invoice_id": 670,
      "product_id": 73,
      "pricing_plan_id": null,
      "text": "This is a dummy description",
      "rate": "50.0000000000",
      "amount": "50.0000000000",
      "quantity": "1.0000000000",
      "discount_amount": null,
      "gst": "0.00",
      "gst_amount": "0.00",
      "unit_id": 27,
      "warehouse_id": null,
      "bin_locations": [],
      "discount_line_detail_id": 2,
      "is_taxable": false,
      "type": "product",
      "gst_rate": "0.0000000000",
      "tax_amount": "0.0000000000",
      "returned_quantity": 0,
      "product": {
        "id": 73,
        "tenant_id": "umer",
        "code": "CHI0SUATR4",
        "name": "CHIROTE 200 GM RS.85",
        "type": "inventory",
        "is_active": "1",
        "available_stock": 2,
        "revenue_account": 26,
        "expense_account": 20,
        "inventory_account": 10,
        "unit_id": 27,
        "sku": "CHI0SUATR4"
      },
      "discount_detail": {
        "id": 2,
        "discount_source": "CAMPAIGN",
        "discount_level": "TRANSACTION",
        "discount_type": "",
        "discount_value": 2,
        "discount_amount": 2.5,
        "discount_tax_type": "BEFORE_TAX",
        "discount_meta": {
          "campaign_name": "VOLUME (Txn - 2-4: 10%)",
          "rule_applied": true,
          "tier_info": [
            {
              "id": 1,
              "discount_id": 1,
              "min_value_or_qty": "2.00",
              "max_value_or_qty": "4.00",
              "discount_type": "PERCENTAGE",
              "discount_value": "10.00",
              "tier_order": 1,
              "appliedQty": 1,
              "tierDiscount": 7.5
            }
          ]
        },
        "is_active": true,
        "created_at": "2026-06-05T11:42:32.000000Z",
        "updated_at": "2026-06-05T11:42:32.000000Z",
        "deleted_at": null
      }
    }
  ],
  "addresses": [
    {
      "id": 66,
      "administrative_area_level_1": "MH",
      "administrative_area_level_2": "Konkan Division",
      "country": "IN",
      "formatted_address": "Grant Road",
      "locality": "Mumbai",
      "postal_code": 400003,
      "route": "Grant Rd",
      "street_number": null,
      "latitude": "18.96196340",
      "longitude": "72.82181210",
      "is_google_address": 1,
      "type": "location",
      "is_primary": false
    }
  ],
  "attachments": [],
  "tags": [],
  "is_recurring": false,
  "invoice_date": "2026-06-05",
  "due_date": "2026-06-05",
  "shipping_date": null,
  "unique_no": "INVOICE-105",
  "reference_no": "INVOICE-105",
  "tracking_no": "INVOICE-105",
  "message_on_invoice": null,
  "message_on_statement": null,
  "status": "open",
  "pdf_url": null,
  "amount": 142.5,
  "tax_rates": [],
  "installments": [],
  "id": 670,
  "balance": 142.5,
  "is_scheduled": 0,
  "recurring_template_id": null,
  "source_type": "accounting",
  "discount_level": null,
  "discount_type": null,
  "discount_value": null,
  "discount_amount": 0,
  "discount_tax_type": null,
  "custom_fields": [],
  "level": "accounting",
  "manage_type": null
}

2. Fetch All Invoices

EndPoint: GET /api/invoices

Description: Retrieves a list of all invoices.

SAMPLE REQUEST

curl -X GET 'https://api.mochaaccounting.com/sales_service/api/invoices' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

3. Fetch A Specific Invoice

EndPoint: GET /api/invoices/:id

Description: Fetches and gets detailed information about a single invoice by its unique ID.

SAMPLE REQUEST

curl -X GET 'https://api.mochaaccounting.com/sales_service/api/invoices/:id' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

4. Delete A Specific Invoice

EndPoint: DELETE /api/invoices/:id

Description: Permanently removes a specific invoice that is no longer needed.

SAMPLE REQUEST

curl -X DELETE 'https://api.mochaaccounting.com/sales_service/api/invoices/:id' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

5. Void A Specific Invoice

EndPoint: PUT /api/invoices/:id

Description: Description: Marks an invoice as void to prevent payment while keeping a record for audit purposes

SAMPLE REQUEST

curl -X PUT 'https://api.mochaaccounting.com/sales_service/api/invoices/void/:id' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

PRODUCT & INVENTORY API GUIDE

This guide provides a deep dive into the Product & Inventory APIs, detailing how to retrieve product metadata, available units, and real-time inventory information to support sales, invoicing, and stock monitoring systems.

The Product & Inventory APIs helps you:

  • Track and manage your product units and stock availability
  • Access up-to-date inventory for all listed products
  • Integrate inventory data with invoicing or order management workflows

API ENDPOINTS

1. Fetch All Product Units

EndPoint: GET -/api/invoices-units

Description: Gets real-time inventory levels and stock status of all your products.

SAMPLE REQUEST

curl -X GET 'https://api.mochaaccounting.com/sales_service/api/invoices-units' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

2. Fetch Specific Product Units

EndPoint: GET -/api/product-units/:id

SAMPLE REQUEST

curl -X GET 'https://api.mochaaccounting.com/sales_service/api/product-units/:id' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

CUSTOMER MANAGEMENT API GUIDE

This guide provides in-depth documentation on the Customer Management API, allowing you to create and manage customer records that can be linked to invoices, orders, and other business functions.

The Customer Management API helps you:

  • Create new customer records
  • Store and manage billing details
  • Prepare customers for invoicing, notifications, and CRM workflows

API ENDPOINTS

1. Create New Customer

EndPoint: POST -/api/customers/:id

Description: Adds a new customer to your database with full contact and billing information.

SAMPLE REQUEST

curl -X POST 'https://api.mochaaccounting.com/sales_service/api/customers/:id' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

CREATE CUSTOMER PAYLOAD

{
  "contact_infos": {
    "display_name": "John Doe",
    "email": "john@gmail.com",
    "phone_number": "+91 89658-77456",
    "type": "customer"
  },
  "addresses": [
    {
      "street_number": null,
      "route": null,
      "locality": "Mumbai",
      "administrative_area_level_1": "MH",
      "administrative_area_level_2": "Konkan Division",
      "country": "IN",
      "postal_code": null,
      "formatted_address": "Lower Parel",
      "google_place_id": "ChIJh1xIbI3O5zsRwB4tHYLUzv8",
      "latitude": 18.9982461,
      "longitude": 72.82696460000001,
      "is_google_address": true,
      "type": "billing"
    }
  ],
  "additional_infos": {
    "customer_type": 1,
    "is_tax_exempt": false,
    "gst_treatment": "Unregistered Business",
    "term_id": 4,
    "company_name": "John"
  },
  "tax_rates": [],
  "payment": []
}

SAMPLE RESPONSE

{
    "id": 2814,
    "user_id": "ab71923c-55c9-497c-98ed-224325e6382e",
    "title": null,
    "first_name": "John",
    "middle_name": null,
    "last_name": "Doe",
    "display_name": "John Doe",
    "name_on_checks": null,
    "email": "john@gmail.com",
    "phone_number": "+91 89658-77456",
    "mobile_number": null,
    "type": "customer",
    "shopify_id": null,
    "tax_number": null,
    "tax_profile": null,
    "notes": [],
    "attachments": [],
    "addresses": [],
    "tax_rates": [],
    "add_infos": [
        {
            "id": 2796,
            "parent_id": null,
            "customer_type": null,
            "company_name": null,
            "suffix": null,
            "fax": null,
            "website": null,
            "other": null,
            "exemption_id": null,
            "exemption_details": null,
            "opening_balance": 0,
            "as_of_balance": null,
            "payment_method_id": null,
            "delivery_method": "none",
            "term_id": null,
            "is_tax_exempt": false,
            "tax_number": null,
            "gst_treatment": null,
            "customer_classification": "regular",
            "sez_supply_mode": null,
            "lut_reference": null,
            "pets": false,
            "resident_access": false,
            "occupants": 0,
            "user_id": null
        }
    ],
    "open_balance": 0,
    "over_due": 0,
    "is_active": true,
    "custom_fields": [],
    "contact_persons": [],
    "home_no": null,
    "business_no": null,
    "other_contact": null
}

SALES COMMUNICATION API GUIDE

This guide explains how to use the Sales Communication APIs to send targeted sales emails to your customers, enabling personalized outreach and follow-up as part of your business workflow.

The Sales Communication API helps you:

  • Programmatically send emails to customers
  • Include promotional messages, invoice links, or product updates
  • Track communication status per customer

API ENDPOINTS

1. Send A Sales Email

EndPoint: POST -/api/send-sales-email/:id

Description: Triggers an automated sales email with personalized content to enhance customer engagement.

SAMPLE REQUEST

curl -X POST 'https://api.mochaaccounting.com/sales_service/api/send-sales-email/:id' \
  -H 'X-Tenant: Your X-Tenant' \
  -H 'API Key: Your API-Key'

SAMPLE RESPONSE

STATUS CODES GUIDE

This guide outlines the standard status codes returned by all the APIs. Understanding these codes will help you handle failures gracefully, debug faster, and ensure robust integrations. Every API request returns an HTTP status code. Below is a list of the most common status codes.

DescriptionCodeMessage
Request was successful200OK
Resource was successfully created201Created
Missing required fields400Bad Request
Missing or invalid auth token401Unauthorized
Valid token but action not allowed403Forbidden
Resource not found404Not Found
HTTP method not supported405Method not allowed
Duplicate resource409Conflict
Unexpected error on server500Internal server error
Invalid response502Bad gateway
API is temporary unavailable503Service unavailable
Server took too long to respond504Gateway timeout