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-0012. 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 Name | Data Type | Req | Default | Description & BIR Rule |
|---|---|---|---|---|
| id / public_id | string | Optional | inv_... | Cryptographically shielded public invoice identifier (internal surrogate DB IDs are never exposed). |
| uuid | string (UUID) | Optional | auto-generated | Unique transaction UUID for BIR EIS transmission and audit trail. |
| workspace_id | string | Optional | "CMP-001" | Multi-tenant company workspace code (also accepted via X-Workspace-Id header). |
| company_code | string | Required | "CMP-001" | Registered company code issuing the electronic invoice. |
| company_name | string | Optional | Workspace Name | Registered BIR taxpayer corporate/trade name. |
| company_tin | string | Optional | "009-814-571-00000" | Issuing company BIR Tax Identification Number (TIN). |
| company_address | string | Optional | — | Registered business address printed on the BIR header. |
| company_permit_no | string | Optional | — | BIR CAS / ATP Permit Number (e.g. BIR-ACC-2026-009814). |
| invoice_no | string (9-digit) | Optional | "000000001" | Strict 9-digit zero-padded sequential BIR invoice series per workspace. |
| tran_date | string (ISO 8601) | Optional | now() | Transaction timestamp (e.g. 2026-10-29T08:00:00.000Z). |
| status | "Ok" | "Cancelled" | Optional | "Ok" | Invoice lifecycle status in the ledger (Ok or Cancelled). |
| currency | string | Optional | "PHP" | ISO 4217 currency code. |
| idempotency_key | string | Optional | — | Unique key passed via Idempotency-Key header to prevent duplicate billing. |
| md_code | string | Optional | — | Prescribing Medical Doctor code (for pharmaceutical / healthcare transactions). |
| md_name | string | Optional | — | Prescribing Medical Doctor full name printed on receipt. |
| md_prc_no | string | Optional | — | Medical Doctor PRC License Number. |
| solo_parent_child | array<object> | Optional | [] | Dependent child details [{ child_name, child_birthdate, child_age }] for RA 11861 Solo Parent transactions. |
| receipt_url | string (URL) | Optional | — | Direct URL to stream or download the BIR-compliant PDF receipt (/v1/invoices/:id/receipt). |
| receipt_status | string | Optional | "generated" | PDF generation status ("none" | "queued" | "generated" | "failed"). |
Invoice Line Item Fields (items[])
Table: invoice_itemsPOST /v1/invoices → items[]
| Field Name | Data Type | Req | Default | Description & BIR Rule |
|---|---|---|---|---|
| id / public_id | string | Optional | item_... | Public line item identifier. |
| barcode | string | Required | "4800016629102" | SKU barcode / product code. |
| itemdesc | string | Required | — | Line item product or service description (alias: description). |
| unit | string | Optional | "pcs" | Unit of measurement (e.g. "pcs", "box", "btl", "lot"). |
| qty | number | Required | 1 | Quantity sold (alias: quantity). |
| srp | integer (centavos) | Required | 0 | Suggested Retail Price / Unit price in integer centavos (e.g. 96000 = ₱960.00; alias: unit_price). |
| grossamt | integer (centavos) | Optional | qty * srp | Line item gross amount (qty × srp) in centavos. |
| vatclass | string | Optional | "VATABLE" | "VATABLE" | "VAT_EXEMPT" | "ZERO_RATED" | "VAT_EXEMPT_SC" | "VAT_EXEMPT_PWD" | "VAT_EXEMPT_NAAC" | "VAT_EXEMPT_SOLO". |
| scpwd | boolean | Optional | false | Whether this SKU is eligible for statutory SC / PWD / NAAC / Solo Parent discount. |
| discount1 / discamt1 | integer (centavos) | Optional | 0 | Trade Discount 1 amount in centavos (computed from discper1 %). |
| discper1 | float (%) | Optional | 0 | Trade Discount 1 percentage (0–100%). |
| discount2 / discamt2 | integer (centavos) | Optional | 0 | Trade Discount 2 amount in centavos (computed from discper2 %). |
| discper2 | float (%) | Optional | 0 | Trade Discount 2 percentage (0–100%). |
| spldisc / spldiscamt | integer (centavos) | Optional | 0 | Special / statutory discount amount applied to the line item in centavos. |
| spldiscper | float (%) | Optional | 0 | Special discount percentage applied to the line item. |
| spldesc | string | Optional | — | Special discount description (e.g. "Senior Citizen 20% Discount (RA 9994)"). |
| scdisc / scper | integer / float | Optional | 0 / 20% | Senior Citizen (RA 9994) discount amount (centavos) and rate (default 20% of VAT-exempt base). |
| pwddisc / pwdper | integer / float | Optional | 0 / 20% | Person With Disability (RA 10754) discount amount (centavos) and rate (default 20%). |
| naacdisc / naacper | integer / float | Optional | 0 / 20% | National Athletes & Coaches (RA 10699) discount amount (centavos) and rate (default 20%). |
| solodisc / soloper | integer / float | Optional | 0 / 10% | Solo Parent (RA 11861) discount amount (centavos) and rate (default 10%). |
| vatsales / vatablesales | integer (centavos) | Optional | 0 | Line item net VATable sales (netamt / 1.12 for VATABLE items). |
| vatamt | integer (centavos) | Optional | 0 | Line item 12% output VAT amount (netamt - vatsales). |
| vatexempt / vatexemptsales | integer (centavos) | Optional | 0 | Line item VAT-Exempt sales amount. |
| zerorated | integer (centavos) | Optional | 0 | Line item Zero-Rated sales amount. |
| netamt | integer (centavos) | Optional | 0 | Final line item net payable amount after VAT exemption and all discounts. |
Invoice Tax & Discount Summary Fields
Table: invoices (summary)Response → attributes.summary
| Field Name | Data Type | Req | Default | Description & BIR Rule |
|---|---|---|---|---|
| summary.gross_amount | integer (centavos) | Optional | 0 | Total gross sales amount across all line items in integer centavos (e.g. 960000 = ₱9,600.00). |
| summary.vatable_sales | integer (centavos) | Optional | 0 | Total net VATable sales (net of 12% VAT). |
| summary.vat_exempt_sales | integer (centavos) | Optional | 0 | Total VAT-Exempt sales (including statutory SC, PWD, NAAC, and Solo Parent exempt sales). |
| summary.zero_rated_sales | integer (centavos) | Optional | 0 | Total Zero-Rated (0% VAT) sales. |
| summary.vat_amount | integer (centavos) | Optional | 0 | Total 12% output VAT amount in integer centavos. |
| summary.special_discount_amount | integer (centavos) | Optional | 0 | Total statutory special discount (SC 20%, PWD 20%, NAAC 20%, Solo Parent 10%). |
| summary.regular_discount_amount | integer (centavos) | Optional | 0 | Combined Trade Discount 1 (discount1) + Trade Discount 2 (discount2). |
| summary.promo_discount_amount | integer (centavos) | Optional | 0 | Promotional / commercial discount amount. |
| summary.net_amount / total_amount | integer (centavos) | Optional | 0 | Final net payable settlement amount in integer centavos. |
Customer & Statutory Beneficiary Fields
Table: customersPOST /v1/customers & invoice.customer
| Field Name | Data Type | Req | Default | Description & BIR Rule |
|---|---|---|---|---|
| id / public_id | string | Optional | cus_... | Public customer identifier. |
| custcode / customer_code | string | Optional | "CUS-00001" | Unique customer code per workspace (or "WALK-IN" for walk-in buyers). |
| name | string | Required | — | Customer full name or registered corporate entity name. |
| string | Required | — | Customer billing email address. | |
| address | string | Optional | — | Customer business or residential address. |
| tin | string | Optional | — | Customer BIR Tax Identification Number (e.g. 123-456-789-000). |
| contact_number | string | Optional | — | Customer landline or mobile contact number. |
| taxpayer_classification | string | Optional | "VAT" | "VAT" | "NonVAT" | "SC" | "PWD" | "NAAC" | "SOLO_PARENT". Determines statutory tax & discount computation. |
| birthdate | string (YYYY-MM-DD) | Optional | — | Customer date of birth (used for Senior Citizen age verification). |
| age | integer | Optional | — | Customer age in years (60+ required for Senior Citizen classification). |
| osca_id | string | Optional | — | Senior Citizen OSCA ID / Booklet Control Number (required when classification is SC). |
| pwd_id | string | Optional | — | PWD Identification Card Number (required when classification is PWD). |
| disability_type | string | Optional | — | Type of disability for PWD ledger reporting (e.g. Psychosocial, Orthopedic, Visual). |
| naac_id | string | Optional | — | 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_id | string | Optional | — | Solo Parent Identification Card (SPIC) Number (required when classification is SOLO_PARENT). |
| child_name | string | Optional | — | Authorized dependent child full name (for RA 11861 Solo Parent ledger). |
| child_birthdate | string (YYYY-MM-DD) | Optional | — | Dependent child date of birth. |
| child_age | integer | Optional | — | Dependent child age (must be 6 years old or under for RA 11861 statutory discount). |
| child_psa_no | string | Optional | — | Dependent child PSA Birth Certificate Number. |
| workspace_id | string | Optional | "CMP-001" | Workspace code that owns this customer record. |
SKU Line Item Catalog Fields
Table: sku_itemsPOST /v1/skus
| Field Name | Data Type | Req | Default | Description & BIR Rule |
|---|---|---|---|---|
| id / public_id | string | Optional | sku_... | Public SKU item identifier. |
| workspace_id | string | Optional | "CMP-001" | Workspace code partitioning the SKU catalog. |
| barcode | string | Required | — | Unique product barcode / SKU code. |
| itemdesc | string | Required | — | Product / service item description. |
| unit | string | Optional | "pcs" | Unit of measure ("pcs", "box", "btl", "pack", "service"). |
| srp | integer (centavos) | Required | 0 | Suggested Retail Price in integer centavos (e.g. 96000 = ₱960.00). |
| vatclass | string | Optional | "VATABLE" | "VATABLE" | "VAT_EXEMPT" | "ZERO_RATED". |
| scpwd | boolean | Optional | false | Enables statutory SC / PWD / NAAC / Solo Parent discount eligibility for this item. |
| spldiscper | float (%) | Optional | 0 | Promotional / special discount percentage. |
| discountper1 | float (%) | Optional | 0 | Trade Discount 1 percentage. |
| discountper2 | float (%) | Optional | 0 | Trade Discount 2 percentage. |
| scper | float (%) | Optional | 20 | Senior Citizen statutory discount percentage (default 20%). |
| pwdper | float (%) | Optional | 20 | PWD statutory discount percentage (default 20%). |
| naacper | float (%) | Optional | 20 | NAAC statutory discount percentage (default 20%). |
| soloper | float (%) | Optional | 10 | Solo Parent statutory discount percentage (default 10%). |
| active | boolean | Optional | true | Whether the SKU is active and selectable in invoice creation. |