Skip to main content

Voters API Endpoints

Complete API reference for voter management endpoints.

List Voters

Retrieve a paginated list of voters.

GET /api/voters
Authorization: Bearer {token}

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number
per_pageinteger15Items per page (max: 100)
searchstring-Search term
constituencystring-Filter by constituency
boothstring-Filter by booth number
wardstring-Filter by ward

Response

{
"success": true,
"data": {
"data": [
{
"id": 1,
"name": "John Doe",
"phone": "+919876543210",
"constituency": "ABC",
"booth": "123",
"ward": "5"
}
],
"current_page": 1,
"per_page": 15,
"total": 1000,
"last_page": 67
}
}

Get Voter

Retrieve a specific voter by ID.

GET /api/voters/{id}
Authorization: Bearer {token}

Response

{
"success": true,
"data": {
"id": 1,
"name": "John Doe",
"phone": "+919876543210",
"email": "john@example.com",
"constituency": "ABC",
"booth": "123",
"ward": "5",
"address": "123 Main St",
"created_at": "2024-01-01T00:00:00Z",
"updated_at": "2024-01-01T00:00:00Z"
}
}

Create Voter

Create a new voter record.

POST /api/voters
Authorization: Bearer {token}
Content-Type: application/json

{
"name": "John Doe",
"phone": "+919876543210",
"email": "john@example.com",
"constituency": "ABC",
"booth": "123",
"ward": "5",
"address": "123 Main St"
}

Required Fields

  • name (string): Voter name
  • phone (string): Phone number

Optional Fields

  • email (string): Email address
  • constituency (string): Constituency name
  • booth (string): Booth number
  • ward (string): Ward number
  • address (string): Address

Response

{
"success": true,
"message": "Voter created successfully",
"data": {
"id": 1,
"name": "John Doe",
"phone": "+919876543210",
"created_at": "2024-01-01T00:00:00Z"
}
}

Update Voter

Update an existing voter record.

PUT /api/voters/{id}
Authorization: Bearer {token}
Content-Type: application/json

{
"name": "John Doe Updated",
"email": "john.updated@example.com"
}

Response

{
"success": true,
"message": "Voter updated successfully",
"data": {
"id": 1,
"name": "John Doe Updated",
"updated_at": "2024-01-02T00:00:00Z"
}
}

Delete Voter

Delete a voter record.

DELETE /api/voters/{id}
Authorization: Bearer {token}

Response

{
"success": true,
"message": "Voter deleted successfully"
}

Bulk Import

Import multiple voters from CSV.

POST /api/voters/import
Authorization: Bearer {token}
Content-Type: multipart/form-data

file: [CSV file]

Response

{
"success": true,
"message": "Voters imported successfully",
"data": {
"imported": 100,
"failed": 5,
"errors": []
}
}

Export Voters

Export voters to CSV.

GET /api/voters/export
Authorization: Bearer {token}

Query Parameters

  • format: csv (default) or excel
  • filters: JSON string of filters

Response

Returns CSV or Excel file download.

Next Steps


Need help? Contact Support