The rules of the Scope, as many as needed. A rule selects resources and either gives access to them (inclusion_mode INCLUDE, the default) or removes it from the resources the other rules select (EXCLUDE). It has:
resource_type: USER, COMPANY_CARD, COMPANY_WALLET, MAIN_WALLET or GROUP.
selection_mode: which resources of that type. The values admitted depend on the resource_type: see the table.
The fields of that selection. A field of the type that does not belong to the selection (e.g. job_titles with ALL) is rejected with a 400 that says what the field is for. A field that does not exist for the resource_type (e.g. labels in a USER rule) is ignored, it is not an error.
resource_typeselection_modeSelects Fields USERALLall the users none USERREPORTING_TO_MEthe users who report to the user the Scope is used for none USERCREATED_BY_MEthe users created by that user none USERONLY_MEthat user only none USERSELECTEDthe users in resource_ids resource_ids (required)USERMATCHING_PROPERTIESthe users with one of the job_titles job_titles (required)COMPANY_CARDALLall the company cards none COMPANY_CARDCREATED_BY_MEthe cards created by the user the Scope is used for none COMPANY_CARDASSIGNED_TO_MEthe cards assigned to that user none COMPANY_CARDSELECTEDthe cards in resource_ids resource_ids (required)COMPANY_CARDMATCHING_PROPERTIESthe cards with a label containing one of the labels, and/or one of the currencies at least one of labels, currencies; with both the card has to match both COMPANY_WALLETALLall the company wallets none COMPANY_WALLETCREATED_BY_MEthe wallets created by the user the Scope is used for none COMPANY_WALLETSELECTEDthe wallets in resource_ids resource_ids (required)COMPANY_WALLETMATCHING_PROPERTIESthe wallets whose currency is one of the currencies currencies (required)MAIN_WALLETALLall the main wallets none MAIN_WALLETSELECTEDthe wallets in resource_ids resource_ids (required)MAIN_WALLETMATCHING_PROPERTIESthe wallets whose currency is one of the currencies currencies (required)GROUPALLall the groups none GROUPCREATED_BY_MEthe groups created by the user the Scope is used for none GROUPSELECTEDthe groups in resource_ids resource_ids (required)
Selecting by properties (MATCHING_PROPERTIES). Besides choosing the resources by ID (SELECTED) or by their relation with the user (CREATED_BY_ME, ...), a rule can select the resources that have given properties: set selection_mode to MATCHING_PROPERTIES and give the properties of the resource type. For example, the users with the job title Developer or Manager:
JSON
{
"resource_type": "USER",
"inclusion_mode": "INCLUDE",
"selection_mode": "MATCHING_PROPERTIES",
"job_titles": ["Developer", "Manager"]
}
The properties of each resource type are: job_titles for USER; labels and currencies for COMPANY_CARD; currencies for COMPANY_WALLET and MAIN_WALLET. The values of a property are alternatives (one of them is enough); with more than one property the resource has to match all of them.
Also:
resource_ids holds the IDs the API gives to the users, the cards, the wallets and the groups. An ID that is not one of the account is rejected with a 400.
Two rules cannot have the same resource_type, inclusion_mode and selection_mode: put all the values in a single rule. The MATCHING_PROPERTIES rules are the exception, each one is an alternative.
ALL already selects everything of its resource_type: do not add other INCLUDE rules of that type next to it.
A resource_type with no rule gives no access.