Account details and users through the API: contacts, who has access and two-factor status

API & DocumentationWhat You Can Automate·· 24 views· 5 min read

The short answer: with a key that has only account:read, your program reads the account details, the contacts and the people with access to the account. In this area the API only reads: details, contacts and users are changed in My MozOut. No answer ever carries passwords or card data.

The three operations

Operation What it returns
GET /v1/account The name, company, e-mail, phone, tax number (tax_id), address, currency, language and status of the account, whether the e-mail is confirmed (email_verified) and the date it was opened (created_at).
GET /v1/account/contacts The contacts registered on the account, each with name, company, e-mail, phone and address. It comes in pages.
GET /v1/account/users The people with access to the account. The owner comes first, with owner set to true. It comes in pages.

curl https://api.mozout.com/v1/account -H "Authorization: Bearer $MOZOUT_API_KEY"
curl "https://api.mozout.com/v1/account/users?per_page=100" -H "Authorization: Bearer $MOZOUT_API_KEY"

Lists bring 10 results per page, or up to 100 with per_page. To read them to the end without wasting requests, see paginated lists.

Contacts and users are not the same thing

Contacts are the people registered on the account: the API only tells you who they are and how to reach them. Users are the people with access to the account: besides name and e-mail, the API tells you whether they are the owner, whether two-factor authentication is on, which permissions they have and when they last signed in.

User field What it tells you
owner true for the account owner, who always comes first.
two_factor_enabled Whether the person has two-factor authentication switched on.
permissions What the person may do when signing in to My MozOut. These are not the permissions of the API key. For the owner the list may be empty, because the owner always has every permission.
last_login_at The last sign-in to the account, with date, time and time zone.

An access review run by your program

1 Create a key with only account:read and, if the program runs on a server with a fixed IP, with an IP list. See creating an API key.
2 Read every page of GET /v1/account/users: start at page=1 and carry on while page is lower than total_pages.
3 Flag what needs attention: anyone with two_factor_enabled set to false, anyone who has not signed in for a long time, according to last_login_at, and anyone with more permissions than their work calls for.
4 Fix it in My MozOut: remove access for people who no longer work with you, cut back permissions and ask each person to switch on two-factor authentication. See how to manage sub-accounts and how to enable two-factor authentication.
This is personal data, and a Sandbox key reads it too. In Sandbox, reads are real: real names, e-mails, phone numbers and addresses. Keep this key as carefully as a Production key and, if it leaks, revoke it at once. See what to do when a key leaks.

Account details in your own systems

GET /v1/account lets your invoicing system or CRM hold the same company name, tax number and address as the account. The currency field tells you which currency the account works in: it is the currency the API uses for extras prices and for the keys' spending limits.

Read these details from time to time, not on every page your system shows: each read counts towards the request limits.

What this area does not do yet

Task Where it stands today
Changing the account details and contacts Done in My MozOut. The documentation lists it as planned for the API.
Seeing the security log and managing SSH keys Listed as planned in the documentation. Not in the API yet.
Creating another key, changing the account's password or e-mail, seeing card data Never through the API, whatever permissions the key has.

The account:write permission already shows up when you create a key, but it has no operations yet. Leave it unticked: give each key only what it uses today. And if the person who created the key loses access to the account, the key stops working: the API answers 401 with unauthorized.

To try it before you write code: the Account and security page of the documentation has the sample answers and the Playground, where you send the request from your browser with a Sandbox key. Permissions for every area are in API permissions by area.

Want to connect your account details to your own system? Create a key with only the account:read permission.

Create a key

SEE ALSO

Creating an API key: name, mode, permissions, validity, IP list and spending limit

API permissions by area: read or write, and which permission each task needs

Paginated lists in our API: page, per_page and reading every page without wasting requests

How to manage sub-accounts

How to enable or disable two-factor authentication (2FA)

An API key or token has leaked: what to do, in the right order

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from £5.28/mo (3-year plan, with coupon)

See plans
Was this answer helpful? Your answer helps us improve this article.