Skip to main content
A person’s role applies across the whole organization. Sometimes that isn’t enough: a branch approver should approve payouts for their branch, not every branch. Fine-grained authorization lets you give a role on one part of your organization. It covers that part and everything under it, never the parts beside it.
Fine-grained authorization is available on the Business plan and above. Reading and the check keep working after a move to a lower plan, and so does removing things.

The model

  • Types of part form a tree, for example region → branch. Each type has a key your apps use (fixed once made), a name and one parent type. The top type sits under your organization. You can have up to 20 types, at most 4 levels deep.
  • Roles for parts are made for one type, for example branch_approver on each branch. A role for parts carries your app permissions only, never Aiveth powers, so it never makes anyone an admin. Its key must differ from your whole-organization role keys. You can have up to 100.
  • Parts are the actual regions, branches or projects. Each has your own id (external_id, 1 to 128 characters), a name, and a parent part of the parent type. An organization can have up to 50,000 parts.
  • Access gives a role for parts on one part to a person or a group. A group’s access reaches every member, including people who join later.
Types and roles for parts are made in the console. Parts and access can be managed in the console or from your server through the admin API.

Set it up in the console

1

Add types

Go to Parts & access and choose Type. Start at the top, like region, then add the types under it, like branch.
2

Add roles for parts

Choose Role, pick the type it applies to, and tick the app permissions it carries, like claim:approve.
3

Add parts

Choose Part, or let your app register parts as it makes them (below).
4

Give access

Open a part and give a role on it to a person or a group.
Changing this needs the Manage roles power. Seeing it needs See people.

The check

Your server asks: may this person do this permission on this part? The answer is yes when either:
  1. the person’s whole-organization role carries the permission (what their token already says), or
  2. the person, or a group they are in, holds a role for parts carrying the permission on this part or any part above it.
Everything else is no, including an unknown part, another organization’s part, and a suspended or removed person. A malformed person id is also simply no. The answer says why it allowed the request in via:
kind is organization_role (with role) or resource_role. group appears only when the access came through a group. via is null when allowed is false.

Admin API

Your server calls the admin API with an API key in the Authorization: Bearer aiveth_sk_... header. Each endpoint needs one of these key powers:

Register a part

string
required
The type key, like branch.
string
required
Your own id for the part.
string
required
Up to 200 characters.
string
The parent part’s type. Required unless the type sits at the top.
string
The parent part’s id.

Give access

string
required
The part’s type key.
string
required
The part’s id.
string
required
The role for parts. It must be made for this part’s type.
string
The person to give it to. Send this or group_id, not both.
string
The group to give it to.

Examples

The Node SDK also has resourcesFor, accessOf, find, get, peopleWith, change, remove and take. See Node SDK.

Rules

  • Nobody gives access to themselves, or to a group they are in, unless they are an Owner. An API key never gives access to its maker.
  • A group that holds roles on parts hands them to anyone who joins, so changing its members needs Manage roles, and each change is recorded.
  • A part can move only to a new parent of the parent type. Removing a part is refused while parts sit under it, unless you pass everything_below=true.
  • Nothing is removed while something stands on it: a type with parts, child types or roles; a role anyone holds; a group that holds roles on parts.
  • Lists of parts return at most 500 at a time.
  • Every change is recorded in the activity log and sends a webhook.

Errors