nightscout
Version:
Nightscout acts as a web-based CGM (Continuous Glucose Monitor) to allow multiple caregivers to remotely view a patients glucose data in realtime.
1,100 lines • 109 kB
JSON
{
"openapi": "3.0.0",
"info": {
"title": "Nightscout API",
"description": "Nightscout API v3 is a component of cgm-remote-monitor project. It aims to provide lightweight, secured and HTTP REST compliant interface for your T1D treatment data exchange.\n\nAPI v3 uses these environment variables, among other things:\n- Security switch (optional, default = `true`) <pre>API3_SECURITY_ENABLE=true</pre> You can turn the whole security mechanism off, e.g. for debugging or development purposes, but this should never be set to false in production.\n\n- Maximum limit count of documents retrieved from single query <pre>API3_MAX_LIMIT=1000</pre>\n\n- Autopruning of obsolete documents (optional, default is only `DEVICESTATUS`=60) <pre>API3_AUTOPRUNE_DEVICESTATUS=60\nAPI3_AUTOPRUNE_ENTRIES=365\nAPI3_AUTOPRUNE_TREATMENTS=120 </pre> You can specify for which collections autopruning will be activated and length of retention period in days, e.g. \"Hold 60 days of devicestatus, automatically delete older documents, hold 365 days of treatments and entries, automatically delete older documents.\"\n\n- Fallback deduplication switch (optional, default = true) <pre>API3_DEDUP_FALLBACK_ENABLED=true</pre> API3 uses the `identifier` field for document identification and mutual distinction within a single collection. There is automatic deduplication implemented matching the equal `identifier` field. E.g. `CREATE` operation for document having the same `identifier` as another one existing in the database is automatically transformed into `UPDATE` operation of the document found in the database.\nDocuments not created via API v3 usually does not have any `identifier` field, but we would like to have some form of deduplication for them, too. This fallback deduplication is turned on by having set `API3_DEDUP_FALLBACK_ENABLED` to `true`. When searching the collection in database, the document is found to be a duplicate only when either he has equal `identifier` or he has no `identifier` and meets: <pre>`devicestatus` collection: equal combination of `created_at` and `device`\n`entries` collection: equal combination of `date` and `type`\n`food` collection: equal `created_at`\n`profile` collection: equal `created_at`\n`treatments` collection: equal combination of `created_at` and `eventType` </pre>\n\n- Fallback switch for adding `created_at` field along the `date` field (optional, default = true) <pre>API3_CREATED_AT_FALLBACK_ENABLED=true</pre> Standard APIv3 document model uses only `date` field for storing a timestamp of the event recorded by the document. But there is a fallback option to fill `created_at` field as well automatically on each insert/update, just to keep all older components working.",
"contact": {
"name": "NS development discussion channel",
"url": "https://gitter.im/nightscout/public"
},
"license": {
"name": "AGPL 3",
"url": "https://www.gnu.org/licenses/agpl.txt"
},
"version": "3.0.3"
},
"servers": [
{
"url": "/api/v3"
}
],
"tags": [
{
"name": "generic",
"description": "Generic operations with each database collection (devicestatus, entries, food, profile, settings, treatments)"
},
{
"name": "other",
"description": "All other various operations"
}
],
"paths": {
"/{collection}": {
"get": {
"tags": [
"generic"
],
"summary": "SEARCH: Search documents from the collection",
"description": "General search operation through documents of one collection, matching the specified filtering criteria. You can apply:\n\n1) filtering - combining any number of filtering parameters\n\n2) ordering - using `sort` or `sort$desc` parameter\n\n3) paging - using `limit` and `skip` parameters\n\nIf successful, HTTP 200 code is returned with JSON array of matching documents as a response content (it may be empty).\n\nThis operation requires `read` permission for the API and the collection (e.g. `*:*:read`, `api:*:read`, `*:treatments:read`, `api:treatments:read`).\n\nThe only exception is the `settings` collection which requires `admin` permission (`api:settings:admin`), because the settings of each application should be isolated and kept secret. You need to know the concrete identifier to access the app's settings.",
"operationId": "SEARCH",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "filter_parameters",
"in": "query",
"description": "Any number of filtering operators.\n\nEach filtering operator has name like `<field-name>$<operator>`, e.g. `carbs$gt=2` which represents filtering rule \"The field carbs must be present and greater than 2\".\n\nYou can choose from operators:\n\n`eq`=equals, `insulin$eq=1.5`\n\n`ne`=not equals, `insulin$ne=1.5`\n\n`gt`=greater than, `carbs$gt=30`\n\n`gte`=greater than or equal, `carbs$gte=30`\n\n`lt`=less than, `carbs$lt=30`\n\n`lte`=less than or equal, `carbs$lte=30`\n\n`in`=in specified set, `type$in=sgv|mbg|cal`\n\n`nin`=not in specified set, `eventType$nin=Temp%20Basal|Temporary%20Target`\n\n`re`=regex pattern, `eventType$re=Temp.%2A`\n\nWhen filtering by field `date`, `created_at`, `srvModified` or `srvCreated`, you can choose from three input formats\n- Unix epoch in milliseconds (1525383610088)\n- Unix epoch in seconds (1525383610)\n- ISO 8601 with optional timezone ('2018-05-03T21:40:10.088Z' or '2018-05-03T23:40:10.088+02:00')\n\nThe date is always queried in a normalized form - UTC with zero offset and with the correct format (1525383610088 for `date`, '2018-05-03T21:40:10.088Z' for `created_at`).",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "sort",
"in": "query",
"description": "Field name by which the sorting of documents is performed. This parameter cannot be combined with `sort$desc` parameter.",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "sort$desc",
"in": "query",
"description": "Field name by which the descending (reverse) sorting of documents is performed. This parameter cannot be combined with `sort` parameter.",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Maximum number of documents to get in result array",
"required": false,
"style": "form",
"explode": true,
"schema": {
"minimum": 1,
"type": "integer",
"example": 100
}
},
{
"name": "skip",
"in": "query",
"description": "Number of documents to skip from collection query before loading them into result array (used for pagination)",
"required": false,
"style": "form",
"explode": true,
"schema": {
"minimum": 0,
"type": "integer",
"example": 0,
"default": 0
}
},
{
"name": "fields",
"in": "query",
"description": "A chosen set of fields to return in response. Either you can enumerate specific fields of interest or use the predefined set. Sample parameter values:\n\n_all: All fields will be returned (default value)\n\ndate,insulin: Only fields `date` and `insulin` will be returned",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string",
"default": "_all"
},
"examples": {
"all": {
"summary": "All fields will be returned (default behaviour)",
"value": "_all"
},
"customSet": {
"summary": "Only fields date and insulin will be returned",
"value": "date,insulin"
}
}
}
],
"responses": {
"200": {
"description": "Successful operation returning array of documents matching the filtering criteria",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200"
}
},
"text/csv": {
"schema": {
"$ref": "#/components/schemas/DocumentArray"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/DocumentArray"
}
}
}
},
"400": {
"description": "The request is malformed. There may be some required parameters missing or there are unrecognized parameters present.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_400"
}
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been successfully authenticated, but the security subject is not authorized for the operation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_403"
}
}
}
},
"404": {
"description": "The collection or document specified was not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_404"
}
}
}
},
"406": {
"description": "The requested content type (in `Accept` header) is not supported.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_406"
}
}
}
}
},
"security": [
{
"accessToken": []
},
{
"jwtoken": []
}
]
},
"post": {
"tags": [
"generic"
],
"summary": "CREATE: Inserts a new document into the collection",
"description": "Using this operation you can insert new documents into collection. Normally the operation ends with 201 HTTP status code, `Last-Modified` and `Location` headers specified. `identifier` is included in response body or it can be parsed from the `Location` response header.\n\nWhen the document to post is marked as a duplicate (using rules described at `API3_DEDUP_FALLBACK_ENABLED` switch), the update operation takes place instead of inserting. In this case the original document in the collection is found and it gets updated by the actual operation POST body. Finally the operation ends with 200 HTTP status code along with `Last-Modified` and correct `Location` headers. The response body then includes `isDeduplication`=`true` and `deduplicatedIdentifier` fields.\n\nThis operation provides autopruning of the collection (if autopruning is enabled).\n\nThis operation requires `create` (and/or `update` for deduplication) permission for the API and the collection (e.g. `api:treatments:create` and `api:treatments:update`)",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "JSON with new document to insert",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DocumentToPost"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "Successfully updated a duplicate document in the collection",
"headers": {
"Last-Modified": {
"$ref": "#/components/schemas/headerLastModified"
},
"Location": {
"$ref": "#/components/schemas/headerLocation"
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200_1"
}
}
}
},
"201": {
"description": "Successfully created a new document in collection",
"headers": {
"Last-Modified": {
"$ref": "#/components/schemas/headerLastModified"
},
"Location": {
"$ref": "#/components/schemas/headerLocation"
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_201"
}
}
}
},
"400": {
"description": "The request is malformed. There may be some required parameters missing or there are unrecognized parameters present.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_400"
}
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been successfully authenticated, but the security subject is not authorized for the operation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_403"
}
}
}
},
"404": {
"description": "The collection or document specified was not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_404"
}
}
}
},
"422": {
"description": "The client request is well formed but a server validation error occured. Eg. when trying to modify or delete a read-only document (having `isReadOnly=true`).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_422"
}
}
}
}
},
"security": [
{
"accessToken": []
},
{
"jwtoken": []
}
]
}
},
"/{collection}/{identifier}": {
"get": {
"tags": [
"generic"
],
"summary": "READ: Retrieves a single document from the collection",
"description": "Basically this operation looks for a document matching the `identifier` field returning 200 or 404 HTTP status code.\n\nIf the document has been found in the collection but it had already been deleted, 410 HTTP status code is to be returned.\n\nWhen `If-Modified-Since` header is used and its value is greater than the timestamp of the document in the collection, 304 HTTP status code with empty response content is returned. It means that the document has not been modified on server since the last retrieval to client side. With `If-Modified-Since` header and less or equal timestamp `srvModified` a normal 200 HTTP status with full response is returned.\n\nThis operation requires `read` permission for the API and the collection (e.g. `api:treatments:read`)",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "identifier",
"in": "path",
"description": "Identifier of the document to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramIdentifier"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "If-Modified-Since",
"in": "header",
"description": "Timestamp (defined with respect to server's clock) of the last document modification formatted as:\n\n<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT\n\nIf this header is present, the operation will compare its value with the srvModified timestamp of the document at first and the operation result then may differ. The srvModified timestamp was defined by server's clock.\n\nExample:\n\n<pre>If-Modified-Since: Wed, 17 Oct 2018 05:13:00 GMT</pre>",
"required": false,
"style": "simple",
"explode": false,
"schema": {
"type": "string"
}
},
{
"name": "fields",
"in": "query",
"description": "A chosen set of fields to return in response. Either you can enumerate specific fields of interest or use the predefined set. Sample parameter values:\n\n_all: All fields will be returned (default value)\n\ndate,insulin: Only fields `date` and `insulin` will be returned",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string",
"default": "_all"
},
"examples": {
"all": {
"summary": "All fields will be returned (default behaviour)",
"value": "_all"
},
"customSet": {
"summary": "Only fields date and insulin will be returned",
"value": "date,insulin"
}
}
}
],
"responses": {
"200": {
"description": "The document has been succesfully found and its JSON form returned in the response content.",
"headers": {
"Last-Modified": {
"$ref": "#/components/schemas/headerLastModified"
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200_2"
}
},
"text/csv": {
"schema": {
"$ref": "#/components/schemas/Document"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Document"
}
}
}
},
"304": {
"description": "The document has not been modified on the server since timestamp specified in If-Modified-Since header",
"headers": {
"Last-Modified": {
"$ref": "#/components/schemas/headerLastModified"
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been successfully authenticated, but the security subject is not authorized for the operation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_403"
}
}
}
},
"404": {
"description": "The collection or document specified was not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_404"
}
}
}
},
"406": {
"description": "The requested content type (in `Accept` header) is not supported.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_406"
}
}
}
},
"410": {
"description": "The requested document has already been deleted.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_410"
}
}
}
}
},
"security": [
{
"accessToken": []
},
{
"jwtoken": []
}
]
},
"put": {
"tags": [
"generic"
],
"summary": "UPDATE: Updates a document in the collection",
"description": "Normally the document with the matching `identifier` will be replaced in the collection by the whole JSON request body and 200 HTTP status code will be returned.\n\nIf the document has been found in the collection but it had already been deleted, 410 HTTP status code is to be returned.\n\nWhen no document with `identifier` has been found in the collection, then an insert operation takes place instead of updating. Finally 201 HTTP status code is returned with only `Last-Modified` header (`identifier` is already known from the path parameter).\n\nYou can also specify `If-Unmodified-Since` request header including your timestamp of document's last modification. If the document has been modified by somebody else on the server afterwards (and you do not know about it), the 412 HTTP status code is returned cancelling the update operation. You can use this feature to prevent race condition problems.\n\nThis operation provides autopruning of the collection (if autopruning is enabled).\n\nThis operation requires `update` (and/or `create`) permission for the API and the collection (e.g. `api:treatments:update` and `api:treatments:create`)",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "identifier",
"in": "path",
"description": "Identifier of the document to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramIdentifier"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "If-Unmodified-Since",
"in": "header",
"description": "Timestamp (defined with respect to server's clock) of the last document modification formatted as:\n\n<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT\n\nIf this header is present, the operation will compare its value with the srvModified timestamp of the document at first and the operation result then may differ. The srvModified timestamp was defined by server's clock.\n\nExample:\n\n<pre>If-Unmodified-Since: Wed, 17 Oct 2018 05:13:00 GMT</pre>",
"required": false,
"style": "simple",
"explode": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "JSON of new version of document (`identifier` in JSON is ignored if present)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DocumentToPost"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "The request was successfully processed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200_3"
}
}
}
},
"201": {
"description": "Successfully created a new document in collection",
"headers": {
"Last-Modified": {
"$ref": "#/components/schemas/headerLastModified"
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_201"
}
}
}
},
"400": {
"description": "The request is malformed. There may be some required parameters missing or there are unrecognized parameters present.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_400"
}
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been successfully authenticated, but the security subject is not authorized for the operation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_403"
}
}
}
},
"404": {
"description": "The collection or document specified was not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_404"
}
}
}
},
"410": {
"description": "The requested document has already been deleted.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_410"
}
}
}
},
"412": {
"description": "The document has already been modified on the server since specified timestamp (in If-Unmodified-Since header).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_412"
}
}
}
},
"422": {
"description": "The client request is well formed but a server validation error occured. Eg. when trying to modify or delete a read-only document (having `isReadOnly=true`).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_422"
}
}
}
}
},
"security": [
{
"accessToken": []
},
{
"jwtoken": []
}
]
},
"delete": {
"tags": [
"generic"
],
"summary": "DELETE: Deletes a document from the collection",
"description": "If the document has already been deleted, the operation will succeed anyway. Normally, documents are not really deleted from the collection but they are only marked as deleted. For special cases the deletion can be irreversible using `permanent` parameter.\n\nThis operation provides autopruning of the collection (if autopruning is enabled).\n\nThis operation requires `delete` permission for the API and the collection (e.g. `api:treatments:delete`)",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "identifier",
"in": "path",
"description": "Identifier of the document to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramIdentifier"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "permanent",
"in": "query",
"description": "If true, the deletion will be irreversible and it will not appear in `HISTORY` operation. Normally there is no reason for setting this flag.",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "boolean"
}
}
],
"responses": {
"200": {
"description": "The request was successfully processed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200_3"
}
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been successfully authenticated, but the security subject is not authorized for the operation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_403"
}
}
}
},
"404": {
"description": "The collection or document specified was not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_404"
}
}
}
},
"422": {
"description": "The client request is well formed but a server validation error occured. Eg. when trying to modify or delete a read-only document (having `isReadOnly=true`).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_422"
}
}
}
}
},
"security": [
{
"accessToken": []
},
{
"jwtoken": []
}
]
},
"patch": {
"tags": [
"generic"
],
"summary": "PATCH: Partially updates document in the collection",
"description": "Normally the document with the matching `identifier` will be retrieved from the collection and it will be patched by all specified fields from the JSON request body. Finally 200 HTTP status code will be returned.\n\nIf the document has been found in the collection but it had already been deleted, 410 HTTP status code is to be returned.\n\nWhen no document with `identifier` has been found in the collection, then the operation ends with 404 HTTP status code.\n\nYou can also specify `If-Unmodified-Since` request header including your timestamp of document's last modification. If the document has been modified by somebody else on the server afterwards (and you do not know about it), the 412 HTTP status code is returned cancelling the update operation. You can use this feature to prevent race condition problems.\n\n`PATCH` operation can save some bandwidth for incremental document updates in comparison with `GET` - `UPDATE` operation sequence.\n\nWhile patching the document, the field `modifiedBy` is automatically set to the authorized subject's name.\n\nThis operation provides autopruning of the collection (if autopruning is enabled).\n\nThis operation requires `update` permission for the API and the collection (e.g. `api:treatments:update`)",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "identifier",
"in": "path",
"description": "Identifier of the document to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramIdentifier"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "If-Unmodified-Since",
"in": "header",
"description": "Timestamp (defined with respect to server's clock) of the last document modification formatted as:\n\n<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT\n\nIf this header is present, the operation will compare its value with the srvModified timestamp of the document at first and the operation result then may differ. The srvModified timestamp was defined by server's clock.\n\nExample:\n\n<pre>If-Unmodified-Since: Wed, 17 Oct 2018 05:13:00 GMT</pre>",
"required": false,
"style": "simple",
"explode": false,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"description": "JSON of new version of document (`identifier` in JSON is ignored if present)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DocumentToPost"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "The request was successfully processed",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200_3"
}
}
}
},
"400": {
"description": "The request is malformed. There may be some required parameters missing or there are unrecognized parameters present.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_400"
}
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been successfully authenticated, but the security subject is not authorized for the operation.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_403"
}
}
}
},
"404": {
"description": "The collection or document specified was not found.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_404"
}
}
}
},
"410": {
"description": "The requested document has already been deleted.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_410"
}
}
}
},
"412": {
"description": "The document has already been modified on the server since specified timestamp (in If-Unmodified-Since header).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_412"
}
}
}
},
"422": {
"description": "The client request is well formed but a server validation error occured. Eg. when trying to modify or delete a read-only document (having `isReadOnly=true`).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_422"
}
}
}
}
},
"security": [
{
"accessToken": []
},
{
"jwtoken": []
}
]
}
},
"/{collection}/history": {
"get": {
"tags": [
"generic"
],
"summary": "HISTORY: Retrieves incremental changes since timestamp",
"description": "HISTORY operation is intended for continuous data synchronization with other systems.\nEvery insertion, update and deletion will be included in the resulting JSON array of documents (since timestamp in `Last-Modified` request header value). All changes are listed chronologically in response with 200 HTTP status code. The maximum listed `srvModified` timestamp is also stored in `Last-Modified` and `ETag` response headers that you can use for future, directly following synchronization. You can also limit the array's length using `limit` parameter.\n\nDeleted documents will appear with `isValid` = `false` field.\n\nHISTORY operation has a fallback mechanism in place for documents, which were not created by API v3. For such documents `srvModified` is virtually assigned from the `date` field (for `entries` collection) or from the `created_at` field (for other collections).\n\nThis operation requires `read` permission for the API and the collection (e.g. `api:treatments:read`)\n\nThe only exception is the `settings` collection which requires `admin` permission (`api:settings:admin`), because the settings of each application should be isolated and kept secret. You need to know the concrete identifier to access the app's settings.",
"operationId": "HISTORY",
"parameters": [
{
"name": "collection",
"in": "path",
"description": "Collection to which the operation is targeted",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"$ref": "#/components/schemas/paramCollection"
}
},
{
"name": "token",
"in": "query",
"description": "An alternative way of authorization - passing accessToken in a query parameter.\n\nExample:\n\n<pre>token=testadmin-bf2591231bd2c042</pre>",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string"
}
},
{
"name": "Last-Modified",
"in": "header",
"description": "Starting timestamp (defined with respect to server's clock) since which the changes in documents are to be listed, formatted as:\n\n<day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT\n\nExample:\n\n<pre>Last-Modified: Wed, 17 Oct 2018 05:13:00 GMT</pre>",
"required": true,
"style": "simple",
"explode": false,
"schema": {
"type": "string"
}
},
{
"name": "limit",
"in": "query",
"description": "Maximum number of documents to get in result array",
"required": false,
"style": "form",
"explode": true,
"schema": {
"minimum": 1,
"type": "integer",
"example": 100
}
},
{
"name": "fields",
"in": "query",
"description": "A chosen set of fields to return in response. Either you can enumerate specific fields of interest or use the predefined set. Sample parameter values:\n\n_all: All fields will be returned (default value)\n\ndate,insulin: Only fields `date` and `insulin` will be returned",
"required": false,
"style": "form",
"explode": true,
"schema": {
"type": "string",
"default": "_all"
},
"examples": {
"all": {
"summary": "All fields will be returned (default behaviour)",
"value": "_all"
},
"customSet": {
"summary": "Only fields date and insulin will be returned",
"value": "date,insulin"
}
}
}
],
"responses": {
"200": {
"description": "Changed documents since specified timestamp",
"headers": {
"Last-Modified": {
"$ref": "#/components/schemas/headerLastModifiedMaximum"
},
"ETag": {
"$ref": "#/components/schemas/headerEtagLastModifiedMaximum"
}
},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_200"
}
},
"text/csv": {
"schema": {
"$ref": "#/components/schemas/DocumentArray"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/DocumentArray"
}
}
}
},
"400": {
"description": "The request is malformed. There may be some required parameters missing or there are unrecognized parameters present.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_400"
}
}
}
},
"401": {
"description": "The request was not successfully authenticated using access token or JWT, so that the request cannot continue due to the security policy.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/inline_response_401"
}
}
}
},
"403": {
"description": "Insecure HTTP scheme used or the request has been