# Contact Picker API

> navigator.contacts.select() opens a one-off contact picker. This reference covers syntax, errors, Android and iOS support, and form fallbacks.

The `navigator.contacts.select()` method asks the user to choose contacts and the details to share with a page. The user agent presents the picker, and the page receives one-off access to the selected records instead of standing access to the address book.

The `api.Navigator.contacts` and `api.ContactsManager` compatibility data records support from Chrome 80 on Android M (Android 6) and Android WebView 80. It records no support in desktop Chrome, Edge, Firefox, or macOS Safari; iOS 14.5 Safari has the `Contact Picker API` preference, and Samsung Internet 14.0 exposed an implementation that failed when opening the selector before removal in 22.0. MDN classifies the API as experimental and outside Baseline. The [Contact Picker compatibility data](/compatibility/contact-picker/) carries the browser rows and their verification date.

## Syntax

The API exposes `select()` and `getProperties()` through `navigator.contacts` on a `[SecureContext]` interface in `Window`. `select()` must run in a top-level traversable with transient user activation. The specification defines `getProperties()` without those two checks.

| Operation | Signature | Result |
|---|---|---|
| Pick contacts | `navigator.contacts.select(properties, options?)` | `Promise<sequence<ContactInfo>>` |
| List available fields | `navigator.contacts.getProperties()` | `Promise<sequence<ContactProperty>>` |

```js
navigator.contacts.select(properties)
navigator.contacts.select(properties, options)
navigator.contacts.getProperties()
```

Calling `select()` consumes transient activation before it opens the picker. The picker UI must display the requesting origin, identify the requested properties, let the user select individual contacts, and offer a cancel path. Cancellation returns an empty sequence. When `options.multiple` is false, the UI allows one contact to be picked.

`getProperties()` reports the fields offered by the contact source chosen by the user agent. Use its result to build the array passed to `select()`; the specification rejects a selection request when that array contains a field outside the source's supported set.

## Parameters

`select()` takes a sequence of contact fields and an optional selection dictionary. The Contact Picker specification defines the following values.

| Parameter | Type | Required | Meaning |
|---|---|---|---|
| `properties` | `sequence<ContactProperty>` | Yes | Requested fields. The enum contains `"address"`, `"email"`, `"icon"`, `"name"`, and `"tel"`. |
| `options.multiple` | `boolean` | No | Defaults to `false`. Set it to `true` to allow more than one selected contact. |

Chrome documents `name`, `email`, and `tel` in Chrome 80 on Android M or later, with `address` and `icon` requiring Chrome 84 or later. Query `getProperties()` instead of assuming that every contact source supplies each enum value.

The returned `ContactInfo` dictionary uses sequences because a selected contact can have more than one value for a field. A dictionary includes the fields requested by the caller. `ContactAddress` represents each physical address.

| Member | Type | Content |
|---|---|---|
| `name` | `sequence<DOMString>` | Names from the selected contact |
| `email` | `sequence<DOMString>` | Email addresses from the selected contact |
| `tel` | `sequence<DOMString>` | Telephone numbers from the selected contact |
| `address` | `sequence<ContactAddress>` | Physical addresses; the interface includes `country`, `addressLine`, `region`, `city`, and `postalCode`. W3C's 2021 activity records the change that transplanted `PaymentAddress` into `ContactInfo`. |
| `icon` | `sequence<Blob>` | Contact images represented by `Blob` objects |

Chrome documents an empty sequence when the selected contact lacks a requested value or the user chooses not to share that value. The picker therefore does not tell the page which of those conditions produced the empty sequence. Chrome also documents that labels and other semantic information attached to contact fields are dropped.

## Exceptions

The `select()` algorithm checks the calling context, user activation, picker state, and requested properties before presenting any UI.

| Exception | Condition |
|---|---|
| `InvalidStateError` | The caller is not a top-level traversable, a picker is already showing for the navigable, or launching the picker or reading its contact source fails. |
| `SecurityError` | The relevant global object has no transient activation. |
| `TypeError` | `properties` is empty or includes a property that the contact source does not support. |

Chromium's implementation reports a different exception when its Android selector cannot open: it rejects with `TypeError: Unable to open a contact selector`. Code that recovers from picker failures should handle the rejected promise rather than branching only on the exception names in the specification. A delayed callback can run after transient activation expires and then fail the implementation's activation check, so call `select()` as soon as practical within the activation handler.

:::caution
Chromium's [`contacts_manager.cc`](https://chromium.googlesource.com/chromium/src/+/main/third_party/blink/renderer/modules/contacts_picker/contacts_manager.cc) emits `InvalidStateError: The contacts API can only be used in the top frame` outside the outermost main frame, `SecurityError: A user gesture is required to call this method` without transient activation, and `InvalidStateError: Contacts Picker is already in use.` for an overlapping call. Keep `select()` in the button handler and disable that button while its promise is pending.
:::

## Examples

Both examples keep a form path available. Feature detection can decide which control to show, but a supported implementation can still reject or return a contact without the requested value.

### Picking one email with a manual fallback

Place a button and an `<input type="email">` in the document. Test `'contacts' in navigator && 'ContactsManager' in window`, then call `select()` directly from the `click` handler. Treat an empty result as cancellation, and reveal the input after a missing email or rejected promise.

```js
const pickButton = document.querySelector('#pick-recipient');
const manualField = document.querySelector('#recipient-email');

const supported = 'contacts' in navigator && 'ContactsManager' in window;
pickButton.hidden = !supported;
manualField.hidden = supported;

pickButton.addEventListener('click', async () => {
  try {
    const [contact] = await navigator.contacts.select(['name', 'email']);
    if (!contact) return; // user cancelled
    const email = contact.email[0];
    if (!email) {
      manualField.hidden = false; // contact had no email address
      return;
    }
    manualField.value = email;
  } catch (err) {
    console.error(`${err.name}: ${err.message}`);
    manualField.hidden = false;
  }
});
```

The input is the recovery path on unsupported browsers and after an error. Checking `contact.email[0]` also covers a contact whose email field is absent or withheld, as described by Chrome's Contact Picker documentation.

### Recovering when requested properties are unavailable

Ask the contact source which values it supports before opening the picker. This function filters a desired list, passes `multiple: true`, returns `null` when the API or usable fields are absent, and leaves the caller to render its attendee form. A missing first value would otherwise produce `undefined`.

```js
async function pickAttendees(wanted = ['name', 'tel', 'icon']) {
  if (!('contacts' in navigator && 'ContactsManager' in window)) {
    return null; // caller shows its own attendee form
  }
  const available = await navigator.contacts.getProperties();
  const props = wanted.filter((p) => available.includes(p));
  if (props.length === 0) return null;

  const contacts = await navigator.contacts.select(props, { multiple: true });
  return contacts.map((c) => ({
    name: c.name?.[0] ?? '',
    tel: c.tel?.[0] ?? '',
    avatar: c.icon?.[0] ? URL.createObjectURL(c.icon[0]) : null,
  }));
}
```

Call this function from a user-activation handler because `select()` consumes transient activation. A `null` result tells the caller to display its form; an empty array means the picker returned no selected contact. Catch a rejection at the call site and show the same form, as the first example does.

## See also

- [Contact Picker API browser support](/compatibility/contact-picker/)
- [Web Share API](/reference/capabilities/web-share/)
- [Payment Request API](/reference/capabilities/payment-request/)
- [Contact Picker API](https://w3c.github.io/contact-picker/) (w3.org)
- [A contact picker for the web](https://developer.chrome.com/docs/capabilities/web-apis/contact-picker) (developer.chrome.com)
- [Chrome Platform Status: Contacts API](https://chromestatus.com/feature/6511327140904960) (chromestatus.com)