Skip to main content
PUT
/
api
/
unions
/
:id
Update Union
curl --request PUT \
  --url https://api.example.com/api/unions/:id \
  --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>"
  }
}
Update an existing union’s details.

Authentication

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

Authorization

This endpoint requires ADMIN role. Only administrators can update unions.

Path Parameters

id
string
required
The unique identifier (CUID) of the union to update.

Request Body

All fields are optional. Only include fields you want to update.
name
string
Updated name of the union.
location
string
Updated location of the union.
address
string
Updated physical address of the union.
creditOfficerId
string
ID of a different credit officer to assign this union to. This will trigger a reassignment.

Response

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

Example Request

curl --request PUT \
  --url https://api.example.com/api/unions/clx9876543210 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Central Farmers Union - Updated",
    "location": "Abuja",
    "address": "456 New Avenue, Wuse, Abuja"
  }'

Example Response

{
  "success": true,
  "message": "Union updated successfully",
  "data": {
    "id": "clx9876543210",
    "name": "Central Farmers Union - Updated",
    "location": "Abuja",
    "address": "456 New Avenue, Wuse, Abuja",
    "creditOfficerId": "clx1234567890",
    "createdAt": "2024-03-15T10:30:00.000Z",
    "updatedAt": "2024-03-16T14:20:00.000Z",
    "deletedAt": null
  }
}

Example: Reassigning Credit Officer

curl --request PUT \
  --url https://api.example.com/api/unions/clx9876543210 \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "creditOfficerId": "clx0987654321"
  }'

Error Responses

401 Unauthorized
Missing or invalid authentication token.
{
  "success": false,
  "message": "Unauthorized"
}
403 Forbidden
User does not have required role (ADMIN).
{
  "success": false,
  "message": "Access denied. Admin privileges required."
}
404 Not Found
Union with the specified ID does not exist.
{
  "success": false,
  "message": "Union not found"
}
400 Bad Request
Invalid request data or validation error.
{
  "success": false,
  "message": "Failed to update union"
}

Audit Log

This operation creates an audit log entry with action UNION_UPDATED for tracking purposes.
  • For reassigning a union with a documented reason, use POST /api/unions/:unionId/assign
  • To view union assignment history, check the UnionAssignmentHistory records via audit logs

Build docs developers (and LLMs) love