Admin phonebook import endpoint for super administrators.
This endpoint allows super administrators to import phonebook contacts from a CSV file into any target user's phonebook. The target username must be provided as a form field.
CSV Format: Requires multipart/form-data with:
- Field "username" (string, required): Target username to import contacts for
- Field "file" (binary, required): CSV file with contact data
CSV Columns (case-insensitive): name (required), and optional: workemail, homeemail, workphone, homephone, cellphone, fax, title, company, notes, homestreet, homepob, homecity, homeprovince, homepostalcode, homecountry, workstreet, workpob, workcity, workprovince, workpostalcode, workcountry, url, extension, speeddial_num, type (optional, default: private).
Security: Requires two factors of authentication:
- IP Whitelist - Request must come from an allowed IP/CIDR range (default: 127.0.0.0/8)
- Bearer Token - Must provide valid super admin token in Authorization header
POST
/admin/phonebook/import
curl \
--request POST 'https://middleware.example.com/api/admin/phonebook/import' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: multipart/form-data" \
--form "username=john.smith" \
--form "file=@file"
Response examples (200)
{
"message": "phonebook import completed",
"total_rows": 10,
"imported_rows": 9,
"failed_rows": 0,
"skipped_rows": 1,
"error_messages": [
"Row 5: invalid type 'business' (must be 'private' or 'public')"
]
}
Response examples (400)
{
"message": "username field is required"
}
Response examples (401)
{
"code": 401,
"message": "super admin authentication required"
}
Response examples (403)
{
"code": 403,
"message": "access denied: IP not in allowed list"
}
Response examples (404)
{
"message": "target user not found"
}