# Data API

The Tidepool API is an HTTP REST API used by Tidepool clients use to communicate with the Tidepool Platform.

For more information, see the [Getting Started](../docs/quick-start.md) section.

Version: 1.0
License: BSD-2-Clause

## Servers

integration
```
https://external.integration.tidepool.org
```

production
```
https://api.tidepool.org
```

dev1
```
https://dev1.dev.tidepool.org
```

qa1
```
https://qa1.development.tidepool.org
```

qa2
```
https://qa2.development.tidepool.org
```

## Security

### sessionToken

Tidepool Session Token

Type: apiKey
In: header
Name: X-Tidepool-Session-Token

### serverToken

Tidepool Server Token

Type: apiKey
In: header
Name: X-Tidepool-Session-Token

## Download OpenAPI description

[Data API](https://dev-docs.tidepool.org/_bundle/reference/data.v1.yaml)

## Data

Manages diabetes data in user's Tidepool account.

### Create New Data Source for User

 - [POST /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/internal/createdatasource.md): Creates a new data source for the user specified by the userId. Before creating a new data source, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete All Data Sources for User

 - [DELETE /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/internal/deletealldatasources.md): Deletes all data sources for the user specified by the userId. This does not delete the corresponding data provider sessions. See the Authentication APIs for the details on how to delete data provider sessions.

### Update Data Source

 - [PUT /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/internal/updatedatasource.md): Updates the data source specified by the dataSourceId. If you want to change the data provider session, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete Data Source

 - [DELETE /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/internal/deletedatasource.md): Deletes data source specified by the dataSourceId. This does not delete the corresponding data provider session. See the Authentication APIs for the details on how to delete data provider sessions.

### Upload Data (LEGACY) (deprecated)

 - [POST /data/{userId}](https://dev-docs.tidepool.org/reference/data.v1/internal/uploaddata.md): This is a legacy API for uploading diabetes data to user's account. It is deprecated and should not be used.

Upload data for the specified userId.
The session token must be for userId, or identify a user who has the upload permission to the account specified by the userId.

### Delete All Data for User

 - [DELETE /v1/users/{userId}/data](https://dev-docs.tidepool.org/reference/data.v1/data/deletealluserdata.md): Delete all data for user specified by the userId.

### Get Data Sets for User

 - [GET /v1/users/{userId}/datasets](https://dev-docs.tidepool.org/reference/data.v1/data/getuserdatasets.md): Gets data sets for the user account specified by the userId.

### Create New Data Set for User

 - [POST /v1/users/{userId}/datasets](https://dev-docs.tidepool.org/reference/data.v1/data/createdataset.md): Creates a new data set of type upload and data set type dataSetType for the user specified by the userId.

### List Data Sets for User

 - [GET /v1/users/{userId}/data_sets](https://dev-docs.tidepool.org/reference/data.v1/data/listdatasets.md): Returns a list of data sets for the user specified by the userId.

### Create New Data Set for User

 - [POST /v1/users/{userId}/data_sets](https://dev-docs.tidepool.org/reference/data.v1/data/createdataset2.md): Creates a new data set of type upload and data set type dataSetType for the user specified by the userId.

### Update Data Set

 - [PUT /v1/datasets/{dataSetId}](https://dev-docs.tidepool.org/reference/data.v1/data/updatedataset.md): Updates the data set specified by the dataSetId.

### Delete Data Set

 - [DELETE /v1/datasets/{dataSetId}](https://dev-docs.tidepool.org/reference/data.v1/data/deletedataset.md): Deletes the data set specified by the dataSetId.

### Get Data Set

 - [GET /v1/data_sets/{dataSetId}](https://dev-docs.tidepool.org/reference/data.v1/data/getdataset.md): Returns the data set specified by the dataSetId.

### Update Data Set

 - [PUT /v1/data_sets/{dataSetId}](https://dev-docs.tidepool.org/reference/data.v1/data/updatedataset2.md): Updates the data set specified by the dataSetId.

### Delete Data Set

 - [DELETE /v1/data_sets/{dataSetId}](https://dev-docs.tidepool.org/reference/data.v1/data/deletedataset2.md): Deletes an entire dataset specified by the dataSetId.

### Upload Data to Data Set

 - [POST /v1/datasets/{dataSetId}/data](https://dev-docs.tidepool.org/reference/data.v1/data/uploaddatatodataset.md): Uploads data to a user's data set identified by the dataSetId.

### Upload Data to Data Set

 - [POST /v1/data_sets/{dataSetId}/data](https://dev-docs.tidepool.org/reference/data.v1/data/uploaddatatodataset2.md): Uploads data to a user's data set identified by the dataSetId.

### Delete Data from Data Set

 - [DELETE /v1/data_sets/{dataSetId}/data](https://dev-docs.tidepool.org/reference/data.v1/data/deletedatasetdata.md): Deletes data from data set specified by the dataSetId.

### Upload twiist Data

 - [POST /v1/partners/twiist/data/{dataSetId}](https://dev-docs.tidepool.org/reference/data.v1/data/uploadtwiistdata.md): Uploads data to a user's data set for twiist.

### Get Data for User

 - [GET /data/{userId}](https://dev-docs.tidepool.org/reference/data.v1/data/getdata.md): Get data for the specified userId. You can filter the data to pull with several query parameters.

### List Data Sources for User

 - [GET /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/data/listdatasources.md): Returns a list of data sources for the user specified by the userId.

### Create New Data Source for User

 - [POST /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/data/createdatasource.md): Creates a new data source for the user specified by the userId. Before creating a new data source, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete All Data Sources for User

 - [DELETE /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/data/deletealldatasources.md): Deletes all data sources for the user specified by the userId. This does not delete the corresponding data provider sessions. See the Authentication APIs for the details on how to delete data provider sessions.

### Get Data Source

 - [GET /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/data/getdatasource.md): Returns the data source specified by the dataSourceId.

### Update Data Source

 - [PUT /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/data/updatedatasource.md): Updates the data source specified by the dataSourceId. If you want to change the data provider session, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete Data Source

 - [DELETE /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/data/deletedatasource.md): Deletes data source specified by the dataSourceId. This does not delete the corresponding data provider session. See the Authentication APIs for the details on how to delete data provider sessions.

### Upload Data (LEGACY) (deprecated)

 - [POST /data/{userId}](https://dev-docs.tidepool.org/reference/data.v1/data/uploaddata.md): This is a legacy API for uploading diabetes data to user's account. It is deprecated and should not be used.

Upload data for the specified userId.
The session token must be for userId, or identify a user who has the upload permission to the account specified by the userId.

## Internal

APIs intended for internal use by Tidepool.

### Create New Data Source for User

 - [POST /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/internal/createdatasource.md): Creates a new data source for the user specified by the userId. Before creating a new data source, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete All Data Sources for User

 - [DELETE /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/internal/deletealldatasources.md): Deletes all data sources for the user specified by the userId. This does not delete the corresponding data provider sessions. See the Authentication APIs for the details on how to delete data provider sessions.

### Update Data Source

 - [PUT /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/internal/updatedatasource.md): Updates the data source specified by the dataSourceId. If you want to change the data provider session, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete Data Source

 - [DELETE /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/internal/deletedatasource.md): Deletes data source specified by the dataSourceId. This does not delete the corresponding data provider session. See the Authentication APIs for the details on how to delete data provider sessions.

### Upload Data (LEGACY) (deprecated)

 - [POST /data/{userId}](https://dev-docs.tidepool.org/reference/data.v1/internal/uploaddata.md): This is a legacy API for uploading diabetes data to user's account. It is deprecated and should not be used.

Upload data for the specified userId.
The session token must be for userId, or identify a user who has the upload permission to the account specified by the userId.

### Create New Data Source for User

 - [POST /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/data/createdatasource.md): Creates a new data source for the user specified by the userId. Before creating a new data source, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete All Data Sources for User

 - [DELETE /v1/users/{userId}/data_sources](https://dev-docs.tidepool.org/reference/data.v1/data/deletealldatasources.md): Deletes all data sources for the user specified by the userId. This does not delete the corresponding data provider sessions. See the Authentication APIs for the details on how to delete data provider sessions.

### Update Data Source

 - [PUT /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/data/updatedatasource.md): Updates the data source specified by the dataSourceId. If you want to change the data provider session, you must first create the data provider session. See the Authentication APIs for the details on how to create data provider sessions.

### Delete Data Source

 - [DELETE /v1/data_sources/{dataSourceId}](https://dev-docs.tidepool.org/reference/data.v1/data/deletedatasource.md): Deletes data source specified by the dataSourceId. This does not delete the corresponding data provider session. See the Authentication APIs for the details on how to delete data provider sessions.

### Upload Data (LEGACY) (deprecated)

 - [POST /data/{userId}](https://dev-docs.tidepool.org/reference/data.v1/data/uploaddata.md): This is a legacy API for uploading diabetes data to user's account. It is deprecated and should not be used.

Upload data for the specified userId.
The session token must be for userId, or identify a user who has the upload permission to the account specified by the userId.

