This guide provides details about the conventions followed by our REST APIs.
Our APIs are released using the semantic versioning conventions. Minor and patch releases will always be backwards compatible. Each time a major version is released, it is included in the URI /v2/orders/1234. You may continue to use the previous version of the URI, however it will be deprecated and will be removed in a future release.
/v2/orders/1234
Most RESTful APIs support JSON. Please refer to the API specific documentation for any alternative or additional content types.
The content types your client accepts should be expressed in the Accept header, for example:
Accept
Accept: application/json
415
The following table shows the status codes that are used
An error response that was caused by invalid input will be indicated by a 400 response.
400
The body of the response will contain a representation of the error details. For example:
{"message":"Unable to parse JSON"}
An error response will always include a message. In the event that the error was caused by a validation error, resulting from invalid input, the fields in error will be expressed in the following way:
{ "message": "Validation Failed", "errors": [ { "field": "companyName", "code": "missingField" }, { "field": "emailAddress", "code": "invalid", "message": "not a well-formed email address" }, { "field": "device.model", "code": "invalid", "message": "not valid polycom model" "reference": "https://developers.gamma.co.uk/docs/horizon/errors#1234" } ] }
Some more specific validation errors may include a reference which describes the input requirements in more details.
reference
Endpoints which return large volumes of data may include a paging option that allows the request to specify a subset of data that is to be returned. If an endpoint supports paging, it will be specified in the endpoint documentation. This subset is specified by the page and perPage query string parameters.
page
perPage
The following request limits the total number of records to be returned:
GET https://api.gamma.co.uk/example/list?perPage=10
The response will include the following headers:
Link: <https://api.gamma.co.uk/example/list?perPage=10&page=2>; rel="next", <https://api.gamma.co.uk/example/list?perPage=10&page=20>; rel="last" X-Pagination-Total-Pages: 10 X-Pagination-Total-Count: 100 X-Pagination-Current-Page: 2 X-Pagination-Page-Size: 10
The Link header provides URIs for the first, previous, next and last pages. Some may be omitted depending on the current page, for example the previous and first page URIs will not be included if the current page is page 1.
Link
The X-Pagination headers provide additional meta data about the total pages, total number of records, current page and page size.
X-Pagination
Endpoints which support paging will include a default number of records per page. This is specified in the individual endpoint documentation. Endpoints may also specify a maximum number of records per page. A request which includes a perPage parameter which exceeds the maximum will result in an error 400.
Some endpoints may not be able to supply the total number of records or pages. In this scenario the X-Pagination-Total-Pages and X-Pagination-Total-Count headers will be omitted in the response. The Link header will include only a URI for next if more records are available.
X-Pagination-Total-Pages
X-Pagination-Total-Count
next
Endpoints which return collections of data (for example a list of CLIs) may include a sorting option that allows items in the collection to be sorted. If an endpoint supports sorting, it will be specified in the endpoint documentation.
Sorting is applied by supplying the sort query string parameter. For example:
sort
GET https://api.gamma.co.uk/example/list?sort=name,-date
The above example will sort first by name ascending, and then by date descending. Unless the endpoint documentation describes otherwise, all fields that would be returned by the response for the endpoint are available for sorting. Endpoint documentation will list fields available for sorting if only a subset are supported. A request which includes a field in the sort parameter which is not supported will result in an error 400.
Hypermedia as the Engine of Application State is not implemented fully. Our APIs do not include links, aside from those used in paging responses as described above.
Resources, and where applicable nested resources, do however include a self URI. For example:
self
{ "id": 1234, "self": "https://api.gamma.co.uk/horizon/v1/orders/1234", "company": { "id": 1234, "self": "https://api.gamma.co.uk/horizon/v1/companies/1234", }, "cpe": [ { "model":"Polycom" } ] }
A self URI is included only if the resource, or nested resource, is individually accessible.
Some endpoints will return a great many fields in their responses. You may not need every field to be returned. Consequently, some endpoints will support field limiting, which allows a request to specify the fields that should be included in the response using the fields query string parameter.
fields
For example, a request sent to https://api.gamma.co.uk/inbound/v1/numbers/1234 could return:
https://api.gamma.co.uk/inbound/v1/numbers/1234
{ "id":1234 "cli": "+44123456789", "self": "https://api.gamma.co.uk/inbound/v1/clis/1234" "status": "active", "callPlan" : { "id":1234, "self": "https://api.gamma.co.uk/inbound/v1/clis/1234/callplan" "name": "My callplan" } }
Specifying the fields to include, for example https://api.gamma.co.uk/inbound/v1/numbers/1234?fields=cli,status will reduce the fields included in the response:
https://api.gamma.co.uk/inbound/v1/numbers/1234?fields=cli,status
{ "id":1234 "cli": "+44123456789", "self": "https://api.gamma.co.uk/inbound/v1/clis/1234" "status": "active" }
The id and self fields are always included.
id
Some endpoints will support expanding fields. Endpoints which return a large amount of nested resources will sometimes not return these resources in full, only the id and self will be returned. The endpoint documentation will describe if this is the case.
In these scenarios, a request may specify that the entire nested resource is to be expanded, so all of its fields are returned.
For example a request sent to https://api.gamma.co.uk/inbound/v1/numbers/1234 could return:
{ "id":1234 "cli": "+44123456789", "self": "https://api.gamma.co.uk/inbound/v1/clis/1234" "status": "active", "callPlan" : { "id":1234, "self": "https://api.gamma.co.uk/inbound/v1/clis/1234/callplan" } }
Specifying the fields to exapanded, for example https://api.gamma.co.uk/inbound/v1/numbers/1234?expand=callPlan will include the full set of fields from the nested resource:
https://api.gamma.co.uk/inbound/v1/numbers/1234?expand=callPlan
{ "id":1234 "cli": "+44123456789", "self": "https://api.gamma.co.uk/inbound/v1/clis/1234" "status": "active", "callPlan" : { "id":1234, "self": "https://api.gamma.co.uk/inbound/v1/clis/1234/callplan" "name": "My callplan", "lastUpdated": "2018-02-02T11:06:08Z", "destination": "+44123456789" } }