Directory preparation kit

Templates, exact columns and examples for getting the directory out of Microsoft 365 or Google Workspace and into the format SecureContacts reads.

Everything on this page describes the version published on Google Play (454) and is taken from its code. The internal test version reads the same formats and fields. Where we have not tested something on a phone, we say so.

1. Templates

Three files with three fictitious contacts. Pick one format; all three hold the same data. The sample values are in Spanish.

Rules common to all three formats:

2. Fields and exact names

DataCSV columnJSON keyvCard
Identifierid, uidid, uidUID
Given namegiven_name, first_name, firstnamegiven_name, givenName, first_name, firstNameN (2nd value)
Family namefamily_name, last_name, lastname, surnamefamily_name, familyName, last_name, lastNameN (1st value)
Display namename, full_name, fullname, display_namename, display_name, displayName, fullNameFN
Companycompany, organization, orgcompany, organization, orgORG (1st value)
Job titletitle, position, roletitle, position, roleTITLE; if missing, ROLE
Departmentdepartment, deptdepartment, deptORG (2nd value)
Work phonephone_work, work_phonephone_work, phoneWork, phone, workPhoneTEL;TYPE=WORK
Mobile phonephone_mobile, mobile, cellphone_mobile, phoneMobile, mobile, cellTEL;TYPE=CELL
Home phonephone_home, home_phonephone_home, phoneHome, homeTEL;TYPE=HOME
Work emailemail_work, work_email, emailemail_work, emailWork, emailEMAIL;TYPE=WORK
Personal emailemail_personal, personal_emailemail_personal, emailPersonalEMAIL with no type
Work addressaddress_work, addressaddress_work, addressADR (street, city, postal code and country)
Websitewebsite, urlwebsite, urlURL
Notesnotes, notenotes, noteNOTE

Where a field has several names, the app uses the first one in the list that has a value. Columns or keys not in the table are ignored. Include home phone and personal email only if the person has agreed.

CSV

JSON

vCard

3. Export from Microsoft 365 / Entra ID

Option A: from the admin center

  1. In the Microsoft 365 admin center, go to Users › Active users and choose “Export users”. In the Microsoft Entra admin center, the equivalent is under Users › All users (“Download users”).
  2. You get a CSV. Its column names depend on the portal and change over time: look at the first line of your file.
  3. Convert that CSV to the app's format (step 5).

Option B: with Microsoft Graph PowerShell

You run this example yourself, on your infrastructure and with your account. It writes agenda.csv with the app's columns already, and uses the user's Entra ID object ID, which does not change, as the id.

# EXAMPLE ONLY. Review it before use. Run it on your own infrastructure, with your own account.
# Needs the Microsoft.Graph.Users module and read access to users (User.Read.All).
Connect-MgGraph -Scopes "User.Read.All"

$props = "id","givenName","surname","displayName","companyName","jobTitle",
         "department","businessPhones","mobilePhone","mail","userType"

Get-MgUser -All -Filter "accountEnabled eq true" -Property $props |
  Where-Object { $_.UserType -eq "Member" -and ($_.BusinessPhones -or $_.MobilePhone -or $_.Mail) } |
  ForEach-Object {
    [pscustomobject]@{
      id           = $_.Id
      given_name   = $_.GivenName
      family_name  = $_.Surname
      name         = $_.DisplayName
      company      = $_.CompanyName
      title        = $_.JobTitle
      department   = $_.Department
      phone_work   = ($_.BusinessPhones | Select-Object -First 1)
      phone_mobile = $_.MobilePhone
      email_work   = $_.Mail
    }
  } |
  Export-Csv -Path .\agenda.csv -NoTypeInformation -Encoding utf8NoBOM   # PowerShell 7 or later

Disconnect-MgGraph

In Windows PowerShell 5.1, -Encoding UTF8 adds a BOM; use PowerShell 7 or strip the BOM afterwards.

4. Export from Google Workspace

Option A: from the Admin console

  1. In the Google Admin console, go to Directory › Users and use “Download users”. Choose all columns and CSV format.
  2. Convert that CSV to the app's format (step 5).

Option B: with the Directory API or GAM

5. Convert your CSV to the app's format

You only need to rename the header to the names in the field table and save with commas, as UTF-8 without BOM. You can do it by hand in a spreadsheet or with this Python example. MAP is the part you adapt: on the left, the column name in your file; on the right, the app's.

#!/usr/bin/env python3
# EXAMPLE ONLY. Review it before use. Runs on your computer; it sends nothing anywhere.
# Usage: python3 convert-csv.py export.csv agenda.csv
import csv, sys

# Left: the column name in YOUR export (check your file's first line).
# Right: the column name SecureContacts reads.
MAP = {
    "Employee ID": "id",
    "First Name [Required]": "given_name",
    "Last Name [Required]": "family_name",
    "Email Address [Required]": "email_work",
    "Work Phone": "phone_work",
    "Mobile Phone": "phone_mobile",
    "Department": "department",
    "Employee Title": "title",
}

with open(sys.argv[1], newline="", encoding="utf-8-sig") as src, \
     open(sys.argv[2], "w", newline="", encoding="utf-8") as dst:   # UTF-8, no BOM
    reader = csv.DictReader(src)
    writer = csv.DictWriter(dst, fieldnames=list(dict.fromkeys(MAP.values())))
    writer.writeheader()
    for row in reader:
        out = {new: " ".join((row.get(old) or "").split()) for old, new in MAP.items()}
        if not out.get("id"):
            out["id"] = out.get("email_work", "")   # stable fallback: the work email
        if out["id"] and (out.get("phone_work") or out.get("phone_mobile") or out.get("email_work")):
            writer.writerow(out)

The scripts on this page are examples. They contain no real keys or identifiers. Review them before use, run them on your own infrastructure and check the result with a few contacts. We receive nothing of what you export.

6. Where to put the file

On an HTTPS server

  1. Upload the file to an HTTPS server of yours (intranet, corporate website) or to cloud storage.
  2. Put the address in contacts_source and the domain in download_allowed_hosts (for example, intranet.example.com). Separate several domains with commas. Subdomains of a listed domain are accepted too.
  3. If the server redirects to another domain, add that domain as well.

Pasted into the console

If the directory is small, paste the content straight into contacts_source, preferably as JSON on one line. That way you need no server and no download_allowed_hosts. The maximum size depends on your MDM. This is the only route we have tested on a device (see Tested on).

contacts_format can stay at auto. The accepted values are auto, json, vcard, csv and url.

7. The source_sha256 hash (optional)

If you fill in source_sha256, the app only applies the directory when its SHA-256 hash matches. If it does not match, it keeps the previous directory and shows an error.

shasum -a 256 agenda.csv                         # macOS
sha256sum agenda.csv                             # Linux
Get-FileHash agenda.csv -Algorithm SHA256        # PowerShell

Next step

With the file ready, follow the IT guide. If you would like help, request a pilot or write to hola@securecontacts.app.

— SecureContacts Team · hola@securecontacts.app