Import phonebook contacts (Super Admin only)

POST /admin/phonebook/import

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:

  1. IP Whitelist - Request must come from an allowed IP/CIDR range (default: 127.0.0.0/8)
  2. Bearer Token - Must provide valid super admin token in Authorization header
multipart/form-data

Body Required

  • username string Required

    Target username to import contacts for

  • file string(binary) Required

    CSV file containing phonebook contacts

Responses

  • 200 application/json

    Phonebook import completed

    Hide response attributes Show response attributes object
    • message string
    • total_rows integer
    • imported_rows integer
    • failed_rows integer
    • skipped_rows integer
    • error_messages array[string]
  • 400 application/json

    Bad request - missing username field or invalid CSV

    Hide response attribute Show response attribute object
    • message string
  • 401 application/json

    Unauthorized - invalid or missing super admin token

    Hide response attributes Show response attributes object
    • code integer
    • message string
  • 403 application/json

    Forbidden - client IP is not in the super admin allowed IP whitelist

    Hide response attributes Show response attributes object
    • code integer
    • message string
  • 404 application/json

    Not found - target user does not exist

    Hide response attribute Show response attribute object
    • message string
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"
}