Introduction

Welcome to the SureBucks SME Loan API documentation. This API enables partners to programmatically manage client businesses and loan requests.

Base URL: https://api.surebucks-sme.com/v1

Quick Start

  1. Get your API key from the Partner Portal dashboard
  2. Include the API key in all requests via the X-API-Key header
  3. Create a client business profile
  4. Submit loan requests for your clients
  5. Track loan status and receive webhook notifications

Authentication

All API requests (except /health) require authentication using an API key.

API Key Format

Type Format Example
Live Key sb_live_ + 32+ characters sb_live_a1b2c3d4e5f6...
Test Key sb_test_ + 32+ characters sb_test_x9y8z7w6v5u4...

Providing Your API Key

Option 1: X-API-Key Header (Recommended)

HTTP Header
X-API-Key: sb_live_your_api_key_here

Option 2: Authorization Bearer Token

HTTP Header
Authorization: Bearer sb_live_your_api_key_here

Example Request

cURL
curl -X GET "https://api.surebucks-sme.com/v1/clients" \
  -H "X-API-Key: sb_live_your_api_key_here" \
  -H "Content-Type: application/json"

Rate Limiting

The API implements rate limiting to ensure fair usage and system stability.

Default Limits

Limit Type Value
Requests per minute 60
Burst limit 100

Rate Limit Headers

Every response includes rate limit information:

Response Headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1706824800

When you exceed the rate limit, you'll receive a 429 Too Many Requests response. Wait until the reset time before making more requests.

Error Handling

All errors follow a consistent JSON format:

Error Response
{
  "success": false,
  "error": {
    "code": "ERROR_CODE",
    "message": "Human-readable error message",
    "details": {}
  }
}

HTTP Status Codes

Code Meaning
200Success
201Created - Resource successfully created
400Bad Request - Invalid request parameters
401Unauthorized - Invalid or missing API key
403Forbidden - Access denied
404Not Found - Resource doesn't exist
422Validation Error - Invalid request data
429Rate Limit Exceeded
500Internal Server Error

Error Codes

Code Description
UNAUTHORIZEDAuthentication failed
FORBIDDENAccess denied to resource
NOT_FOUNDRequested resource not found
VALIDATION_ERRORRequest data validation failed
DUPLICATE_CLIENTClient with same registration number exists
INVALID_STATUSOperation not allowed for current status
RATE_LIMIT_EXCEEDEDToo many requests

Health Check

Check API availability. No authentication required.

GET /v1/health Check API health status

Example Request

cURL
curl -X GET "https://api.surebucks-sme.com/v1/health"

Response

JSON
{
  "success": true,
  "data": {
    "status": "ok",
    "message": "API is healthy",
    "version": "1.1.0",
    "timestamp": "2026-02-01T21:00:00+00:00"
  }
}

Clients

Manage client business profiles.

POST /v1/clients Create a new client business

Request Body

Field Type Description
business_nameRequired string Legal business name
registration_numberRequired string CAC registration number
emailOptional string Business email address
phoneOptional string Business phone number
business_typeOptional string Type: sole_proprietorship, partnership, llc, plc

Example Request

cURL
curl -X POST "https://api.surebucks-sme.com/v1/clients" \
  -H "X-API-Key: sb_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "business_name": "Acme Trading Ltd",
    "registration_number": "RC123456",
    "email": "info@acmetrading.com",
    "business_type": "llc"
  }'

Response (201 Created)

JSON
{
  "success": true,
  "data": {
    "uuid": "550e8400-e29b-41d4-a716-446655440000",
    "business_name": "Acme Trading Ltd",
    "registration_number": "RC123456",
    "business_type": "llc",
    "mono_connected": false,
    "created_at": "2026-02-01T21:00:00+00:00"
  }
}
GET /v1/clients List all client businesses

Query Parameters

Parameter Type Description
page integer Page number (default: 1)
per_page integer Items per page (default: 20, max: 100)
search string Search by business name or registration number

Example Request

cURL
curl -X GET "https://api.surebucks-sme.com/v1/clients?page=1&per_page=10" \
  -H "X-API-Key: sb_live_your_api_key_here"
GET /v1/clients/{uuid} Get client details

Path Parameters

Parameter Type Description
uuidRequired string Client's unique identifier

Loans

Manage loan requests for your clients.

POST /v1/loans Create a new loan request

Request Body

Field Type Description
client_uuidRequired string UUID of the client business
loan_amountRequired number Loan amount (₦50,000 - ₦50,000,000)
tenure_monthsOptional integer Loan tenure 1-36 months (default: 12)
purposeOptional string Loan purpose description

Example Request

cURL
curl -X POST "https://api.surebucks-sme.com/v1/loans" \
  -H "X-API-Key: sb_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "client_uuid": "550e8400-e29b-41d4-a716-446655440000",
    "loan_amount": 5000000,
    "tenure_months": 12,
    "purpose": "Working capital for inventory"
  }'

Response (201 Created)

JSON
{
  "success": true,
  "data": {
    "uuid": "660e8400-e29b-41d4-a716-446655440001",
    "reference_number": "SBL-20260201-A1B2C3D4",
    "status": "draft",
    "loan_amount": 5000000,
    "currency": "NGN",
    "tenure_months": 12,
    "interest_rate": 24.0,
    "monthly_repayment": 473790.12,
    "total_repayment": 5685481.44,
    "processing_fee": 100000,
    "created_at": "2026-02-01T21:00:00+00:00"
  }
}
GET /v1/loans List all loan requests

Query Parameters

Parameter Type Description
status string Filter by status (draft, submitted, approved, etc.)
from_date string Filter from date (YYYY-MM-DD)
to_date string Filter to date (YYYY-MM-DD)
POST /v1/loans/{uuid}/submit Submit loan for review

Submit a draft loan request for review. Only loans in draft status can be submitted.

Example Request

cURL
curl -X POST "https://api.surebucks-sme.com/v1/loans/660e8400-e29b-41d4-a716-446655440001/submit" \
  -H "X-API-Key: sb_live_your_api_key_here"
GET /v1/loans/{uuid}/status Get loan status timeline

Get the current status and complete timeline of a loan request.

Loan Statuses

Status Description
draftInitial state, can be edited
submittedSubmitted for review
under_reviewBeing reviewed by credit team
approvedFully approved, pending disbursement
disbursedFunds disbursed
rejectedApplication rejected
cancelledCancelled by partner

Webhooks

Test and manage webhook configurations.

POST /v1/webhooks/test Test webhook delivery

Send a test webhook to your configured endpoint. You must have a webhook URL configured in the Partner Portal.

Example Request

cURL
curl -X POST "https://api.surebucks-sme.com/v1/webhooks/test" \
  -H "X-API-Key: sb_live_your_api_key_here"

Webhook Events

When events occur, we send POST requests to your configured webhook URL.

Webhook Payload Structure

JSON
{
  "event": "loan.status.updated",
  "timestamp": "2026-02-01T21:00:00+00:00",
  "data": {
    "loan_uuid": "660e8400-e29b-41d4-a716-446655440001",
    "reference_number": "SBL-20260201-A1B2C3D4",
    "previous_status": "submitted",
    "new_status": "under_review"
  }
}

Webhook Headers

Header Description
X-Webhook-Signature HMAC-SHA256 signature of the payload
X-Webhook-Timestamp Unix timestamp when webhook was sent

Verifying Signatures

PHP
$payload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'];
$secret = 'your_webhook_secret';

$expectedSignature = hash_hmac('sha256', $payload, $secret);

if (hash_equals($expectedSignature, $signature)) {
    // Signature is valid
    $data = json_decode($payload, true);
    // Process webhook...
}

Event Types

Event Description
loan.submittedLoan request submitted for review
loan.status.updatedLoan status changed
loan.approvedLoan fully approved
loan.rejectedLoan application rejected
loan.disbursedFunds disbursed to client

Code Examples

Complete code examples in multiple languages to help you integrate with the SureBucks API.

cURL

Command-line examples for quick testing and scripting.

cURL - Create Client
# Create a new client
curl -X POST "https://api.surebucks-sme.com/v1/clients" \
  -H "X-API-Key: sb_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "business_name": "Acme Trading Ltd",
    "registration_number": "RC123456",
    "email": "info@acmetrading.com",
    "business_type": "llc"
  }'

# Create a loan request
curl -X POST "https://api.surebucks-sme.com/v1/loans" \
  -H "X-API-Key: sb_live_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "client_uuid": "550e8400-e29b-41d4-a716-446655440000",
    "loan_amount": 500000,
    "tenure_months": 12,
    "purpose": "Working capital"
  }'

# Get loan status
curl -X GET "https://api.surebucks-sme.com/v1/loans/550e8400-e29b-41d4-a716-446655440000/status" \
  -H "X-API-Key: sb_live_your_api_key_here"

# List all clients with pagination
curl -X GET "https://api.surebucks-sme.com/v1/clients?page=1&per_page=20" \
  -H "X-API-Key: sb_live_your_api_key_here"

Python

Using the requests library for HTTP calls.

Python
import requests
from typing import Dict, Any, Optional

class SureBucksAPI:
    """SureBucks SME Loan API Client for Python"""
    
    def __init__(self, api_key: str, base_url: str = "https://api.surebucks-sme.com/v1"):
        self.api_key = api_key
        self.base_url = base_url
        self.session = requests.Session()
        self.session.headers.update({
            "X-API-Key": api_key,
            "Content-Type": "application/json"
        })
    
    def _request(self, method: str, endpoint: str, data: Optional[Dict] = None) -> Dict[str, Any]:
        """Make an API request"""
        url = f"{self.base_url}{endpoint}"
        response = self.session.request(method, url, json=data)
        response.raise_for_status()
        return response.json()
    
    # Client Methods
    def create_client(self, business_name: str, registration_number: str, **kwargs) -> Dict:
        """Create a new client business"""
        data = {
            "business_name": business_name,
            "registration_number": registration_number,
            **kwargs
        }
        return self._request("POST", "/clients", data)
    
    def get_client(self, client_uuid: str) -> Dict:
        """Get client details by UUID"""
        return self._request("GET", f"/clients/{client_uuid}")
    
    def list_clients(self, page: int = 1, per_page: int = 20) -> Dict:
        """List all clients with pagination"""
        return self._request("GET", f"/clients?page={page}&per_page={per_page}")
    
    # Loan Methods
    def create_loan(self, client_uuid: str, loan_amount: float, tenure_months: int = 12, **kwargs) -> Dict:
        """Create a new loan request"""
        data = {
            "client_uuid": client_uuid,
            "loan_amount": loan_amount,
            "tenure_months": tenure_months,
            **kwargs
        }
        return self._request("POST", "/loans", data)
    
    def get_loan(self, loan_uuid: str) -> Dict:
        """Get loan details by UUID"""
        return self._request("GET", f"/loans/{loan_uuid}")
    
    def get_loan_status(self, loan_uuid: str) -> Dict:
        """Get current loan status"""
        return self._request("GET", f"/loans/{loan_uuid}/status")
    
    def submit_loan(self, loan_uuid: str) -> Dict:
        """Submit loan for review"""
        return self._request("POST", f"/loans/{loan_uuid}/submit")
    
    def cancel_loan(self, loan_uuid: str, reason: str) -> Dict:
        """Cancel a loan request"""
        return self._request("POST", f"/loans/{loan_uuid}/cancel", {"reason": reason})


# Usage Example
if __name__ == "__main__":
    # Initialize the API client
    api = SureBucksAPI("sb_live_your_api_key_here")
    
    # Create a new client
    client = api.create_client(
        business_name="Acme Trading Ltd",
        registration_number="RC123456",
        email="info@acmetrading.com",
        business_type="llc"
    )
    print(f"Created client: {client['data']['uuid']}")
    
    # Create a loan request
    loan = api.create_loan(
        client_uuid=client['data']['uuid'],
        loan_amount=500000,
        tenure_months=12,
        purpose="Working capital"
    )
    print(f"Created loan: {loan['data']['uuid']}")
    
    # Check loan status
    status = api.get_loan_status(loan['data']['uuid'])
    print(f"Loan status: {status['data']['status']}")

PHP

Using cURL for HTTP requests in PHP.

PHP
<?php
/**
 * SureBucks SME Loan API Client for PHP
 */
class SureBucksAPI {
    private string $apiKey;
    private string $baseUrl;
    
    public function __construct(string $apiKey, string $baseUrl = 'https://api.surebucks-sme.com/v1') {
        $this->apiKey = $apiKey;
        $this->baseUrl = $baseUrl;
    }
    
    /**
     * Make an API request
     */
    private function request(string $method, string $endpoint, array $data = []): array {
        $ch = curl_init();
        $url = $this->baseUrl . $endpoint;
        
        $headers = [
            'X-API-Key: ' . $this->apiKey,
            'Content-Type: application/json',
            'Accept: application/json'
        ];
        
        curl_setopt_array($ch, [
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HTTPHEADER => $headers,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_TIMEOUT => 30
        ]);
        
        if (!empty($data) && in_array($method, ['POST', 'PUT', 'PATCH'])) {
            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
        }
        
        $response = curl_exec($ch);
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $error = curl_error($ch);
        curl_close($ch);
        
        if ($error) {
            throw new Exception("cURL Error: $error");
        }
        
        $decoded = json_decode($response, true);
        
        if ($httpCode >= 400) {
            throw new Exception($decoded['message'] ?? 'API Error', $httpCode);
        }
        
        return $decoded;
    }
    
    // Client Methods
    public function createClient(array $data): array {
        return $this->request('POST', '/clients', $data);
    }
    
    public function getClient(string $uuid): array {
        return $this->request('GET', "/clients/$uuid");
    }
    
    public function listClients(int $page = 1, int $perPage = 20): array {
        return $this->request('GET', "/clients?page=$page&per_page=$perPage");
    }
    
    public function updateClient(string $uuid, array $data): array {
        return $this->request('PUT', "/clients/$uuid", $data);
    }
    
    // Loan Methods
    public function createLoan(array $data): array {
        return $this->request('POST', '/loans', $data);
    }
    
    public function getLoan(string $uuid): array {
        return $this->request('GET', "/loans/$uuid");
    }
    
    public function getLoanStatus(string $uuid): array {
        return $this->request('GET', "/loans/$uuid/status");
    }
    
    public function submitLoan(string $uuid): array {
        return $this->request('POST', "/loans/$uuid/submit");
    }
    
    public function cancelLoan(string $uuid, string $reason): array {
        return $this->request('POST', "/loans/$uuid/cancel", ['reason' => $reason]);
    }
}

// Usage Example
try {
    $api = new SureBucksAPI('sb_live_your_api_key_here');
    
    // Create a new client
    $client = $api->createClient([
        'business_name' => 'Acme Trading Ltd',
        'registration_number' => 'RC123456',
        'email' => 'info@acmetrading.com',
        'business_type' => 'llc'
    ]);
    echo "Created client: " . $client['data']['uuid'] . "\n";
    
    // Create a loan request
    $loan = $api->createLoan([
        'client_uuid' => $client['data']['uuid'],
        'loan_amount' => 500000,
        'tenure_months' => 12,
        'purpose' => 'Working capital'
    ]);
    echo "Created loan: " . $loan['data']['uuid'] . "\n";
    
    // Check loan status
    $status = $api->getLoanStatus($loan['data']['uuid']);
    echo "Loan status: " . $status['data']['status'] . "\n";
    
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Node.js

Using axios for HTTP requests in Node.js.

Node.js
const axios = require('axios');

/**
 * SureBucks SME Loan API Client for Node.js
 */
class SureBucksAPI {
    constructor(apiKey, baseUrl = 'https://api.surebucks-sme.com/v1') {
        this.client = axios.create({
            baseURL: baseUrl,
            headers: {
                'X-API-Key': apiKey,
                'Content-Type': 'application/json'
            },
            timeout: 30000
        });
        
        // Response interceptor for error handling
        this.client.interceptors.response.use(
            response => response.data,
            error => {
                const message = error.response?.data?.message || error.message;
                throw new Error(message);
            }
        );
    }
    
    // Client Methods
    async createClient(data) {
        return this.client.post('/clients', data);
    }
    
    async getClient(uuid) {
        return this.client.get(`/clients/${uuid}`);
    }
    
    async listClients(page = 1, perPage = 20) {
        return this.client.get('/clients', { params: { page, per_page: perPage } });
    }
    
    async updateClient(uuid, data) {
        return this.client.put(`/clients/${uuid}`, data);
    }
    
    // Loan Methods
    async createLoan(data) {
        return this.client.post('/loans', data);
    }
    
    async getLoan(uuid) {
        return this.client.get(`/loans/${uuid}`);
    }
    
    async getLoanStatus(uuid) {
        return this.client.get(`/loans/${uuid}/status`);
    }
    
    async submitLoan(uuid) {
        return this.client.post(`/loans/${uuid}/submit`);
    }
    
    async cancelLoan(uuid, reason) {
        return this.client.post(`/loans/${uuid}/cancel`, { reason });
    }
    
    async listLoans(page = 1, perPage = 20, filters = {}) {
        return this.client.get('/loans', { params: { page, per_page: perPage, ...filters } });
    }
}

// Usage Example
async function main() {
    const api = new SureBucksAPI('sb_live_your_api_key_here');
    
    try {
        // Create a new client
        const client = await api.createClient({
            business_name: 'Acme Trading Ltd',
            registration_number: 'RC123456',
            email: 'info@acmetrading.com',
            business_type: 'llc'
        });
        console.log('Created client:', client.data.uuid);
        
        // Create a loan request
        const loan = await api.createLoan({
            client_uuid: client.data.uuid,
            loan_amount: 500000,
            tenure_months: 12,
            purpose: 'Working capital'
        });
        console.log('Created loan:', loan.data.uuid);
        
        // Check loan status
        const status = await api.getLoanStatus(loan.data.uuid);
        console.log('Loan status:', status.data.status);
        
    } catch (error) {
        console.error('Error:', error.message);
    }
}

main();

// ES Module export (for modern Node.js)
module.exports = SureBucksAPI;

© 2026 SureBucks Business Loans. All rights reserved.
api-support@surebucks.com