Fetch the API account your token belongs to
- Bearer token
- Permission
api/* - Core record
The account whose apiKey signed the token: its _id, apiKey, companyName, scopes, roles and isActive, never its apiSecret. Call it to check that your tokens are accepted and which account they name.
The one operation without the envelope. The account is the whole body, not data inside { success, message, data }.
roles are the grants an operator gave your account, each { effect, action, target, authorized? }. When an operation answers 403 forbidden with "Insufficient role permissions", compare them with its x-permission: no allow role matched it on that organization, or a disallow role did.
It needs the api/* permission, which only a role whose action is api/*, */* or * grants; a role for the student or exam operations does not. A change an operator makes to your account, to its roles or deactivating it, can take up to 60 seconds to reach this and every other operation.
Responses
200 OK
The object itself, not wrapped in the { success, message, data } envelope every other operation answers with.
The body is the object itself, without the { success, message, data } envelope.
Body
_idstringrequiredYour account’s id.
example
6650a1b2c3d4e5f6a7b8c9f0apiKeystringrequiredYour account’s
apiKey: what goes in a token’skidheader andsubclaim.example
key_EXAMPLEexample0123456789companyNamestringrequiredThe company the account was issued to.
example
Example Learning Ltdscopesarray of stringrequiredLabels an operator set on the account. Informational: no operation checks them, and what your account may do is decided by its roles.
example
[]rolesarray of RoleResponserequiredWhat your account may do, as an operator set it. Compare them with an operation’s
x-permissionto see why it answers403 forbidden. Only an operator can change them, and a change reaches every operation within 60 seconds.4 fields of each item
effectstringrequiredallowgrants what the role matches;disallowrefuses it, and wins over everyallowthat matches the same request.one of
allowdisallowexample
allowactionstringrequiredThe operations it matches, as
<resource>/<operation>: an exact action such asstudent/read, a*for either part such asstudent/*or*/read, or*for every action. Each operation names the action it needs inx-permission.example
student/*targetstringrequiredThe organization it applies to: an organization’s
slug, or*for every organization. An operation without:organizationIdin its path acts onmto.example
mtoauthorizedstringAn account
_idthe role is limited to. Absent, or your own_id, and the role applies to your account; any other id and it does nothing, adisallowincluded.example
6650a1b2c3d4e5f6a7b8c9f0
isActivebooleanrequiredAlways
truehere: a token of an account that is not active is refused with401before this is reached.example
true
Headers
X-RateLimit-LimitintegerRequests your account may make to this operation per window (100).
X-RateLimit-RemainingintegerRequests left in the current window.
X-RateLimit-ResetintegerSeconds until the current window ends.
Example
{
"_id": "6650a1b2c3d4e5f6a7b8c9f0",
"apiKey": "key_EXAMPLEexample0123456789",
"companyName": "Example Learning Ltd",
"scopes": [],
"roles": [
{
"effect": "allow",
"action": "student/*",
"target": "mto",
"authorized": "6650a1b2c3d4e5f6a7b8c9f0"
}
],
"isActive": true
}401 Unauthorized
unauthorized: The token is missing or malformed, is not signed with your account’s apiSecret, breaks the iat and exp rules, has expired or been revoked, or its account is not active. All of these answer the same.
When
unauthorizedThe token is missing or malformed, is not signed with your account’s
apiSecret, breaks theiatandexprules, has expired or been revoked, or its account is not active. All of these answer the same.
Example
{
"error": {
"code": "unauthorized",
"documentation_url": "https://hub.main-team.org/api/errors#unauthorized",
"message": "Authentication is required or the provided credentials are invalid.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
403 Forbidden
forbidden: The token is valid, but no role on your account allows api/* on mto, the organization every operation without :organizationId acts on, or a role denies it.
When
forbiddenThe token is valid, but no role on your account allows
api/*onmto, the organization every operation without:organizationIdacts on, or a role denies it.
Example
{
"error": {
"code": "forbidden",
"documentation_url": "https://hub.main-team.org/api/errors#forbidden",
"message": "Insufficient role permissions",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
429 Too many requests
too_many_requests: Your account has made more than 100 requests to this operation in the current 60-second window. Wait the seconds in Retry-After before sending again.
When
too_many_requestsYour account has made more than 100 requests to this operation in the current 60-second window. Wait the seconds in
Retry-Afterbefore sending again.
Headers
Retry-AfterintegerSeconds to wait before sending again; a request sent sooner is refused too.
Example
{
"error": {
"code": "too_many_requests",
"documentation_url": "https://hub.main-team.org/api/errors#too_many_requests",
"message": "Too many requests to this operation. Wait the number of seconds in Retry-After, then try again.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.
500 Internal error
internal_error: Something failed on our side. Retry later, and quote request_id if it goes on.
When
internal_errorSomething failed on our side. Retry later, and quote
request_idif it goes on.
Example
{
"error": {
"code": "internal_error",
"documentation_url": "https://hub.main-team.org/api/errors#internal_error",
"message": "An unexpected error occurred.",
"request_id": "0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8e"
}
}Fields of the error body
errorobject · ErrorDetailrequiredWhat went wrong.
5 fields of error
codestringrequiredA stable machine code: branch on this. Each one is explained at
documentation_url.one of
invalid_emailbad_requestunauthorizedforbiddennot_foundconflictpayload_too_largeunsupported_media_typeunprocessable_entitytoo_many_requestsinternal_errorservice_unavailableexample
not_foundmessagestringrequiredWritten for a person, and may change: never branch on it.
example
Not found!documentation_urlstringrequiredWhere this code is explained.
format
uriexamplehttps://hub.main-team.org/api/errors#not_foundrequest_idstringrequiredThis request’s id, also sent as the
X-Request-Idresponse header: the one you sent, when it was acceptable, or else one the API made. Quote it when you report a problem.example
0b5c6d0e-8f7a-4b1c-9d2e-3f4a5b6c7d8edetailsobjectPresent only where an operation says so, and then with the shape that operation documents — the rows it could not accept, say. Treat it as absent everywhere else, and ignore a
detailsyou do not recognise.