Getting started
The Teleport Cloud API can be used to control Teleport devices and for other interaction with the Teleport Cloud. The API is organized around REST. It uses standard HTTP verbs, authentication and response codes. It accepts JSON-encoded request bodies and also returns JSON-encoded responses. To describe requests and responses, this documentation display them as Typescript interfaces.
The base URL of the Teleport API is https://api.teleport.withthegrid.com
.
Authentication
The Teleport API uses tokens to authenticate requests. You must send an Authorization header (Authorization: Bearer [token]
) with your request.
Encoding
As stated in the introduction, request and response bodies are JSON-encoded. Date-objects in JSON should be communicated as ISO 8601 strings, specifically as yyyy-mm-ddThh:mm:ss[.mmm]Z
.
Demo device
We offer Teleport demo devices. Each demo device is configured for you and set up in the Withthegrid test lab. More details about the Teleport demo devices can be found on the Demo section.
Rate limiting
We apply rate limiting to some endpoints. We follow the IETF RateLimit header fields for HTTP proposal by adding the following headers in the response to rate limited requests:
RateLimit-Limit
: the allowed quota of requests in the current time windowRateLimit-Remaining
: the remaining quota of requests in the current time windowRateLimit-Reset
: the number of seconds until the remaining quota resets to the limit
Some requests are limited by API key, others by asset. Endpoints that are rate limited will mention this and the rate limiting policy. If your remaining quota of requests is 0, your request will be rejected with a 429
status code, see Errors.
Pagination
We apply pagination to the response of some endpoints. We use the Link
header to indicate that more results are available. The value of the link header will be Link: <uri-reference>; rel="next";
, where uri-reference
is an URL encoded relative link, eg. /v1/device?offset=qy39y9
.
Endpoints that use pagination will mention this.
Errors
Errors are returned by using the 4xx (for client side) and 5xx (for server side) HTTP status codes. The response contains a JSON-encoded body: { key: string, details?: unknown }
. The key
is unique for the HTTP status code and can be used for automated client side error handling. The details
property (if present) contains debugging information that can help fixing the issue.
Specific endpoints can return specific errors, which are listed with that route. In addition, every route can return the following generic errors.