Accounts Endpoint

Retrieve paginated account data with optional filtering capabilities.

Endpoint Details

GET /api/accounts

Authentication Required

  • API Token: Required in URL parameter ?api_token=xxx
  • User Token: Required in Authorization header Bearer {access_token}

Query Parameters

Parameter Type Required Description
api_token string Yes Your API access token
page integer No Page number (default: 1)
paging integer No Set to 0 to disable pagination and get all results
account_name string No Filter by account name (partial match)

Response Format

Success Response (200 OK)
{
  "success": true,
  "data": {
    "accounts": [
      {
        "account_id": "123",
        "account_name": "Example Corp",
        "account_email": "contact@example.com",
        "status": "active",
        "created_at": "2024-01-01T10:00:00Z"
      }
    ],
    "pagination": {
      "current_page": 1,
      "total_pages": 5,
      "total_records": 45,
      "per_page": 100
    }
  },
  "message": "Accounts retrieved successfully"
}

Examples

Basic Request
curl -X GET "https://api.creditrisk.co.za/api/accounts?api_token=your_token" \
-H "Authorization: Bearer your_access_token"
With Filtering
curl -X GET "https://api.creditrisk.co.za/api/accounts?api_token=your_token&account_name=example" \
-H "Authorization: Bearer your_access_token"
Get All Records (No Pagination)
curl -X GET "https://api.creditrisk.co.za/api/accounts?api_token=your_token&paging=0" \
-H "Authorization: Bearer your_access_token"

Error Responses

Authentication Failed (401 Unauthorized)
{
  "success": false,
  "error": "Authentication failed",
  "message": "Invalid or expired access token"
}
Access Denied (403 Forbidden)
{
  "success": false,
  "error": "Access denied",
  "message": "User does not have access to any grantor accounts"
}

Test This Endpoint

Use the interactive testing tool to try this endpoint:

Go to API Testing