All Documents API

Introduction
 

The All Documents API is the central document-processing engine of the Biz1 system.
It is designed as a single, unified API layer through which all business documents are created, managed, linked, delivered, retrieved, and audited.
 

Instead of exposing many different APIs for invoices, receipts, orders, and payments, Biz1 provides one powerful API that dynamically adapts its behavior based on parameters—primarily the document_type.
 

This API supports every business flow and every accounting requirement, without forcing external systems to duplicate business logic.
 


Who Uses This API
 

The All Documents API is intended to be used by:
 

  • Websites and e-commerce platforms

  • Mobile applications

  • CRM systems

  • ERP systems

  • Accounting and finance integrations

  • POS systems

  • Automation scripts and background jobs
     

Any system that needs to issue invoices, receipts, orders, donation documents, or accounting records can rely entirely on this API.
 



Base URLs and Entry Points
 

All interactions start from one of the following base domains:
 

  • Production domain

    https://biz1.co.il/

  • Alternative domain

    https://bull36.com/
     

Both domains expose the same API behavior.
 


Main Document Creation URLs
 

add_order2 – Primary Creation Endpoint
 

https://biz1.co.il/api.php?api=add_order2
 

This is the main external URL used to create documents.
 

It is responsible for:

 

  • Creating invoices

  • Creating receipts

  • Creating orders

  • Creating donation receipts

  • Creating credit and return documents

  • Triggering workflow automation
     

External systems normally interact only with this URL for document creation.
 


create_document – Alias of add_order2
 

https://biz1.co.il/api.php?api=create_document
 

This URL is functionally identical to add_order2.
 

It exists for:
 

  • Backward compatibility

  • Cleaner naming for integrations

  • Historical support
     

Both URLs route to the same internal logic.
 



What “Documents” Mean in Biz1
 

In Biz1, a document is any official business record that represents one of the following:
 

  • A financial transaction

  • A commitment to sell or purchase

  • A confirmation of payment

  • A delivery or return of goods

  • A donation or subscription
     

All documents share a common internal structure, but their behavior changes depending on the document type.
This allows Biz1 to remain flexible while still enforcing accounting, tax, and legal rules.
 



Types of Documents and Their Purpose
 

Invoice Documents
 

Invoices represent billing events.

A tax invoice is issued when charging a customer.
A credit invoice reverses or reduces a previous invoice.
A proforma invoice is a preliminary invoice used for approval.
A delivery invoice documents shipped goods.
A return invoice records returned goods.
A GR/IR document supports accounting reconciliation of goods and invoices.
 

Invoice documents:
 

  • Can contain products

  • Can include VAT

  • Always generate PDFs

  • Appear in accounting records
     


Receipt Documents
 

Receipts represent payment events.

A standard receipt confirms money received.
A receipt tax invoice includes tax reporting.
A partly paid receipt records partial payments.
A donation receipt records donations, often with special tax handling.
 

Receipts:
 

  • May include products or only a total amount

  • Always represent money movement

  • Update payment status of related documents
     



Order Documents
 

Orders represent intent and workflow, not payment.
 

Order proposals are quotations.
Purchase orders are issued to suppliers.
Detail orders store structured order information.
 

Orders:
 

  • Can later generate invoices

  • Are often linked to receipts

  • Track the business process before payment
     


How the All Documents API Runs Internally

When an external system calls:
 

https://biz1.co.il/api.php?api=add_order2
 

the following execution flow occurs inside Biz1.
 


Step 1: Authentication
 

The API validates the api_token.
 

If invalid:
 

  • The request stops immediately

  • No document is created

  • No customer is modified
     

If valid:
 

  • The user is loaded

  • Organization settings are applied

  • Permissions are enforced
     


Step 2: Document Type Resolution
 

The API reads document_type and determines:
 

  • Which internal document engine to use

  • Which validation rules apply

  • Which PDF template should be selected

  • Whether products are required

  • Whether payment data is required
     

This step controls everything that follows.
 


Step 3: Customer Resolution
 

The API determines who the document belongs to.
 

Two paths exist:
 

If cust_id is provided:
 

  • The existing customer is loaded directly
     

If cust_id is not provided:
 

  • The API uses name, email, and phone

  • An existing customer is reused if found

  • Otherwise, a new customer is created automatically
     

This means no separate customer creation API is required.
 


Step 4: Order Object Processing
 

The order JSON object defines document-level behavior.
 

The API:
 

  • Sets the currency

  • Sets VAT percentage

  • Applies notes

  • Registers global discounts
     

This becomes the financial foundation of the document.
 


Step 5: Product and Line Item Handling
 

If the document type requires products:
 

  • Each SKU is validated or auto-created

  • Price and quantity are validated

  • Discounts are applied

  • VAT inclusion is handled correctly
     

The system calculates:
 

  • Line totals

  • Discount impact

  • Tax values
     

If the document is a receipt using all_items_total, this step is skipped.
 


Step 6: Payment Handling (Receipt Documents)
 

For receipt-based documents:
 

  • Payment method is recorded

  • Credit card identifiers are stored (last 4 digits)

  • Installments are handled

  • Documents are marked as paid or partly paid
     

This directly affects:
 

  • Accounting status

  • Customer balance

  • Linked document state
     


Step 7: Workflow Automation
 

If automation flags are present:
 

  • invoice_create

  • reciept_tax_invoice
     

The system automatically creates additional documents.
 

Examples:
 

  • Order → Invoice

  • Order → Invoice → Receipt
     

All documents are:
 

  • Linked together

  • Stored atomically

  • Treated as one logical transaction
     


Step 8: Document Persistence
 

The document is saved in the database.
 

At this point:
 

  • A document ID is generated

  • Relationships are stored

  • Financial values are finalized
     


Step 9: PDF Generation
 

For finalized documents:
 

  • The correct PDF template is selected

  • Branding and language are applied

  • A PDF is rendered

  • The file is stored securely
     

The PDF becomes the official document output.
 



Step 10: Delivery (Optional)
 

If delivery flags are enabled:
 

  • Email sends the PDF as an attachment

  • WhatsApp sends a secure document link
     

Delivery happens asynchronously and does not block creation.
 


Document Retrieval URL
 

To retrieve documents later, systems call:
 

https://biz1.co.il/api/get_document
 

This API:
 

  • Authenticates the request

  • Filters by customer

  • Filters by document type

  • Applies date filters

  • Returns document metadata and PDF paths
     

Used for:
 

  • Customer portals

  • Admin dashboards

  • Reports

  • Audits
     


PDF Viewing URL
 

To view or download a PDF:
 

https://biz1.co.il/dashboard/api/filesview?url=ENCODED_PDF_PATH
 

This URL:
 

  • Streams PDFs securely

  • Prevents direct file access

  • Supports browser viewing and downloads
     

Used in:
 

  • Email links

  • WhatsApp messages

  • Admin interfaces
     



Real-World End-to-End Example
 

A typical business flow looks like this:
 

  1. Customer completes checkout

  2. System calls add_order2

  3. Order document is created

  4. Invoice is auto-created

  5. Payment is confirmed

  6. Receipt tax invoice is created

  7. PDF is generated

  8. PDF is emailed and sent via WhatsApp

  9. Admin retrieves documents via get_document

  10. PDF is viewed via filesview
     

All using one unified API system.
 



Why This API Design Matters
 

The All Documents API:
 

  • Eliminates duplicated accounting logic

  • Prevents inconsistent documents

  • Ensures tax compliance

  • Simplifies integrations

  • Scales across business sizes

  • Keeps a clean audit trail
     

It is built to be future-proof, extensible, and secure.
 


Final Understanding
 

If someone asks:
 

“What does the All Documents API do?”
 

The correct answer is:
 

It is the single authoritative interface for creating, managing, linking, delivering, retrieving, and auditing every business document in Biz1 — from the first order to the final receipt.
 

information_img