Memberships
An organization can have several users. As long as these users belong to the organization, they are called members and the relation between a user and an organization is called Membership.
Each membership has a role and an importance and responsibility. Below there's a description of each one of them:
- User: This is the lowest responsibility role. A regular user can only create new Expenses and follow it's updates. He can also follow Reimbursement's updates and Advancement's updates that he is the receiver.
- Analyst: Can add and remove new members to the organization and promote them to Analysts. It's main responsibility is to manage Expenses.
- Manager: Can add and remove new members to the organization and promote them to Analysts or Managers. It's main responsibility is to finish Expenses by using Reimbursements or Advancements.
- Admin: Can add and remove new members to the organization and promote them to Analysts, Managers and Administrators. An Administrator can do any action in related to the organization, even delete it. He is the main responsible for the organization and cannot leave the organization unless it has an another Administrator.
Parameters
role: |
string 'admin', 'manager', 'analyst' and 'member' the role of the user in the organization |
user: | JSON object |
organization: | JSON object |
_links: | array of object array of links of the organization's member |
Example Membership
List all memberships
Retrieve the list of memberships of an organization. It will return a JSON containing the name of the resource with an array of the objects requested using the membership representation.
Also, the response is always paginated. To select different pages, you have to pass the following parameters.
Parameters
page: | integer |
per_page: | integer |
Definition
GET https://app.rexpense.com/api/v1/organizations/:organization_id/members
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/organizations/:organization_id/members \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Example Response
Show a membership
Retrieve a specific membership of an organization. Returns a detailed representation of the membership.
Definition
GET https://app.rexpense.com/api/v1/organizations/:organization_id/members/:user_id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/organizations/:organization_id/members/:user_id \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Create a membership
Creates an invitation for each email. Those invitations are processed asynchronously in another job.
Parameters
user[email]: |
string required one or more e-mails, separated by commas |
Expired organization
If the organization is expired, it will return an 402 error.
Definition
POST https://app.rexpense.com/api/v1/organizations/:organization_id/members/
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/organizations/:organization_id/members \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"user": {"email":"user@email.com, another.user@email.com"}}'
Example Response Success
HTTP 201 CREATED
Example Response Failure
HTTP 422 Unprocessable Entity
Example Response Failure when some recipients are correct and others not
HTTP 422 Unprocessable Entity
Example Response Failure when organization is expired
HTTP 402 Payment Required
Update a membership
Updates the role of the user in the organization. Returns a detailed representation of the membership.
Parameters
role: |
string 'admin', 'manager' and 'member' the role of the user in the organization |
Expired organization
If the organization is expired, it will return an 402 error.
Definition
PUT https://app.rexpense.com/api/v1/organizations/:organization_id/members/:user_id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PUT https://app.rexpense.com/api/v1/organizations/:organization_id/members/:user_id \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"role":"member"}'
Example Response Success
HTTP 200 OK
Example Response Failure
HTTP 422 Unprocessable Entity
Example Response Failure when organization is expired
HTTP 402 Payment Required
Remove a membership
Removes a membership from an organization.
Expired organization
If the organization is expired, it will return an 402 error.
Definition
DELETE https://app.rexpense.com/api/v1/organizations/:organization_id/members/:user_id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/organizations/:organization_id/members/:user_id \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Example Response Success
HTTP 204 NO CONTENT
Example Response Failure when organization is expired
HTTP 402 Payment Required
Leave an organization
You can leave an organization. However, if you're the only administrator of the organization, you'll not be able to leave the organization.
Definition
DELETE https://app.rexpense.com/api/v1/organizations/:organization_id/members
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/organizations/:organization_id/members \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Example Response Success
HTTP 204 NO CONTENT
Example Response Failure
HTTP 422 Unprocessable Entity