> For the complete documentation index, see [llms.txt](https://documentation.qure.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.qure.ai/api/platform-api/api-specifications/uploading-the-dicoms.md).

# Uploading the Dicoms

{% hint style="info" %}
BASE URL will be the API service hostname and each request to the Qure.ai app is expected to carry a bearer TOKEN. Qure will provide both of these.
{% endhint %}

Use the following sample script to upload Dicoms to the service.

{% code title="Python" %}

```python
import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
file_paths = ['dicom-file1.dcm', 'dicom-file2.dcm']
m = MultipartEncoder({
    file_path: (file_path, open(file_path, 'rb'), 'application/dicom')
    for file_path in file_paths
})
content_type = 'multipart/related; type=application/dicom; boundary={}'\
.format(m.boundary_value)

# Make the HTTP POST request to the service
r = requests.post(
    url=URL, data=m,
    headers={'Content-Type': content_type,
             'Authorization': 'Token {}'.format(TOKEN)})
```

{% endcode %}

## Uploading Dicoms to the Service

<mark style="color:green;">`POST`</mark> `http://BASE URL + studies`

Use the URL to make a **POST** call with the multipart encoded payload.

#### Path Parameters

| Name                                          | Type   | Description                      |
| --------------------------------------------- | ------ | -------------------------------- |
| file\_paths<mark style="color:red;">\*</mark> | String | Represents the file location.    |
| URL<mark style="color:red;">\*</mark>         | String | The URL pointing to the service. |

#### Headers

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

#### Request Body

| Name                                   | Type   | Description |
| -------------------------------------- | ------ | ----------- |
| data<mark style="color:red;">\*</mark> | String |             |

{% tabs %}
{% tab title="200: OK Successful" %}
{% code title="Json" %}

```json
{
    "message": "Success",
    "series_instance_uids": ["SERIES_INSTANCE_UID_1", "SERIES_INSTANCE_UID_2",],
    "detailed_info":[
        {
            "SeriesInstanceUID": "SERIES_INSTANCE_UID 1",
            "NumberOfSeriesRelatedInstances": "INTEGER"
        },
        {
            "SeriesInstanceUID": "SERIES_INSTANCE_UID 2",
            "NumberOfSeriesRelatedInstances": "INTEGER"
        }      

    ]
}
```

{% endcode %}
{% endtab %}

{% tab title="400: Bad Request Invalid Request" %}
{% code title="Json" %}

```json
{
    "message": "No DICOM files were uploaded!"
}
```

{% endcode %}
{% endtab %}

{% tab title="401: Unauthorized Unauthorized" %}
{% code title="Json" %}

```json
{
    "message": "Invalid token header.
        No credentials provided.",
    "next": "/accounts/login/",
    "authenticated": false
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
For large data, it is recommended to perform batch uploads. Please ensure that the payload size of each request does not exceed 100 MB.
{% endhint %}

### Response Attribute

<table><thead><tr><th width="324">Attribute</th><th width="121">Value type</th><th width="230">Description</th><th>Sample Value</th></tr></thead><tbody><tr><td><pre><code>message
</code></pre></td><td>String</td><td>It validates the post call action based on the response status code. </td><td><pre class="language-json"><code class="lang-json">"message": "Success"
</code></pre></td></tr><tr><td><pre><code>series_instance_uids
</code></pre></td><td>Integer</td><td>It is a unique identifier  given for a series of Dicom images.</td><td><pre class="language-json"><code class="lang-json">"series_instance_uids": [
    "1.2.826.0.1.3680043.8.498.83895378777916398722746509596078492186"
</code></pre></td></tr><tr><td><pre><code>detailed_info
</code></pre></td><td>String</td><td>It is an object which contains a set of Dicom images.</td><td>-</td></tr><tr><td><pre><code>NumberOfSeriesRelatedInstances
</code></pre></td><td>Integer</td><td>It is the number of series instance UID's that belong to a set of series.</td><td><pre class="language-json"><code class="lang-json">"NumberOfSeriesRelatedInstances": 50
</code></pre></td></tr><tr><td><pre><code>authenticated
</code></pre></td><td>Boolean</td><td>It validates the token validity. </td><td><pre class="language-json"><code class="lang-json">"authenticated": false
</code></pre></td></tr></tbody></table>
