GETTING STARTED

API Quickstart & Overview

Learn how to connect to the E-Invoice platform, authenticate with SHA-256 API keys, and issue your first BIR-compliant electronic invoice using the complete table schema.

1. Authentication

All REST requests require a valid API bearer token passed via the Authorization header and your workspace code in X-Workspace-Id. You can generate Live or Test mode keys from the developer dashboard.

Authorization: Bearer sk_live_89f3a9a12c4e5f...
X-Workspace-Id: CMP-001

2. Issue an Invoice (cURL Example)

Includes the full invoices, customers, and invoice_items table fields (monetary figures in integer centavos).

curl -X POST https://api-production-618c.up.railway.app/v1/invoices \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "X-Workspace-Id: CMP-001" \
  -H "Idempotency-Key: idem_tx_20261029_001" \
  -H "Content-Type: application/json" \
  -d '{
    "workspace_id": "CMP-001",
    "company_code": "CMP-001",
    "invoice_no": "000000001",
    "tran_date": "2026-10-29T08:30:00.000Z",
    "currency": "PHP",
    "status": "Ok",
    "customer": {
      "customer_code": "CUS-00001",
      "name": "Medical Health Experts Inc.",
      "email": "billing@medicalhealth.ph",
      "tin": "123-456-789-000",
      "address": "Pasig City, Philippines",
      "contact_number": "0917-123-4567",
      "taxpayer_classification": "SC",
      "birthdate": "1958-04-15",
      "age": 68,
      "osca_id": "OSCA-2026-8821"
    },
    "items": [
      {
        "barcode": "4806539930001",
        "itemdesc": "Alaprime SG Cap 1x30",
        "unit": "box",
        "qty": 10,
        "srp": 96000,
        "grossamt": 960000,
        "vatclass": "VAT_EXEMPT_SC",
        "scpwd": true,
        "discper1": 0,
        "discount1": 0,
        "discper2": 0,
        "discount2": 0,
        "scper": 20,
        "scdisc": 171429,
        "spldisc": 171429,
        "spldiscper": 20,
        "spldesc": "Senior Citizen 20% Discount (RA 9994)",
        "vatsales": 0,
        "vatamt": 0,
        "vatexempt": 685714,
        "zerorated": 0,
        "netamt": 685714
      }
    ],
    "md_code": "MD-0012",
    "md_name": "Dr. Josefa Cruz, MD",
    "md_prc_no": "PRC-0129481"
  }'

3. Node.js & TypeScript SDK

import { EInvoiceClient } from '@einvoice/sdk';

const client = new EInvoiceClient({
  apiKey: process.env.EINVOICE_SECRET_KEY,
  workspaceId: 'CMP-001',
});

// Idempotent BIR Invoice creation aligned with invoices, customers, and invoice_items tables
const invoice = await client.invoices.create({
  workspace_id: 'CMP-001',
  company_code: 'CMP-001',
  status: 'Ok',
  currency: 'PHP',
  customer: {
    customer_code: 'CUS-00001',
    name: 'Medical Health Experts and Associates Inc.',
    email: 'billing@medicalhealth.ph',
    tin: '123-456-789-000',
    address: 'Pasig City, Philippines',
    contact_number: '0917-123-4567',
    taxpayer_classification: 'SC', // 'VAT' | 'NonVAT' | 'SC' | 'PWD' | 'NAAC' | 'SOLO_PARENT'
    birthdate: '1958-04-15',
    age: 68,
    osca_id: 'OSCA-2026-8821',
  },
  items: [
    {
      barcode: '4806539930001',
      itemdesc: 'Alaprime SG Cap 1x30',
      unit: 'box',
      qty: 10,
      srp: 96000, // Integer centavos (₱960.00)
      vatclass: 'VAT_EXEMPT_SC',
      scpwd: true,
      scper: 20,
      discper1: 0,
      discper2: 0,
    },
  ],
}, { idempotencyKey: 'idem_tx_20261029_001' });

console.log('Invoice Public ID:', invoice.id);
console.log('9-Digit BIR Series:', invoice.invoice_no);
console.log('Net Payable (centavos):', invoice.attributes.summary.net_amount);
console.log('Streamed BIR PDF receipt:', invoice.receipt_url);

4. Core Table Structures & API Fields

Complete field mapping for the invoices, invoice_items, customers, and sku_items database tables.

Invoice Header Fields

Table: invoicesPOST /v1/invoices
Field NameData TypeReqDefaultDescription & BIR Rule
id / public_idstringOptionalinv_...Cryptographically shielded public invoice identifier (internal surrogate DB IDs are never exposed).
uuidstring (UUID)Optionalauto-generatedUnique transaction UUID for BIR EIS transmission and audit trail.
workspace_idstringOptional"CMP-001"Multi-tenant company workspace code (also accepted via X-Workspace-Id header).
company_codestringRequired"CMP-001"Registered company code issuing the electronic invoice.
company_namestringOptionalWorkspace NameRegistered BIR taxpayer corporate/trade name.
company_tinstringOptional"009-814-571-00000"Issuing company BIR Tax Identification Number (TIN).
company_addressstringOptional—Registered business address printed on the BIR header.
company_permit_nostringOptional—BIR CAS / ATP Permit Number (e.g. BIR-ACC-2026-009814).
invoice_nostring (9-digit)Optional"000000001"Strict 9-digit zero-padded sequential BIR invoice series per workspace.
tran_datestring (ISO 8601)Optionalnow()Transaction timestamp (e.g. 2026-10-29T08:00:00.000Z).
status"Ok" | "Cancelled"Optional"Ok"Invoice lifecycle status in the ledger (Ok or Cancelled).
currencystringOptional"PHP"ISO 4217 currency code.
idempotency_keystringOptional—Unique key passed via Idempotency-Key header to prevent duplicate billing.
md_codestringOptional—Prescribing Medical Doctor code (for pharmaceutical / healthcare transactions).
md_namestringOptional—Prescribing Medical Doctor full name printed on receipt.
md_prc_nostringOptional—Medical Doctor PRC License Number.
solo_parent_childarray<object>Optional[]Dependent child details [{ child_name, child_birthdate, child_age }] for RA 11861 Solo Parent transactions.
receipt_urlstring (URL)Optional—Direct URL to stream or download the BIR-compliant PDF receipt (/v1/invoices/:id/receipt).
receipt_statusstringOptional"generated"PDF generation status ("none" | "queued" | "generated" | "failed").

Invoice Line Item Fields (items[])

Table: invoice_itemsPOST /v1/invoices → items[]
Field NameData TypeReqDefaultDescription & BIR Rule
id / public_idstringOptionalitem_...Public line item identifier.
barcodestringRequired"4800016629102"SKU barcode / product code.
itemdescstringRequired—Line item product or service description (alias: description).
unitstringOptional"pcs"Unit of measurement (e.g. "pcs", "box", "btl", "lot").
qtynumberRequired1Quantity sold (alias: quantity).
srpinteger (centavos)Required0Suggested Retail Price / Unit price in integer centavos (e.g. 96000 = ₱960.00; alias: unit_price).
grossamtinteger (centavos)Optionalqty * srpLine item gross amount (qty × srp) in centavos.
vatclassstringOptional"VATABLE""VATABLE" | "VAT_EXEMPT" | "ZERO_RATED" | "VAT_EXEMPT_SC" | "VAT_EXEMPT_PWD" | "VAT_EXEMPT_NAAC" | "VAT_EXEMPT_SOLO".
scpwdbooleanOptionalfalseWhether this SKU is eligible for statutory SC / PWD / NAAC / Solo Parent discount.
discount1 / discamt1integer (centavos)Optional0Trade Discount 1 amount in centavos (computed from discper1 %).
discper1float (%)Optional0Trade Discount 1 percentage (0–100%).
discount2 / discamt2integer (centavos)Optional0Trade Discount 2 amount in centavos (computed from discper2 %).
discper2float (%)Optional0Trade Discount 2 percentage (0–100%).
spldisc / spldiscamtinteger (centavos)Optional0Special / statutory discount amount applied to the line item in centavos.
spldiscperfloat (%)Optional0Special discount percentage applied to the line item.
spldescstringOptional—Special discount description (e.g. "Senior Citizen 20% Discount (RA 9994)").
scdisc / scperinteger / floatOptional0 / 20%Senior Citizen (RA 9994) discount amount (centavos) and rate (default 20% of VAT-exempt base).
pwddisc / pwdperinteger / floatOptional0 / 20%Person With Disability (RA 10754) discount amount (centavos) and rate (default 20%).
naacdisc / naacperinteger / floatOptional0 / 20%National Athletes & Coaches (RA 10699) discount amount (centavos) and rate (default 20%).
solodisc / soloperinteger / floatOptional0 / 10%Solo Parent (RA 11861) discount amount (centavos) and rate (default 10%).
vatsales / vatablesalesinteger (centavos)Optional0Line item net VATable sales (netamt / 1.12 for VATABLE items).
vatamtinteger (centavos)Optional0Line item 12% output VAT amount (netamt - vatsales).
vatexempt / vatexemptsalesinteger (centavos)Optional0Line item VAT-Exempt sales amount.
zeroratedinteger (centavos)Optional0Line item Zero-Rated sales amount.
netamtinteger (centavos)Optional0Final line item net payable amount after VAT exemption and all discounts.

Invoice Tax & Discount Summary Fields

Table: invoices (summary)Response → attributes.summary
Field NameData TypeReqDefaultDescription & BIR Rule
summary.gross_amountinteger (centavos)Optional0Total gross sales amount across all line items in integer centavos (e.g. 960000 = ₱9,600.00).
summary.vatable_salesinteger (centavos)Optional0Total net VATable sales (net of 12% VAT).
summary.vat_exempt_salesinteger (centavos)Optional0Total VAT-Exempt sales (including statutory SC, PWD, NAAC, and Solo Parent exempt sales).
summary.zero_rated_salesinteger (centavos)Optional0Total Zero-Rated (0% VAT) sales.
summary.vat_amountinteger (centavos)Optional0Total 12% output VAT amount in integer centavos.
summary.special_discount_amountinteger (centavos)Optional0Total statutory special discount (SC 20%, PWD 20%, NAAC 20%, Solo Parent 10%).
summary.regular_discount_amountinteger (centavos)Optional0Combined Trade Discount 1 (discount1) + Trade Discount 2 (discount2).
summary.promo_discount_amountinteger (centavos)Optional0Promotional / commercial discount amount.
summary.net_amount / total_amountinteger (centavos)Optional0Final net payable settlement amount in integer centavos.

Customer & Statutory Beneficiary Fields

Table: customersPOST /v1/customers & invoice.customer
Field NameData TypeReqDefaultDescription & BIR Rule
id / public_idstringOptionalcus_...Public customer identifier.
custcode / customer_codestringOptional"CUS-00001"Unique customer code per workspace (or "WALK-IN" for walk-in buyers).
namestringRequired—Customer full name or registered corporate entity name.
emailstringRequired—Customer billing email address.
addressstringOptional—Customer business or residential address.
tinstringOptional—Customer BIR Tax Identification Number (e.g. 123-456-789-000).
contact_numberstringOptional—Customer landline or mobile contact number.
taxpayer_classificationstringOptional"VAT""VAT" | "NonVAT" | "SC" | "PWD" | "NAAC" | "SOLO_PARENT". Determines statutory tax & discount computation.
birthdatestring (YYYY-MM-DD)Optional—Customer date of birth (used for Senior Citizen age verification).
ageintegerOptional—Customer age in years (60+ required for Senior Citizen classification).
osca_idstringOptional—Senior Citizen OSCA ID / Booklet Control Number (required when classification is SC).
pwd_idstringOptional—PWD Identification Card Number (required when classification is PWD).
disability_typestringOptional—Type of disability for PWD ledger reporting (e.g. Psychosocial, Orthopedic, Visual).
naac_idstringOptional—PNSTMID / PSC Identification Number (required when classification is NAAC).
athlete_coach_type"National Athlete" | "National Coach"Optional—Classification role under RA 10699 (National Athlete or National Coach).
solo_parent_idstringOptional—Solo Parent Identification Card (SPIC) Number (required when classification is SOLO_PARENT).
child_namestringOptional—Authorized dependent child full name (for RA 11861 Solo Parent ledger).
child_birthdatestring (YYYY-MM-DD)Optional—Dependent child date of birth.
child_ageintegerOptional—Dependent child age (must be 6 years old or under for RA 11861 statutory discount).
child_psa_nostringOptional—Dependent child PSA Birth Certificate Number.
workspace_idstringOptional"CMP-001"Workspace code that owns this customer record.

SKU Line Item Catalog Fields

Table: sku_itemsPOST /v1/skus
Field NameData TypeReqDefaultDescription & BIR Rule
id / public_idstringOptionalsku_...Public SKU item identifier.
workspace_idstringOptional"CMP-001"Workspace code partitioning the SKU catalog.
barcodestringRequired—Unique product barcode / SKU code.
itemdescstringRequired—Product / service item description.
unitstringOptional"pcs"Unit of measure ("pcs", "box", "btl", "pack", "service").
srpinteger (centavos)Required0Suggested Retail Price in integer centavos (e.g. 96000 = ₱960.00).
vatclassstringOptional"VATABLE""VATABLE" | "VAT_EXEMPT" | "ZERO_RATED".
scpwdbooleanOptionalfalseEnables statutory SC / PWD / NAAC / Solo Parent discount eligibility for this item.
spldiscperfloat (%)Optional0Promotional / special discount percentage.
discountper1float (%)Optional0Trade Discount 1 percentage.
discountper2float (%)Optional0Trade Discount 2 percentage.
scperfloat (%)Optional20Senior Citizen statutory discount percentage (default 20%).
pwdperfloat (%)Optional20PWD statutory discount percentage (default 20%).
naacperfloat (%)Optional20NAAC statutory discount percentage (default 20%).
soloperfloat (%)Optional10Solo Parent statutory discount percentage (default 10%).
activebooleanOptionaltrueWhether the SKU is active and selectable in invoice creation.