Tags
This section describes the API of the tags resource.
Parameters
id: | integer |
name: | string |
Example of Tag
{
"id": 1,
"name": "Restaurant",
"created_at": "2014-06-03T14:17:56Z",
"updated_at": "2014-06-03T14:17:56Z",
"_links": [
{
"rel": "self",
"method": "GET",
"href": "https://app.rexpense.com/api/v1/organizations/1/tags"
},
{
"rel": "update",
"method": "PUT",
"href": "https://app.rexpense.com/api/v1/organizations/1/tags"
},
{
"rel": "destroy",
"method": "DELETE",
"href": "https://app.rexpense.com/api/v1/organizations/1/tags"
}
]
}
List tags
Retrieve all tags from a specific organization.
Parameters
page: | integer |
per_page: | integer limit to 100 |
Definition
GET https://app.rexpense.com/api/v1/organizations/:id/tags
Example Request
$ curl -u $YOUR_API_TOKEN:X -X GET https://app.rexpense.com/api/v1/organizations/1/tags \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
{
"count": 1,
"current_page": 1,
"total_pages": 1,
"tags": [{ "id": 1, ... }]
}
Show a tag
This request shows the tag complete information.
To visualize a tag you have to be an Organization's Administrator or Manager.
Parameters
id: | integer required |
Definition
GET https://app.rexpense.com/api/v1/organizations/:organization_id/tags/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/organizations/1/tags/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example Success
HTTP 200 OK
{
"id": 1,
...
}
Response Example Failure
HTTP 404 Record Not Found
{
"errors": {
"message": "Record Not Found"
}
}
Create a tag
This request creates a new tag.
To create a tag you have to be an Organization's Administrator or Manager.
It is possible to restrict the tag to a group of users in the organization through the restricted_user_ids
parameter. It means only users in restricted_user_ids
will be able to use the tag.
Parameters
name: | string |
restricted_user_ids: | array of user IDs optional |
Definition
POST https://app.rexpense.com/api/v1/organization/:organization_id/tags
Example Request
$ curl -u $YOUR_API_TOKEN:X -X POST https://app.rexpense.com/api/v1/organization/1/tags \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"name":"Restaurant","restricted_user_ids":[1900,1945]}'
Response Example Success
HTTP 201 CREATED
{
"id": 1,
"name": "Restaurant",
"restricted_user_ids": [1900, 1945]
}
Response Example Failure
HTTP 422 Unprocessable Entity
{
"errors": {
"name": ["can't be blank"]
}
}
Update a tag
This request updates a new tag.
To update a tag you have to be an Organization's Administrator or Manager.
Parameters
name: | string |
restricted_user_ids: | array of user IDs optional |
Definition
PUT https://app.rexpense.com/api/v1/organizations/:organization_id/tags
Example Request
$ curl -u $YOUR_API_TOKEN:X -X PATCH https://app.rexpense.com/api/v1/organizations/1/tags/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json' \ -d '{"name":"Restaurant"}'
Response Example Success
HTTP 200 OK
{
"id": 1,
...
}
Response Example Failure
HTTP 422 Unprocessable Entity
{
"errors": {
"name": ["can't be blank"]
}
}
Destroy a tag
To destroy a tag you have to be an Organization's Administrator or Manager.
Definition
DELETE https://app.rexpense.com/api/v1/organizations/:organization_id/tags/:id
Example Request
$ curl -u $YOUR_API_TOKEN:X -X DELETE https://app.rexpense.com/api/v1/organizations/1/tags/1 \ -H 'Accept: application/json' \ -H 'Content-type: application/json'
Response Example
HTTP 204 NO CONTENT