> For the complete documentation index, see [llms.txt](https://developers-apps-in-toss.toss.im/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/sdk/domains-api/device/device.getcontacts.md).

# Device.getContacts

> Functional API `fetchContacts`You can use the same feature with it as well.

### Feature description

Fetch the user's contact list page by page. `size`·`offset`paginate with `query.contains`to search by name containing text. `offset`is on the first call `0`, and afterward use the response's `nextOffset`Use it.

If there is no permission to read contacts `FetchContactsPermissionError`occurs. `Device.getContacts.getPermission()` / `Device.getContacts.openPermissionDialog()`you can check/request permission with

### Type

```ts
Device.getContacts(options: FetchContactsOptions): Promise<ContactResult>;
```

**Params**

```ts
type FetchContactsOptions = {
  size: number;
  offset: number;
  query?: {
    contains?: string;
  };
};
```

**Response**

```ts
type ContactEntity = {
  name: string;
  phoneNumber: string;
};

type ContactResult = {
  result: ContactEntity[];
  nextOffset: number | null;
  done: boolean;
};
```

### Error

The error is thrown as a class — `error instanceof FetchContactsPermissionError`identify it with. The class can `@apps-in-toss/web-framework`be imported from

| Error class                    | Description                                                                                                                   |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `FetchContactsPermissionError` | This occurs when permission to read contacts is denied. `Device.getContacts.openPermissionDialog()`You can request again with |

### Example code

```js
import {
  Device,
  FetchContactsPermissionError,
} from "@apps-in-toss/web-framework";

let nextOffset = 0;
let done = false;

async function loadNextContacts() {
  if (done) {
    return;
  }

  try {
    const response = await Device.getContacts({
      size: 10,
      offset: nextOffset ?? 0,
      query: { contains: "김" },
    });

    for (const contact of response.result) {
      console.log(`${contact.name}: ${contact.phoneNumber}`);
    }

    nextOffset = response.nextOffset;
    done = response.done;
  } catch (error) {
    if (error instanceof FetchContactsPermissionError) {
      console.warn("No permission to read contacts.");
      return;
    }
    console.error(error);
  }
}

document
  .getElementById("load-contacts")
  .addEventListener("click", loadNextContacts);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers-apps-in-toss.toss.im/documentation/api-and-sdk-en/sdk/domains-api/device/device.getcontacts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
