> For the complete documentation index, see [llms.txt](https://developer.gerosense.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.gerosense.ai/gerosense-api-proxy-reference/sending-users-data.md).

# Sending Users Data

Use `/samples` endpoint to sync users' data with our API. You will need to split data points (samples) into batches of 1000 elements in size. It's okay to send such batches in parallel.\
\
Considering that you'll be sending us numerous batches, we recommend that you create a system to track samples that have already been submitted. As an example, the simplest method to accomplish this is by sending batches in chronological order and keeping a record of the most recent synchronized batch for each device.

<mark style="color:green;">`POST`</mark> `/api/v1.1/samples`

#### Headers

| Name                                            | Type   | Description      |
| ----------------------------------------------- | ------ | ---------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer \<token>  |
| Content-Type<mark style="color:red;">\*</mark>  | String | application/json |

#### Request Body

| Name                                         | Type      | Description                                                                                                                                                                              |
| -------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data\_type<mark style="color:red;">\*</mark> | String    | <p>Samples type.<br>Either <code>steps</code> or <code>bpm</code> (for heart rate)</p>                                                                                                   |
| data<mark style="color:red;">\*</mark>       | Sample\[] | <p>An array of samples like heart rate measurements or steps. <br><br>The minimal accepted size is <code>3</code> elements. The maximum accepted size is <code>1000</code> elements.</p> |

{% tabs %}
{% tab title="200: OK Every sample has been accepted" %}

{% endtab %}

{% tab title="207: Multi-Status Samples were partially accepted (usually due to bugs with platform health APIs)" %}

{% endtab %}

{% tab title="400: Bad Request No samples were accepted" %}

{% endtab %}
{% endtabs %}

Each `Sample` in the `data` field must follow the following structure:

<table><thead><tr><th width="193">Field</th><th width="98">Type</th><th>Description</th></tr></thead><tbody><tr><td>device_name<mark style="color:red;">*</mark></td><td>String</td><td>A unique device name like <code>iPhone</code> or <code>Apple Watch</code> </td></tr><tr><td>device_version</td><td>String</td><td>The version of the device or firmware</td></tr><tr><td>start_date<mark style="color:red;">*</mark></td><td>String</td><td>Sample's start timestamp in ISO 8601 format</td></tr><tr><td>end_date</td><td>String</td><td>Sample's end timestamp in ISO 8601 format.<br>It must not be earlier than <code>start_date</code></td></tr><tr><td>unit<mark style="color:red;">*</mark></td><td>String</td><td>Sample's unit.<br>Either <code>count</code>, <code>count/min</code>, or <code>count/s</code></td></tr><tr><td>value<mark style="color:red;">*</mark></td><td>Number</td><td>Sample's value.<br>It must be bigger than <code>0</code>.<br>It must be less than or equal to <code>30000</code> when <code>unit</code> is <code>count</code>.<br>It must be less than or equal to <code>300</code> when <code>unit</code> is <code>count/min</code>.</td></tr></tbody></table>

{% code title="REQUEST (EXAMPLE)" %}

```bash
curl -X 'POST' 'https://<api-proxy-hostname>/api/v1.1/samples' \
     -H 'Authorization: Bearer <token>' \
     -H 'Content-Type: application/json' \
     -d '{
       "data_type": "steps",
       "data": [
         {
           "device_name": "iPhone",
           "device_version": "17.0.3",
           "start_date": "2023-11-01T08:04:51.000+04:00",
           "end_date": "2023-11-01T08:04:58.000+04:00",
           "value": 14,
           "unit": "count"
         },
         {
           "device_name": "iPhone",
           "device_version": "17.0.3",
           "start_date": "2023-11-01T09:47:21.000+04:00",
           "end_date": "2023-11-01T09:47:34.000+04:00",
           "value": 24,
           "unit": "count"
         },
         ...
       ]
     }'     
```

{% endcode %}

See the full example in the json-file below:

{% file src="/files/Vy9igZwQnvgdlzZa1cE7" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.gerosense.ai/gerosense-api-proxy-reference/sending-users-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
