Getting Started
This comprehensive guide will walk you through everything you need to know to get started with BigLedger APIs, from authentication to creating your first business transactions.
Overview
BigLedger’s RESTful APIs are built on modern standards and designed for ease of use:
- RESTful Design: Standard HTTP methods (GET, POST, PUT, DELETE)
- JSON Everywhere: All requests and responses use JSON format
- Consistent Structure: Predictable URL patterns and response formats
- Comprehensive: Complete CRUD operations for all business entities
- Real-time: WebSocket connections and webhooks for live updates
- Secure: Industry-standard OAuth 2.0 and API key authentication
Quick Start Checklist
Prerequisites
Before you begin, ensure you have:
- A BigLedger account (sign up at bigledger.com)
- Basic knowledge of RESTful APIs
- A development environment with HTTP client capabilities
Step 1: Get Your API Key
Log in to BigLedger
- Go to app.bigledger.com
- Sign in with your credentials
Navigate to API Settings
- Click on Settings in the main menu
- Select API Keys from the sidebar
Generate API Key
- Click Create New API Key
- Enter a descriptive name (e.g., “My Integration”)
- Select the required permissions
- Click Generate Key
Copy Your Credentials
API Key: blg_live_sk_1234567890abcdef Company ID: company_abc123
Step 2: Test Your Connection
Let’s verify your API key works by fetching your company information.
Using cURL
curl -X GET "https://api.bigledger.com/v1/company" \
-H "Authorization: Bearer blg_live_sk_1234567890abcdef" \
-H "Content-Type: application/json" \
-H "X-Company-Id: company_abc123"
Expected Response
{
"success": true,
"data": {
"id": "company_abc123",
"name": "Acme Corporation",
"currency": "MYR",
"country": "MY",
"plan": "professional",
"createdAt": "2024-01-01T00:00:00Z"
},
"meta": {
"timestamp": "2024-01-15T10:30:00Z",
"requestId": "req_123456789"
}
}
If you see this response, congratulations! Your API key is working correctly.
Step 3: Your First Business Operation
Now let’s create a customer record - one of the most common operations:
Create a Customer
curl -X POST "https://api.bigledger.com/v1/customers" \
-H "Authorization: Bearer blg_live_sk_1234567890abcdef" \
-H "Content-Type: application/json" \
-H "X-Company-Id: company_abc123" \
-d '{
"name": "Test Customer",
"email": "test@example.com",
"phone": "+60123456789",
"address": {
"street": "123 Main Street",
"city": "Kuala Lumpur",
"state": "Selangor",
"postalCode": "50000",
"country": "MY"
},
"taxNumber": "123456789012",
"creditLimit": 10000.00,
"paymentTerms": 30
}'
Response
{
"success": true,
"data": {
"id": "cust_789xyz123",
"customerNumber": "CUST-0001",
"name": "Test Customer",
"email": "test@example.com",
"phone": "+60123456789",
"address": {
"street": "123 Main Street",
"city": "Kuala Lumpur",
"state": "Selangor",
"postalCode": "50000",
"country": "MY"
},
"taxNumber": "123456789012",
"creditLimit": 10000.00,
"currentBalance": 0.00,
"paymentTerms": 30,
"status": "active",
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
},
"meta": {
"timestamp": "2024-01-15T10:30:00Z",
"requestId": "req_987654321"
}
}
Step 4: Create Your First Invoice
Let’s create a sales invoice for the customer we just created:
curl -X POST "https://api.bigledger.com/v1/invoices" \
-H "Authorization: Bearer blg_live_sk_1234567890abcdef" \
-H "Content-Type: application/json" \
-H "X-Company-Id: company_abc123" \
-d '{
"customerId": "cust_789xyz123",
"invoiceDate": "2024-01-15",
"dueDate": "2024-02-14",
"reference": "PO-12345",
"items": [
{
"description": "Professional Services",
"quantity": 10,
"unitPrice": 100.00,
"taxCode": "SST",
"taxRate": 6.0
},
{
"description": "Consultation Fee",
"quantity": 5,
"unitPrice": 200.00,
"taxCode": "SST",
"taxRate": 6.0
}
],
"notes": "Thank you for your business!",
"terms": "Payment due within 30 days"
}'
Response
{
"success": true,
"data": {
"id": "inv_456def789",
"invoiceNumber": "INV-2024-0001",
"customerId": "cust_789xyz123",
"customer": {
"id": "cust_789xyz123",
"name": "Test Customer",
"email": "test@example.com"
},
"invoiceDate": "2024-01-15",
"dueDate": "2024-02-14",
"status": "draft",
"currency": "MYR",
"items": [
{
"id": "item_1",
"description": "Professional Services",
"quantity": 10,
"unitPrice": 100.00,
"lineTotal": 1000.00,
"taxCode": "SST",
"taxRate": 6.0,
"taxAmount": 60.00
},
{
"id": "item_2",
"description": "Consultation Fee",
"quantity": 5,
"unitPrice": 200.00,
"lineTotal": 1000.00,
"taxCode": "SST",
"taxRate": 6.0,
"taxAmount": 60.00
}
],
"subtotal": 2000.00,
"totalTax": 120.00,
"total": 2120.00,
"amountDue": 2120.00,
"reference": "PO-12345",
"notes": "Thank you for your business!",
"terms": "Payment due within 30 days",
"createdAt": "2024-01-15T10:35:00Z",
"updatedAt": "2024-01-15T10:35:00Z"
}
}
Step 5: Explore Core Endpoints
Now that you’ve made successful API calls, explore these essential endpoints:
List Customers
curl -X GET "https://api.bigledger.com/v1/customers?limit=20" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Company-Id: YOUR_COMPANY_ID"
Get Chart of Accounts
curl -X GET "https://api.bigledger.com/v1/accounts" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Company-Id: YOUR_COMPANY_ID"
List Invoices
curl -X GET "https://api.bigledger.com/v1/invoices?status=draft&limit=10" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Company-Id: YOUR_COMPANY_ID"
Get Invoice by ID
curl -X GET "https://api.bigledger.com/v1/invoices/inv_456def789" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Company-Id: YOUR_COMPANY_ID"
Common Code Examples
Here are code examples in popular programming languages:
// JavaScript/Node.js with axios
const axios = require('axios');
const client = axios.create({
baseURL: 'https://api.bigledger.com/v1',
headers: {
'Authorization': 'Bearer blg_live_sk_1234567890abcdef',
'Content-Type': 'application/json',
'X-Company-Id': 'company_abc123'
}
});
async function createCustomer() {
try {
const response = await client.post('/customers', {
name: 'Test Customer',
email: 'test@example.com',
phone: '+60123456789'
});
console.log('Customer created:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
async function createInvoice(customerId) {
try {
const response = await client.post('/invoices', {
customerId: customerId,
invoiceDate: new Date().toISOString().split('T')[0],
dueDate: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
items: [
{
description: 'Professional Services',
quantity: 10,
unitPrice: 100.00,
taxCode: 'SST',
taxRate: 6.0
}
]
});
console.log('Invoice created:', response.data);
return response.data;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
// Usage
(async () => {
const customer = await createCustomer();
if (customer) {
await createInvoice(customer.data.id);
}
})();
# Python with requests
import requests
import json
from datetime import datetime, timedelta
headers = {
'Authorization': 'Bearer blg_live_sk_1234567890abcdef',
'Content-Type': 'application/json',
'X-Company-Id': 'company_abc123'
}
base_url = 'https://api.bigledger.com/v1'
def create_customer():
url = f'{base_url}/customers'
data = {
'name': 'Test Customer',
'email': 'test@example.com',
'phone': '+60123456789'
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 201:
print('Customer created:', response.json())
return response.json()
else:
print('Error:', response.json())
return None
def create_invoice(customer_id):
url = f'{base_url}/invoices'
today = datetime.now().strftime('%Y-%m-%d')
due_date = (datetime.now() + timedelta(days=30)).strftime('%Y-%m-%d')
data = {
'customerId': customer_id,
'invoiceDate': today,
'dueDate': due_date,
'items': [
{
'description': 'Professional Services',
'quantity': 10,
'unitPrice': 100.00,
'taxCode': 'SST',
'taxRate': 6.0
}
]
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 201:
print('Invoice created:', response.json())
return response.json()
else:
print('Error:', response.json())
return None
# Usage
customer = create_customer()
if customer:
create_invoice(customer['data']['id'])
<?php
// PHP with cURL
class BigLedgerClient {
private $baseUrl = 'https://api.bigledger.com/v1';
private $headers;
public function __construct($apiKey, $companyId) {
$this->headers = [
'Authorization: Bearer ' . $apiKey,
'Content-Type: application/json',
'X-Company-Id: ' . $companyId
];
}
private function makeRequest($method, $endpoint, $data = null) {
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $this->baseUrl . $endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $this->headers,
CURLOPT_CUSTOMREQUEST => $method,
]);
if ($data) {
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
}
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return [
'status' => $httpCode,
'data' => json_decode($response, true)
];
}
public function createCustomer($customerData) {
return $this->makeRequest('POST', '/customers', $customerData);
}
public function createInvoice($invoiceData) {
return $this->makeRequest('POST', '/invoices', $invoiceData);
}
}
// Usage
$client = new BigLedgerClient(
'blg_live_sk_1234567890abcdef',
'company_abc123'
);
$customerData = [
'name' => 'Test Customer',
'email' => 'test@example.com',
'phone' => '+60123456789'
];
$customer = $client->createCustomer($customerData);
if ($customer['status'] === 201) {
echo "Customer created: " . json_encode($customer['data']) . "\n";
$invoiceData = [
'customerId' => $customer['data']['data']['id'],
'invoiceDate' => date('Y-m-d'),
'dueDate' => date('Y-m-d', strtotime('+30 days')),
'items' => [
[
'description' => 'Professional Services',
'quantity' => 10,
'unitPrice' => 100.00,
'taxCode' => 'SST',
'taxRate' => 6.0
]
]
];
$invoice = $client->createInvoice($invoiceData);
echo "Invoice created: " . json_encode($invoice['data']) . "\n";
}
?>
// Java with OkHttp
import okhttp3.*;
import com.google.gson.Gson;
import java.io.IOException;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import java.util.Arrays;
public class BigLedgerClient {
private static final String BASE_URL = "https://api.bigledger.com/v1";
private final OkHttpClient client;
private final String apiKey;
private final String companyId;
private final Gson gson;
public BigLedgerClient(String apiKey, String companyId) {
this.client = new OkHttpClient();
this.apiKey = apiKey;
this.companyId = companyId;
this.gson = new Gson();
}
private Response makeRequest(String method, String endpoint, Object data) throws IOException {
Request.Builder requestBuilder = new Request.Builder()
.url(BASE_URL + endpoint)
.addHeader("Authorization", "Bearer " + apiKey)
.addHeader("Content-Type", "application/json")
.addHeader("X-Company-Id", companyId);
if (data != null) {
RequestBody body = RequestBody.create(
gson.toJson(data),
MediaType.get("application/json")
);
requestBuilder.method(method, body);
} else {
requestBuilder.method(method, null);
}
return client.newCall(requestBuilder.build()).execute();
}
public void createCustomerAndInvoice() throws IOException {
// Create customer
Map<String, Object> customerData = new HashMap<>();
customerData.put("name", "Test Customer");
customerData.put("email", "test@example.com");
customerData.put("phone", "+60123456789");
Response customerResponse = makeRequest("POST", "/customers", customerData);
if (customerResponse.isSuccessful()) {
System.out.println("Customer created: " + customerResponse.body().string());
// Create invoice
Map<String, Object> item = new HashMap<>();
item.put("description", "Professional Services");
item.put("quantity", 10);
item.put("unitPrice", 100.00);
item.put("taxCode", "SST");
item.put("taxRate", 6.0);
Map<String, Object> invoiceData = new HashMap<>();
invoiceData.put("customerId", "cust_789xyz123"); // Use actual customer ID
invoiceData.put("invoiceDate", LocalDate.now().toString());
invoiceData.put("dueDate", LocalDate.now().plusDays(30).toString());
invoiceData.put("items", Arrays.asList(item));
Response invoiceResponse = makeRequest("POST", "/invoices", invoiceData);
if (invoiceResponse.isSuccessful()) {
System.out.println("Invoice created: " + invoiceResponse.body().string());
}
}
}
public static void main(String[] args) {
try {
BigLedgerClient client = new BigLedgerClient(
"blg_live_sk_1234567890abcdef",
"company_abc123"
);
client.createCustomerAndInvoice();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Testing Your Integration
Health Check Endpoint
Before integrating, verify the API is accessible:
curl -X GET "https://api.bigledger.com/v1/health" \
-H "Content-Type: application/json"
Response:
{
"status": "ok",
"version": "1.0.0",
"timestamp": "2024-01-15T10:30:00Z",
"region": "ap-southeast-1"
}
API Explorer
Use our interactive API Explorer to test endpoints without writing code:
Sample Test Scenarios
1. Basic CRUD Operations
# Create a customer
POST /customers
# Get the customer
GET /customers/{id}
# Update the customer
PUT /customers/{id}
# Create an invoice for the customer
POST /invoices
# List all invoices
GET /invoices
2. Search and Filtering
# Search customers by name
GET /customers?search=acme
# Filter invoices by date range
GET /invoices?fromDate=2024-01-01&toDate=2024-01-31
# Get overdue invoices
GET /invoices?status=overdue
3. Pagination
# Get first page of customers
GET /customers?limit=20&offset=0
# Get second page
GET /customers?limit=20&offset=20
Error Handling
Learn to handle common errors gracefully:
400 Bad Request
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request data",
"details": [
{
"field": "email",
"message": "Email format is invalid"
}
]
}
}
401 Unauthorized
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid or missing API key"
}
}
Rate Limiting (429)
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Too many requests",
"retryAfter": 60,
"limit": 1000,
"remaining": 0,
"resetTime": "2024-01-15T11:30:00Z"
}
}
422 Unprocessable Entity
{
"success": false,
"error": {
"code": "BUSINESS_RULE_VIOLATION",
"message": "Cannot delete customer with outstanding invoices",
"context": {
"customerId": "cust_789xyz123",
"outstandingInvoices": 3,
"totalAmount": 5250.00
}
}
}
Error Response Structure
All error responses follow this consistent structure:
{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Human-readable description",
"details": [], // Field-specific errors (validation)
"context": {}, // Additional error context
"documentation": "https://docs.bigledger.com/errors/ERROR_CODE",
"requestId": "req_123456789"
},
"meta": {
"timestamp": "2024-01-15T10:30:00Z",
"version": "1.0.0"
}
}
Using the SDK
For production applications, use our official SDKs:
Install SDK
npm install @bigledger/sdk
pip install bigledger-sdk
composer require bigledger/sdk
SDK Usage
import { BigLedgerClient } from '@bigledger/sdk';
const client = new BigLedgerClient({
apiKey: 'blg_live_sk_1234567890abcdef',
companyId: 'company_abc123'
});
// Create customer
const customer = await client.customers.create({
name: 'Test Customer',
email: 'test@example.com'
});
// Create invoice
const invoice = await client.invoices.create({
customerId: customer.id,
items: [
{
description: 'Professional Services',
quantity: 10,
unitPrice: 100.00
}
]
});
from bigledger import BigLedgerClient
client = BigLedgerClient(
api_key='blg_live_sk_1234567890abcdef',
company_id='company_abc123'
)
# Create customer
customer = client.customers.create({
'name': 'Test Customer',
'email': 'test@example.com'
})
# Create invoice
invoice = client.invoices.create({
'customer_id': customer['id'],
'items': [
{
'description': 'Professional Services',
'quantity': 10,
'unit_price': 100.00
}
]
})
use BigLedger\BigLedgerClient;
$client = new BigLedgerClient([
'api_key' => 'blg_live_sk_1234567890abcdef',
'company_id' => 'company_abc123'
]);
// Create customer
$customer = $client->customers->create([
'name' => 'Test Customer',
'email' => 'test@example.com'
]);
// Create invoice
$invoice = $client->invoices->create([
'customerId' => $customer['id'],
'items' => [
[
'description' => 'Professional Services',
'quantity' => 10,
'unitPrice' => 100.00
]
]
]);
Next Steps
Now that you’ve made your first API calls, explore these topics:
API Base URLs & Environments
Environments
- Production:
https://api.bigledger.com/v1
- Sandbox:
https://sandbox-api.bigledger.com/v1
Rate Limits & Governance
Default Rate Limits
- Requests per Hour: 1,000 per API key
- Burst Limit: 10 requests per second
- Bulk Operations: Separate higher limits (up to 10,000 operations per request)
- Concurrent Connections: 5 simultaneous requests
- Request Timeout: 30 seconds for standard operations, 15 minutes for bulk operations
Enterprise Plans: Higher limits, dedicated infrastructure, and SLA guarantees available.
Required Headers
All API requests must include these headers:
Authorization: Bearer {your_api_key}
Content-Type: application/json
X-Company-Id: {your_company_id}
User-Agent: YourApp/1.0.0
Optional but recommended headers:
X-Request-ID: {unique_request_identifier}
X-API-Version: 2024-01-15
Accept-Encoding: gzip, deflate
Postman Collection
Ready-to-use Postman Collection: Download our complete Postman collection with all endpoints, authentication, and example requests pre-configured.
The collection includes:
- Pre-configured authentication
- All API endpoints with example requests
- Environment variables for easy switching between sandbox and production
- Sample responses and error scenarios
Troubleshooting Common Issues
Authentication Problems
Symptoms: 401 Unauthorized responses
Solutions:
- Verify API key format:
blg_live_sk_...
(production) orblg_test_sk_...
(sandbox) - Check Company ID format:
company_...
- Ensure headers are correctly formatted
- Verify API key hasn’t expired or been revoked
Rate Limiting
Symptoms: 429 Too Many Requests responses
Solutions:
- Implement exponential backoff with retry logic
- Use bulk endpoints for multiple operations
- Cache responses when appropriate
- Consider upgrading to higher rate limits
Data Validation Errors
Symptoms: 400 Bad Request with validation details
Solutions:
- Check required fields are provided
- Verify data types and formats
- Ensure enum values are valid
- Review field length restrictions
Support & Community
Need help? We’re here to assist:
- Documentation: developers.bigledger.com
- Email Support: developers@bigledger.com
- Community Forum: community.bigledger.com
- Status Page: status.bigledger.com
- Developer Console: developers.bigledger.com/console
- GitHub Issues: github.com/bigledger/api-issues