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:
- Give each contact a stable
id(employee number, directory user ID). If theidchanges, the app treats it as a different contact. If it is missing, the app uses the position in the file, which changes as soon as you reorder. - A contact is only used if it has at least one of: given name, family name, display name, work phone, mobile phone or work email.
- If two contacts share an
id, the first one is kept. - Save the file as UTF-8 without BOM. According to the code, a BOM at the start stops the format (JSON, vCard) or the first column (CSV) from being recognised. We have not tested this on a device.
- A downloaded file must not exceed 5 MB: in version 454 it is cut off and applied partially.
2. Fields and exact names
| Data | CSV column | JSON key | vCard |
|---|---|---|---|
| Identifier | id, uid | id, uid | UID |
| Given name | given_name, first_name, firstname | given_name, givenName, first_name, firstName | N (2nd value) |
| Family name | family_name, last_name, lastname, surname | family_name, familyName, last_name, lastName | N (1st value) |
| Display name | name, full_name, fullname, display_name | name, display_name, displayName, fullName | FN |
| Company | company, organization, org | company, organization, org | ORG (1st value) |
| Job title | title, position, role | title, position, role | TITLE; if missing, ROLE |
| Department | department, dept | department, dept | ORG (2nd value) |
| Work phone | phone_work, work_phone | phone_work, phoneWork, phone, workPhone | TEL;TYPE=WORK |
| Mobile phone | phone_mobile, mobile, cell | phone_mobile, phoneMobile, mobile, cell | TEL;TYPE=CELL |
| Home phone | phone_home, home_phone | phone_home, phoneHome, home | TEL;TYPE=HOME |
| Work email | email_work, work_email, email | email_work, emailWork, email | EMAIL;TYPE=WORK |
| Personal email | email_personal, personal_email | email_personal, emailPersonal | EMAIL with no type |
| Work address | address_work, address | address_work, address | ADR (street, city, postal code and country) |
| Website | website, url | website, url | URL |
| Notes | notes, note | notes, note | NOTE |
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
- The first line is the header and is required. The app ignores case in the header and treats spaces and hyphens as
_(“Display Name” works asdisplay_name). - The separator is the comma. The semicolon that Excel uses in some regional settings does not work.
- A value containing commas goes in double quotes:
"Calle Ejemplo 1, 28000 Madrid". A quote inside is written twice (""). - Each contact takes a single line: line breaks inside a cell are not supported.
- Careful: a plain
phonecolumn is not read in CSV. Usephone_work.
JSON
- The file is a list of objects: it starts with
[and ends with]. A single object wrapping the list is not read. - To paste it into the console, put it on one line.
vCard
- Versions 3.0 and 4.0. Each contact sits between
BEGIN:VCARDandEND:VCARD. - The first phone of each type is read. A phone with no type counts as a work phone.
- Put
TYPE=WORKon the work email: anEMAILwith no type is stored as personal. - Without a
UID, the identifier is computed from the name, the company and the position: it changes if any of them changes. - Photos and properties with a group prefix (
item1.TEL) are not read.
3. Export from Microsoft 365 / Entra ID
Option A: from the admin center
- 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”).
- You get a CSV. Its column names depend on the portal and change over time: look at the first line of your file.
- 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
- In the Google Admin console, go to Directory › Users and use “Download users”. Choose all columns and CSV format.
- Convert that CSV to the app's format (step 5).
Option B: with the Directory API or GAM
- Directory API: the
users.listmethod (GET https://admin.googleapis.com/admin/directory/v1/users?customer=my_customer&projection=full, with theadmin.directory.user.readonlyscope) returns each user'sid,name.givenName,name.familyName,primaryEmail,phonesandorganizations. Useidas the identifier. - GAM (a third-party command-line tool): a command along the lines of
gam print users fields id,primaryemail,name,phones,organizations > users.csv. Check the syntax in the documentation for your version.
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
- Upload the file to an HTTPS server of yours (intranet, corporate website) or to cloud storage.
- Put the address in
contacts_sourceand the domain indownload_allowed_hosts(for example,intranet.example.com). Separate several domains with commas. Subdomains of a listed domain are accepted too. - If the server redirects to another domain, add that domain as well.
- If
download_allowed_hostsis empty, the download is blocked. The asterisk*does not work, even though the console text in version 454 says it does. - If the server only has a private IP address, turn off
block_private_ips. - The app sends no username, password or authentication headers. The phone must be able to download the file without signing in. If the address is public, anyone who knows it can download the directory: decide with your security team how to limit access (for example, a server reachable only from the company network).
- An address that carries an access code in the address itself (a signed URL) should work according to the code, but we have not tested it.
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
- Copy the 64 hexadecimal characters. Upper or lower case does not matter.
- Each time you change the file you must update the hash in the MDM. Until they match, phones do not update.
- If you paste the directory into the console, the hash is that of the pasted text, without spaces or line breaks at the start or end.
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