Download OpenAPI specification:Download
The DutySheet API gives your access to a set of RESTful resources that you can use to retrieve data from DutySheet.
Please note that this documentation is in development and may not contain all the available references.
Any request sent to the DutySheet API must contain the Accept header with
the corresponding version you would like to access.
Currently, the only available version is v2.
application/x.ds.v2+json
Most endpoints will require you to be authenticated using a JSON Web Token.
You must provide your JSON Web Token in the Authorization header in the
following format:
Authorization: Bearer
In order to generate a JSON Web Token, you need to have an account set up on your DutySheet with the appropriate permissions and a API Password (please contact DutySheet support to generate a API password).
To generate a JSON Web Token, you need to send a POST request to /api/auth
with your DutySheet username and API password.
Your JSON Web Token will expire after a set amount of time and you will no
longer be able to access authenticated routes using the same token. You do
not need to generate another JSON Web Token, instead, you can simple refresh
your existing token using the /api/auth/refresh endpoint.
If the endpoint you are trying to request is authentication based, you must
provide the Authorization header containing your JSON Web Token.
If your JSON Web Token expires while sending a request to an authenticated endpoint, you will receive a 401 unauthorized response from the API. You must refresh your JSON Web Token before trying to re-send your request.
The response you receive from an endpoint will change depending on the status of the request.
If a request is successful, most endpoint will respond with a key named data. The data key may be an object or array of resources depending on the context of the endpoint.
{
"data": {
"id": 1,
"name": "Example"
}
}
If there is an error during your request, the contents of the response will be different.
DutySheet API uses standard HTTP status codes to indicate the success or failure of the request. The body of the response will be standard throughout the API.
{
"message": "404 Not Found",
"status_code": 404
}
Some resources with large data sets may return the results using a paging mechanism. You can control the paging mechanism by providing different query string parameters.
You can change which page a paginated endpoint responds with by malipulating
the page query parameter. You can also change how many items are in the
response by updating the limit query parameter.
Below, you can find an example of what a paginated response will look like:
{
"data": [
{id: 1}, {id: 2}, {id: 3}, {id: 4}...
]
"meta": {
"pagination": {
"total": 5664,
"count": 15,
"per_page": 15,
"current_page": 1,
"total_pages": 378,
"links": {
"previous": "https://api.dutysheet.com/api/users?page=1",
"next": "https://api.dutysheet.com/api/users?page=3"
}
}
}
}
Most resources will have additional data that can be included in the response if your request it.
The include query parameter accepts a comma separated string of resources
that you would like to include.
For example, the /users endpoint will only include limited details by
default. You can then include additional information by adding the include
query parameter to the request.
https://api.dutysheet.com/api/users?include=rank,division,borough,station
Generate a JWT token using a username and API password
| Accept | string Example: application/x.ds.v2+json |
| Content-Type | string Example: application/json |
{ "username": "{{username}}", "password": "{{api_password}}" }
{- "token": "eyJ0eXAiOiJKV1QiLAJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuZHV0eXNoAfmxvY2FsXC9hcGlcL2F1dGgiLCJpYXQiOjE1NTgwMDYwMTMsImV4cCI6MTU1ODAwODFSAF2JmIjoxNTU4MDA2MDEzLCJqdGkiOiGSAGaVh5QjhRZldiIiwic3ViIjoxLCJwcnYiOiI0ZGY0YTc90ZDgyZjM1MTNjZmI3Y2YyMzU3MmNmYjEwMThlZGRlYTgwIn0.QYeNPNrcTh5BF_0qBQWnJS23Pt4LUSJtUcgAEFmk\n",
- "type": "bearer",
- "expires_in": 3600
}Refresh an existing JWT token.
You must provide a valid JWT token in the header (see authentication) in order to refresh your token.
A token can only be refreshed once. If you refresh a token more than once, it will be permanently blacklisted.
| Accept | string Example: application/x.ds.v2+json |
{- "token": "eyJ0eXAiOiJKV1QiLAJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuZHV0eXNoAfmxvY2FsXC9hcGlcL2F1dGgiLCJpYXQiOjE1NTgwMDYwMTMsImV4cCI6MTU1ODAwODFSAF2JmIjoxNTU4MDA2MDEzLCJqdGkiOiGSAGaVh5QjhRZldiIiwic3ViIjoxLCJwcnYiOiI0ZGY0YTc90ZDgyZjM1MTNjZmI3Y2YyMzU3MmNmYjEwMThlZGRlYTgwIn0.QYeNPNrcTh5BF_0qBQWnJS23Pt4LUSJtUcgAEFmk\n",
- "type": "bearer",
- "expires_in": 3600
}All endpoints that list a user have available includes that you can use to retrieve additional information.
The following includes are available:
rank
division
borough
station
contactDetails
textFields
dropdowns
dates
certifications
emergencyContacts
supervisor
Get a paginated response of users
By default, only volunteers and users who are active, loa or non-operational will be included
| Key | Description |
|---|---|
| q | Search users by FIN, first name or last name |
| status | Filter users by status. Default: active, loa, non-operational. Comma separated string that can contain: active, loa, non-operational, suspended, resigned |
| o | Order the results. Default: d. One of: a (ascending) or d (descending) |
| s | Sort the results. One of: fin, first_name, last_name, full_name |
| include-non-vol | Include non-volunteers in the results. Default: false. One of: true or false |
| divisions | Filter users by division. Comma separated string of division ids |
| boroughs | Filter users by borough. Comma separated string of borough ids |
| stations | Filter users by station. Comma separated string of station ids |
| include | Additional data to be included with the response |
| include | string Example: include=division,borough,station,rank Available includes |
| Accept | string Example: application/x.ds.v2+json |
{- "data": [
- {
- "id": 1,
- "first_name": "Richard",
- "last_name": "Johnson",
- "display_name": "CO 999999 Richard Johnson",
- "fin": "999999",
- "photo_url": "http://api.dutysheet.local/assets/images/profile/1?t=1556139442\n",
- "status": {
- "id": 1,
- "name": "active"
}
}, - {
- "id": 1596,
- "first_name": "David",
- "last_name": "Davidson",
- "display_name": "SC 9998 David Davidson",
- "fin": "9998",
- "photo_url": "http://api.dutysheet.local/assets/images/profile/1596?t=1556139442\n",
- "status": {
- "id": 1,
- "name": "active"
}
}
], - "meta": {
- "pagination": {
- "total": 2,
- "count": 2,
- "per_page": 20,
- "current_page": 1,
- "total_pages": 1
}
}
}Get a specific users information
| id required | integer Example: 1 User id |
| Accept | string Example: application/x.ds.v2+json |
{- "data": {
- "id": 1,
- "first_name": "Richard",
- "last_name": "Johnson",
- "display_name": "CO 999999 Richard Johnson",
- "fin": "999999",
- "photo_url": "http://api.dutysheet.local/assets/images/profile/1?t=1556140436\n",
- "status": {
- "id": 1,
- "name": "active"
}
}
}Update a specific user's information.
This endpoint expects the same format in the body as you retrieve from the user GET request.
Currently, this endpoint only supports updating the following information:
| id required | integer Example: 1 User id |
| Accept | string Example: application/x.ds.v2+json |
{- "contactDetails": {
- "police_email": {
- "email": ""
}, - "police_mobile": {
- "number": "01632960075",
- "exdirectory": true
}, - "home_phone": {
- "number": "01632960788",
- "exdirectory": true
}, - "personal_mobile": {
- "number": "",
- "exdirectory": true
}, - "work_phone": {
- "number": "01632960724",
- "extension": "765",
- "exdirectory": false
}, - "personal_email": {
- "email": "personal.email@example.com",
- "exdirectory": true
}, - "work_email": {
- "email": "work.email@example.com",
- "exdirectory": false
}
}
}{- "data": {
- "id": 1,
- "first_name": "Richard",
- "last_name": "Johnson",
- "display_name": "CO 999999 Richard Johnson",
- "fin": "999999",
- "photo_url": "http://api.dutysheet.local/assets/images/profile/1?t=1556140436\n",
- "status": {
- "id": 1,
- "name": "active"
}
}
}All endpoints that list a duty have available includes that you can use to retrieve additional information.
The following includes are available:
user (and all user includes)
division
borough
station
type
role
All endpoints that list a division have available includes that you can use to retrieve additional information.
The following includes are available:
Get a collection of all divisions
| Key | Description |
|---|---|
| include | Additional data to be included with the response |
| Accept | string Example: application/x.ds.v2+json |
{- "data": [
- {
- "id": 1,
- "name": "East",
- "abbrv": "E"
}, - {
- "id": 2,
- "name": "North & South",
- "abbrv": "N"
}, - {
- "id": 3,
- "name": "West",
- "abbrv": "W"
}
]
}All endpoints that list a borough have available includes that you can use to retrieve additional information.
The following includes are available:
Get a collection of all boroughs
| Key | Description |
|---|---|
| include | Additional data to be included with the response |
| Accept | string Example: application/x.ds.v2+json |
{- "data": [
- {
- "id": 99,
- "name": "Sunhill",
- "abbrv": "SH"
}, - {
- "id": 2993,
- "name": "Reigate & Bansted",
- "abbrv": "RB"
}, - {
- "id": 2994,
- "name": "Epsom",
- "abbrv": "EP"
}, - {
- "id": 3523,
- "name": "Leatherhead",
- "abbrv": "LH"
}
]
}Get a collection of all stations
| Key | Description |
|---|---|
| include | Additional data to be included with the response |
| Accept | string Example: application/x.ds.v2+json |
{- "data": [
- {
- "id": 248,
- "name": "Team1",
- "abbrv": "T1"
}, - {
- "id": 254,
- "name": "Team2",
- "abbrv": "T2"
}, - {
- "id": 2781,
- "name": "Reigate",
- "abbrv": "RB"
}, - {
- "id": 2782,
- "name": "Banstead",
- "abbrv": "BAN"
}
]
}Get a paginated response of users with additional includes
| include | string Example: include=station,borough,division |
| Accept | string Example: application/x.ds.v2+json |
{- "data": [
- {
- "id": 1,
- "first_name": "Richard",
- "last_name": "Johnson",
- "display_name": "CO 999999 Richard Johnson",
- "fin": "999999",
- "photo_url": "http://api.dutysheet.local/assets/images/profile/1?t=1556139442\n",
- "division": {
- "id": 1,
- "name": "East",
- "abbrv": "E"
}, - "borough": {
- "id": 99,
- "name": "Sunhill",
- "abbrv": "SH"
}, - "station": {
- "id": 248,
- "name": "Team1",
- "abbrv": "T1"
}
}, - {
- "id": 1596,
- "first_name": "David",
- "last_name": "Davidson",
- "display_name": "SC 9998 David Davidson",
- "fin": "9998",
- "photo_url": "http://api.dutysheet.local/assets/images/profile/1596?t=1556139442\n",
- "division": {
- "id": 1,
- "name": "East",
- "abbrv": "E"
}, - "borough": {
- "id": 99,
- "name": "Sunhill",
- "abbrv": "SH"
}, - "station": {
- "id": 248,
- "name": "Team1",
- "abbrv": "T1"
}
}
], - "meta": {
- "pagination": {
- "total": 2,
- "count": 2,
- "per_page": 20,
- "current_page": 1,
- "total_pages": 1
}
}
}