Organizations

This section describes the API of the organization resource. Organizations represent a group of users which have expenses. Generally, organizations represent the company or corporation the group of users belong to.

Parameters

id: integer
name: string
restricted_tags: boolean
expired: boolean
members_count: integer
created_at: string
updated_at: string
members_count: integer
identifier_document: string
logo: array of object
array of styles and URL of the logo
_links: array of object
array of links of the organization

Example Organization

    {
      "id": 1,
      "name": "Organization example 1",
      "restricted_tags": false,
      "expired": false,
      "members_count": 3,
      "identifier_document": '88146658000157',
      "created_at": "2014-06-03T14:17:56Z",
      "updated_at": "2014-06-03T14:17:56Z",
      "logo": [
        {
          "style": "original",
          "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/original/logo.png",
          "expiration": "2014-06-27T20:31:43Z"
        },
        {
          "style": "medium",
          "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/medium/logo.png",
          "expiration": "2014-06-27T20:31:43Z"
        },
        {
          "style": "thumb",
          "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/thumb/logo.png",
          "expiration": "2014-06-27T20:31:43Z"
        }
        {
          "style": "tiny",
          "url": "https://rexpense-uploads.s3.amazonaws.com/organization_logo/1/tiny/logo.png",
          "expiration": "2014-06-27T20:31:43Z"
        }
      ],
      "_links": [
        {
          "rel": "self",
          "method": "GET",
          "url": "https://app.rexpense.com/api/v1/organizations/1"
        },
        {
          "rel": "update",
          "method": "PUT",
          "url": "https://app.rexpense.com/api/v1/organizations/1"
        },
        {
          "rel": "partial_update",
          "method": "PATCH",
          "url": "https://app.rexpense.com/api/v1/organizations/1"
        },
        {
          "rel": "destroy",
          "method": "DELETE",
          "url": "https://app.rexpense.com/api/v1/organizations/1"
        }
      ]
    }
    

List all organizations

Retrieve all organizations that a user is member of. It will return a JSON containing the name of the resource with an array of the objects requested. The fields of the organizations can be found in the Organization section.

Parameters

page: integer
per_page: integer

Definition

GET https://app.rexpense.com/api/v1/organizations

Example Request

$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/organizations \
      -H 'Accept: application/json' \
      -H 'Content-type: application/json'

Response Example

    {
      "organizations": [{ "id": 1, ... }]
    }
    

Show an organization

This request return the detailed representation of the organization.

Definition

GET https://app.rexpense.com/api/v1/organizations/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/organizations/:id \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json'

Response Example Success

HTTP 200 OK
      {
        "id": 1,
        ...
      }
    

Update an organization

There are two ways to update an organization: partially or fully. If you'd like to change just one or a few attributes, you have to use the HTTP method PATCH. If you use the HTTP method PUT, you'll have to pass all attributes of the organization. This behaviour is the same for all resources in the Rexpense API.

Parameters

name: string required
file: string
_destroy: boolean

To update an existing organization logo, you have to provide the parameter file. This parameter must be an URL of the logo. This URL may be achieve following the steps in Uploads section.

To remove the logo, you have to pass the _destroy parameter with value true.

Definition

PUT/PATCH https://app.rexpense.com/api/v1/organizations/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/organizations/:id \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json' \
        -d '{"name":"My Organization"}'

Response Example Success

HTTP 200 OK
    {
      "id": 1,
      ...
    }
    

Response Example Failure

HTTP 422 Unprocessable Entity
    {
      "errors": {
        "name": ["can't be blank"]
      }
    }
    

Destroy an organization

When you destroy an organization, it will destroy all expenses attached to it. So, be carefull doing do that!

Definition

DELETE https://app.rexpense.com/api/v1/organizations/:id

Example Request

$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/organizations/:id \
        -H 'Accept: application/json' \
        -H 'Content-type: application/json'
      

Response Example

HTTP 204 NO CONTENT