How to fetch all the contacts of a client

Hi,

I need to fetch all the contacts and phone number under a clientId specified.

What would be the API needs to be used to fetch all the contacts.

Description: I have gone through the documents of Admin and under that contacts section there, we have two APIs.

  1. https://admin.dev.api.mitel.io/2017-09-01/contacts

  2. https://admin.dev.api.mitel.io/2017-09-01/accounts/{accountId}/contacts

I can be able to fetch some contacts. But I am confused as both the APIs returning the same result, so my question is, its related to a particular client or current account ID.

Also I tried to add a user from account.dev.mitel.io but i am not able to get the newly added user in API response.

Either of the routes that you referenced will work. If you use /contacts, the API determines which account to retrieve the contacts from based on the token used to make the request. This is fine as long as the user only exists in one account, otherwise you will receive an error message saying as much.

If you use the /accounts/{accountId}/contacts, you’re explicitly asking for contacts that exist in the specified account. Using this route would be the preferred practice, assuming you have the accountId.

Your reference to ‘clientId’ is a bit confusing, I assume you mean an account? ClientId refers to either the unique identifier for the Client resource (see the Admin API) or it refers to the application identifier that’s used as part of the OICD Authentication Workflow (see the Auth API).

As for your missing user, I just checked your account and tested GET /accounts/{accountId}/users which returned all 15 users I see in the Accounts portal. If you can provide info about which user you’re not seeing, I can look into it further. Feel free to PM me if you don’t want to post those details here.

Thanks @budd.renaud for the detailed response.
I will give it a try as per your suggestion and get back to you if something need.

Thanks again