DutySheet API

Download OpenAPI specification:Download

Overview

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.

API URL

The base URL to access this API is:

https://api.dutysheet.com/api/

Version

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

Authentication

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

How to generate a JSON Web Token

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.

Common practices

Here you can find common practices that can be found throughout the DutySheet API.

Requests

If the endpoint you are trying to request is authentication based, you must provide the Authorization header containing your JSON Web Token.

Responses

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.

Errors

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
}

Pagination

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"
            }
        }
    }
}

Includes

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

Authentication

Create a JWT token

Generate a JWT token using a username and API password

Authorizations:
noauthAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json
Content-Type
string
Example: application/json
Request Body schema: */*
object

Responses

Request samples

Content type
*/*
{
  "username": "{{username}}",
  "password": "{{api_password}}"
}

Response samples

Content type
application/json
{
  • "token": "eyJ0eXAiOiJKV1QiLAJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuZHV0eXNoAfmxvY2FsXC9hcGlcL2F1dGgiLCJpYXQiOjE1NTgwMDYwMTMsImV4cCI6MTU1ODAwODFSAF2JmIjoxNTU4MDA2MDEzLCJqdGkiOiGSAGaVh5QjhRZldiIiwic3ViIjoxLCJwcnYiOiI0ZGY0YTc90ZDgyZjM1MTNjZmI3Y2YyMzU3MmNmYjEwMThlZGRlYTgwIn0.QYeNPNrcTh5BF_0qBQWnJS23Pt4LUSJtUcgAEFmk\n",
  • "type": "bearer",
  • "expires_in": 3600
}

Refresh a JWT token

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.

Authorizations:
bearerAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "token": "eyJ0eXAiOiJKV1QiLAJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkuZHV0eXNoAfmxvY2FsXC9hcGlcL2F1dGgiLCJpYXQiOjE1NTgwMDYwMTMsImV4cCI6MTU1ODAwODFSAF2JmIjoxNTU4MDA2MDEzLCJqdGkiOiGSAGaVh5QjhRZldiIiwic3ViIjoxLCJwcnYiOiI0ZGY0YTc90ZDgyZjM1MTNjZmI3Y2YyMzU3MmNmYjEwMThlZGRlYTgwIn0.QYeNPNrcTh5BF_0qBQWnJS23Pt4LUSJtUcgAEFmk\n",
  • "type": "bearer",
  • "expires_in": 3600
}

Ping

Ping the API to verify authentication

Authorizations:
bearerAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "message": "Success",
  • "status_code": 200
}

Users

Endpoints relating to listing, viewing and updating user details.

Includes

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 all users

Get a paginated response of users

By default, only volunteers and users who are active, loa or non-operational will be included

Query params

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
Authorizations:
bearerAuth
query Parameters
include
string
Example: include=division,borough,station,rank

Available includes

header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

Get a specific user

Get a specific users information

Authorizations:
bearerAuth
path Parameters
id
required
integer
Example: 1

User id

header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "data": {
    }
}

Update a specific user

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:

  • contactDetails
Authorizations:
bearerAuth
path Parameters
id
required
integer
Example: 1

User id

header Parameters
Accept
string
Example: application/x.ds.v2+json
Request Body schema: application/json
object

Responses

Request samples

Content type
application/json
{
  • "contactDetails": {
    }
}

Response samples

Content type
application/json
{
  • "data": {
    }
}

Duties

Endpoints relating to listing, viewing and updating duties.

Includes

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

Force

Force > Divisions

Endpoints relating to listing divisions

Includes

All endpoints that list a division have available includes that you can use to retrieve additional information.

The following includes are available:

  • boroughs

Get all divisions

Get a collection of all divisions

Query params

Key Description
include Additional data to be included with the response
Authorizations:
bearerAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}

Force > Boroughs

Endpoints relating to listing boroughs

Includes

All endpoints that list a borough have available includes that you can use to retrieve additional information.

The following includes are available:

  • stations

Get all boroughs

Get a collection of all boroughs

Query params

Key Description
include Additional data to be included with the response
Authorizations:
bearerAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}

Force > Stations

Endpoints relating to listing stations

Get all stations

Get a collection of all stations

Query params

Key Description
include Additional data to be included with the response
Authorizations:
bearerAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "data": [
    ]
}

Announcements

Get all announcements

Get a paginated response of announcements

Query params

Key Description
include Additional data to be included with the response
Authorizations:
bearerAuth
query Parameters
include
string
Example: include=user
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Get a specific announcement

Get a specific announcement by its id

Query params

Key Description
include Additional data to be included with the response
Authorizations:
bearerAuth
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Announcements > Attachments

Stream an annoucement attachment

Authorizations:
bearerAuth
path Parameters
id
required
string
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Examples

Users with addtional includes

Get a paginated response of users with additional includes

Authorizations:
bearerAuth
query Parameters
include
string
Example: include=station,borough,division
header Parameters
Accept
string
Example: application/x.ds.v2+json

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}