Skip to main content
GET
/
api
/
unions
List Unions
curl --request GET \
  --url https://api.example.com/api/unions
{
  "success": true,
  "data": [
    {
      "id": "<string>",
      "name": "<string>",
      "location": "<string>",
      "address": "<string>",
      "creditOfficerId": "<string>",
      "creditOfficer": {
        "id": "<string>",
        "firstName": "<string>",
        "lastName": "<string>",
        "email": "<string>"
      },
      "createdAt": "<string>",
      "updatedAt": "<string>"
    }
  ],
  "pagination": {
    "total": 123,
    "page": 123,
    "limit": 123,
    "pages": 123
  }
}
Retrieve a paginated list of unions with optional filtering and search capabilities.

Authentication

Required. Include a valid JWT token in the Authorization header.
Authorization: Bearer <token>

Authorization

All authenticated users can access this endpoint. Credit officers will only see unions assigned to them or under their supervision.

Query Parameters

page
integer
default:"1"
Page number for pagination.
limit
integer
default:"20"
Number of unions to return per page.
creditOfficerId
string
Filter unions by the assigned credit officer ID.
Search unions by name, location, or address.

Response

success
boolean
Indicates if the request was successful.
data
array
Array of union objects.
pagination
object
Pagination metadata.

Example Request

curl --request GET \
  --url 'https://api.example.com/api/unions?page=1&limit=20&creditOfficerId=clx1234567890' \
  --header 'Authorization: Bearer <token>'

Example Response

{
  "success": true,
  "data": [
    {
      "id": "clx9876543210",
      "name": "Central Farmers Union",
      "location": "Lagos",
      "address": "123 Main Street, Ikeja, Lagos",
      "creditOfficerId": "clx1234567890",
      "creditOfficer": {
        "id": "clx1234567890",
        "firstName": "John",
        "lastName": "Doe",
        "email": "[email protected]"
      },
      "createdAt": "2024-03-15T10:30:00.000Z",
      "updatedAt": "2024-03-15T10:30:00.000Z"
    }
  ],
  "pagination": {
    "total": 45,
    "page": 1,
    "limit": 20,
    "pages": 3
  }
}

Error Responses

401 Unauthorized
Missing or invalid authentication token.
{
  "success": false,
  "message": "Unauthorized"
}
400 Bad Request
Invalid query parameters or request error.
{
  "success": false,
  "message": "Failed to fetch unions"
}

Build docs developers (and LLMs) love