← Back to Documentation

BDM Universal API

API Testing Guide - Postman & cURL

Postman Collection

Download Postman Collection

Pre-configured collection with all API endpoints, authentication, and examples.

Download Collection

Step 1: Import Collection

  1. 1

    Open Postman and click Import button

  2. 2

    Drag and drop the downloaded JSON file, or click Upload Files

  3. 3

    Click Import to add the collection to your workspace

Step 2: Configure Variables

Set your base URL and credentials:

  1. 1

    Click on the collection name → Variables tab

    base_url: http://localhost:8000 (change to your domain)

    auth_token: Leave empty (auto-filled after login)

Step 3: Test Authentication

  1. 1

    Open Authentication → Login request

  2. 2

    Update the request body with your credentials:

    {
      "email": "your-email@example.com",
      "password": "your-password"
    }
  3. 3

    Click Send. The auth token will be automatically saved!

✓ You're Ready!

All other requests in the collection will automatically use your auth token. Just click Send on any endpoint to test.

cURL Examples

Test the API directly from your terminal using cURL commands.

Login

curl -X POST http://localhost:8000/api/login \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "email": "user@example.com",
    "password": "password"
  }'

Save the token from the response to use in subsequent requests.

List Resources (with Authentication)

curl -X GET http://localhost:8000/api/v1/accounting/invoices \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

List with Filters & Pagination

curl -X GET "http://localhost:8000/api/v1/accounting/invoices?page=1&per_page=20&filter[status]=unpaid&sort_by=due_date" \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

Create Resource

curl -X POST http://localhost:8000/api/v1/accounting/invoices \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -d '{
    "customer_name": "Acme Corp",
    "customer_email": "billing@acme.com",
    "total": 1500.00
  }'

Update Resource

curl -X PUT http://localhost:8000/api/v1/accounting/invoices/1 \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE" \
  -d '{
    "customer_name": "Acme Corporation"
  }'

Delete Resource

curl -X DELETE http://localhost:8000/api/v1/accounting/invoices/1 \
  -H "Accept: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

Guest Access (No Authentication)

curl -X GET http://localhost:8000/api/guest/resource/YOUR_GUEST_TOKEN_HERE \
  -H "Accept: application/json"

Testing Authentication

1. User Authentication (Sanctum)

Standard login for web and mobile apps:

# Login
POST /api/login
{
  "email": "user@example.com",
  "password": "password"
}

# Response
{
  "success": true,
  "data": {
    "token": "1|abc123def456...",
    "user": {...}
  }
}

# Use token in subsequent requests
Authorization: Bearer 1|abc123def456...

2. API Token Authentication

For service-to-service communication:

# Create token first (via authenticated request)
POST /api/tokens
{
  "name": "My Integration",
  "scopes": ["accounting.*"]
}

# Response includes token (save it!)
{
  "data": {
    "token": "bdm_xyz789..."
  }
}

# Use in requests
Authorization: Bearer bdm_xyz789...

3. Guest Access

Token in URL, no Authorization header needed:

GET /api/guest/resource/128_character_guest_token_here

Common API Requests

Share Module Access

POST /api/permissions
{
  "email": "colleague@example.com",
  "module_slug": "accounting",
  "role": "manager",
  "expires_at": "2026-12-31"
}

Create Guest Access

POST /api/v1/accounting/invoices/1/guest-access
{
  "guest_email": "customer@example.com",
  "guest_name": "John Doe",
  "permissions": ["view", "download", "pay"],
  "expires_at": "2025-12-31",
  "requires_password": true,
  "password": "secret123"
}

Create Webhook

POST /api/webhooks
{
  "url": "https://your-app.com/webhooks/bdm",
  "events": ["invoice.created", "invoice.paid"],
  "active": true
}

Advanced Filtering

GET /api/v1/accounting/invoices?
  page=1&
  per_page=20&
  search=acme&
  filter[status]=unpaid&
  filter[customer_id]=5&
  sort_by=due_date&
  sort_order=asc&
  include=customer,items

Troubleshooting

❌ 401 Unauthorized

Problem: Missing or invalid authentication token

Solution:

  • • Ensure token is included in Authorization header
  • • Check token hasn't expired
  • • Login again to get fresh token

⚠️ 403 Forbidden

Problem: User doesn't have permission

Solution:

  • • Check user has access to the module
  • • Verify role has required permission
  • • Contact module owner to update permissions

ℹ️ 429 Too Many Requests

Problem: Rate limit exceeded

Solution:

  • • Check X-RateLimit-Reset header for reset time
  • • Reduce request frequency
  • • Implement exponential backoff

🔍 422 Validation Error

Problem: Invalid request data

Solution:

  • • Check response "errors" object for details
  • • Verify all required fields are present
  • • Check data types match documentation

Testing Best Practices

✓ Do This

  • ✓ Test in a development environment first
  • ✓ Use environment variables for credentials
  • ✓ Save commonly used requests
  • ✓ Check response status codes
  • ✓ Validate response data structure
  • ✓ Test error scenarios
  • ✓ Monitor rate limit headers

✗ Avoid This

  • ✗ Don't test in production initially
  • ✗ Don't hardcode credentials in requests
  • ✗ Don't ignore error responses
  • ✗ Don't skip authentication testing
  • ✗ Don't exceed rate limits
  • ✗ Don't test with real customer data
  • ✗ Don't share API tokens publicly