Identities and Users

Identity is entity holder. User is entity owner.

Identities are mandatory.

Identity is entity that can be impersonated by User.

Use Identities to define holders of Accounts.

Parameters

Create Identity

Example model for neutral identity.

curl --location --request POST 'https://api.orangepill.cloud/v1/identities' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933deffda' \
--header 'Content-Type: application/json' \
--data-raw '{
    "country": "US",
    "currency": "USD",
    "type": "neutral",
    "data": {
        "nickname": "Player123",
        "level": "3",
        "color": "blue",
        "type": "premium",
        "external_reference": "ref-myreference1"
    }
}'

in response is new Identity.

{
    "id": "634b56217f6a7b0be52dffbd",
    "country": "US",
    "currency": "USD",
    "type": "neutral",
    "data": {
        "nickname": "Player123",
        "level": "3",
        "color": "blue",
        "type": "premium",
        "external_reference": "ref-myreference1"
    },
    "created_at": "1519211809934",
    "error": null
}

Now you can create new Account and use this Identity as Account holder.

Impersonation

To impersonate Identity you must assign it to a User. Each User is related to only one Identity. When new Account or Transaction is created it is owned by logged in User.Automatic own scope will filter out Accounts and Transactions owned by logged in User.

Create User

To impersonate Identities and enable ownership on entities create Users. API will resolve ownership of authenticated user and filter out results in scope own.

If you don't assign identity, it will be auto-created using Realm country and currency settings.

For Roles list check here.

For Scopes list check here.

Use channel object to define SMS, WhatsApp and Email messaging channels.


curl --location --request POST 'https://api.orangepill.cloud/v1/users' \
--header 'x-api-key: AXVubzpwQDU1dzByYM==' \
--header 'idempotency-key: 27373fabc392933de9354' \
--header 'Content-Type: application/json' \
--data-raw '{
    "username": "mdavis1969",
    "password": "P@ssw0rd",
    "scopes": "realm,own",
    "roles": "admin,manage,user",
    "channel": {
        "phone": "38598123456",
        "whatsapp": "38598123654",
        "email": "neo@zion.org"
    },    
    "data": {
        "email": "miles@davis.com",
        "my_field_1": "my_value_1",
        "external_reference": "ref-myreference1"
    }
}'

In response we get a new User.

{
    "identity": "634b56217f6a7b0be52dffbd",
    "username": "mdavis1969",
    "password": "21da8dc09355b747831267aeee57cf7ac82d7da748cb97c110e7853e14b90835d0965baa3bc7ca7ef53d4225b5afa98062fc141f28c2c7b42ecda7b5b593ded6",
    "scopes": "realm,own",
    "roles": "admin,manage,user",
    "channel": {
        "phone": "38598123456",
        "whatsapp": "38598123654",
        "email": "neo@zion.org"
    },    
    "data": {
        "email": "miles@davis.com",
        "my_field_1": "my_value_1",
        "external_reference": "ref-myreference1"
    },
    "active": true,
    "created_at": "1519211809934",
    "error": null
}

If you are building front-end app, you can authenticate User and have ownership mechanism working automatically. All new entities created by this User will have ownership assigned. Queries will filter out entities for which authenticated user is owner.

Last updated