Skip to main content
POST
/
api
/
unions
Create Union
curl --request POST \
  --url https://api.example.com/api/unions \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "location": "<string>",
  "address": "<string>",
  "creditOfficerId": "<string>"
}
'
{
  "success": true,
  "message": "<string>",
  "data": {
    "id": "<string>",
    "name": "<string>",
    "location": "<string>",
    "address": "<string>",
    "creditOfficerId": "<string>",
    "createdAt": "<string>",
    "updatedAt": "<string>",
    "deletedAt": "<string>"
  }
}
Create a new union and assign it to a credit officer.

Authentication

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

Authorization

This endpoint requires ADMIN or SUPERVISOR role. Credit officers cannot create unions.

Request Body

name
string
required
Name of the union. This field is required.
location
string
Location of the union (e.g., city or region).
address
string
Physical address of the union.
creditOfficerId
string
required
ID of the credit officer who will manage this union. This field is required.

Response

success
boolean
Indicates if the request was successful.
message
string
Success message confirming the union was created.
data
object
The created union object.

Example Request

curl --request POST \
  --url https://api.example.com/api/unions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Central Farmers Union",
    "location": "Lagos",
    "address": "123 Main Street, Ikeja, Lagos",
    "creditOfficerId": "clx1234567890"
  }'

Example Response

{
  "success": true,
  "message": "Union created successfully",
  "data": {
    "id": "clx9876543210",
    "name": "Central Farmers Union",
    "location": "Lagos",
    "address": "123 Main Street, Ikeja, Lagos",
    "creditOfficerId": "clx1234567890",
    "createdAt": "2024-03-15T10:30:00.000Z",
    "updatedAt": "2024-03-15T10:30:00.000Z",
    "deletedAt": null
  }
}

Error Responses

401 Unauthorized
Missing or invalid authentication token.
{
  "success": false,
  "message": "Unauthorized"
}
403 Forbidden
User does not have required role (ADMIN or SUPERVISOR).
{
  "success": false,
  "message": "Access denied. Insufficient permissions."
}
400 Bad Request
Missing required fields or validation error.
{
  "success": false,
  "message": "Name and creditOfficerId are required"
}
Or:
{
  "success": false,
  "message": "Failed to create union"
}

Audit Log

This operation creates an audit log entry with action UNION_CREATED for tracking purposes.

Build docs developers (and LLMs) love