Community Workers CRUD
This page documents the create, read, update, and delete operations for Community Workers.
List Community Workers
Endpoint
GET /api/community-workers
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
page | int | No | Page number (default: 1) |
limit | int | No | Items per page (default: 20) |
search | string | No | Search by name, first name, code, or phone |
statut | string | No | Filter by status |
region | UUID | No | Filter by region |
secteur | UUID | No | Filter by sector |
localite | UUID | No | Filter by locality |
typeContrat | string | No | volontaire or contractuel |
sexe | string | No | M or F |
Response
{
"success": true,
"data": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "CW-OIO-00001",
"nomComplet": "Fatou Sane",
"prenom": "Fatou",
"nom": "Sane",
"sexe": "F",
"telephone": "+245955123456",
"typeContrat": "volontaire",
"statut": "actif",
"dateRecrutement": "2025-01-15",
"region": {"id": "...", "nom": "Oio"},
"secteur": {"id": "...", "nom": "Farim"},
"localite": {"id": "...", "nom": "Farim Centro"}
}
],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"pages": 8
}
}
Get Community Worker Details
Endpoint
GET /api/community-workers/{id}
Response
{
"success": true,
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"code": "CW-OIO-00001",
"prenom": "Fatou",
"nom": "Sane",
"nomComplet": "Fatou Sane",
"sexe": "F",
"dateNaissance": "1990-05-10",
"lieuNaissance": "Farim",
"age": 36,
"telephone": "+245955123456",
"email": "fatou.sane@example.com",
"niveauInstruction": "secondaire",
"pieceIdentite": "carte_identite",
"numeroPieceIdentite": "GB123456",
"adresse": "Quartier Central, Farim",
"languePrincipale": "crioulo",
"languesSecondaires": ["portugais", "fula"],
"typeContrat": "volontaire",
"dateRecrutement": "2025-01-15",
"dateFinContrat": null,
"statut": "actif",
"photo": "photos/CW-OIO-00001_abc123.jpg",
"region": {"id": "...", "nom": "Oio"},
"secteur": {"id": "...", "nom": "Farim"},
"localite": {"id": "...", "nom": "Farim Centro"},
"superviseur": {
"id": "...",
"nomComplet": "Mamadou Diallo"
},
"affectationActuelle": {
"id": "...",
"zone": "Oio > Farim > Farim Centro",
"dateDebut": "2025-01-15"
},
"nbRapportsValides": 45,
"tauxValidation": 92.5,
"nbCertificationsValides": 3,
"derniereNote": "A",
"dernierRapport": "2026-06-10",
"derniereEvaluation": "2026-03-15",
"joursDepuisDerniereEvaluation": 88,
"prochaineCertificationExpire": {
"formation": "GBV Awareness",
"dateExpiration": "2026-09-15",
"joursRestants": 95
},
"createdAt": "2025-01-15T10:00:00+00:00",
"updatedAt": "2026-06-10T14:30:00+00:00"
}
}
Create a Community Worker
Endpoint
POST /api/community-workers
Request Body
{
"prenom": "Fatou",
"nom": "Sane",
"sexe": "F",
"dateNaissance": "1990-05-10",
"lieuNaissance": "Farim",
"telephone": "+245955123456",
"email": "fatou.sane@example.com",
"niveauInstruction": "secondaire",
"pieceIdentite": "carte_identite",
"numeroPieceIdentite": "GB123456",
"adresse": "Quartier Central, Farim",
"languePrincipale": "crioulo",
"languesSecondaires": ["portugais", "fula"],
"typeContrat": "volontaire",
"dateRecrutement": "2025-01-15",
"statut": "actif",
"regionId": "550e8400-e29b-41d4-a716-446655440001",
"secteurId": "550e8400-e29b-41d4-a716-446655440002",
"localiteId": "550e8400-e29b-41d4-a716-446655440003",
"superviseurId": "550e8400-e29b-41d4-a716-446655440004"
}
Required Fields
prenom: Community worker's first namenom: Community worker's last name
Behavior
- A unique code is automatically generated (format:
CW-{REGION_CODE}-{SEQUENCE}) - If a region/sector/locality is specified, an initial assignment is automatically created
- The assignment start date is the recruitment date (or today if not specified)
Response (201 Created)
{
"success": true,
"data": { ... },
"message": "Community Worker created successfully"
}
Update a Community Worker
Endpoint
PUT /api/community-workers/{id}
PATCH /api/community-workers/{id}
Request Body
All fields are optional. Only the provided fields are updated.
{
"telephone": "+245955999888",
"statut": "en_formation",
"typeContrat": "contractuel"
}
Response
{
"success": true,
"data": { ... },
"message": "Community Worker updated"
}
Delete a Community Worker
Endpoint
DELETE /api/community-workers/{id}
Required Permission
ROLE_ADMIN
Response
{
"success": true,
"message": "Community Worker deleted"
}
Warning
Deletion is permanent and will remove all associated data (assignments, activity reports, certifications, evaluations, payment slips).
Bulk Status Update
Endpoint
POST /api/community-workers/bulk-status
Request Body
{
"ids": [
"550e8400-e29b-41d4-a716-446655440001",
"550e8400-e29b-41d4-a716-446655440002"
],
"statut": "suspendu"
}
Valid Statuses
actifen_formationsuspenduinactif
Response
{
"success": true,
"message": "10 community workers updated",
"count": 10
}
Check for Duplicates
Endpoint
POST /api/community-workers/check-duplicates
Request Body
{
"nom": "Sane",
"prenom": "Fatou",
"telephone": "+245955123456",
"excludeId": "550e8400-e29b-41d4-a716-446655440000"
}
Response
{
"success": true,
"data": [
{
"id": "...",
"code": "CW-OIO-00005",
"nomComplet": "Fatou Sane",
"telephone": "+245955123456",
"statut": "actif"
}
],
"hasDuplicates": true
}
Usage
This function is automatically called before creation to warn the user of potential duplicates.