# Export Team Overview

## cURL

Use the following `cURL` command to create a project. You can copy and paste the following template and replace the **access\_token**, **teamId**, and **method**.

```
curl --location --request POST 'https://datasaur.ai/graphql' \
--header 'Authorization: Bearer access_token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "query": "query ExportTeamOverview($input: ExportTeamOverviewInput!) { exportTeamOverview(input:$input) { exportId fileUrl } }",
    "variables": {
        "input": {
	    "teamId": "121",
	    "method": "FILE_STORAGE"
        }
    }
}'
```

* **variables**
  * **input**
    * **teamId**
    * **method:** define how the export result will be delivered. The most used methods are:
      * `EMAIL`
      * `FILE_STORAGE`

## Response

### `EMAIL`

If the `method` is set as email, the export result will be sent to `access_token` owner's email. Below is a sample response:

```
{
   "data":{
      "exportTeamOverview":{
         "exportId":"ExportQueue:2d1cfa43-c612-45c7-8f91-fbca03932eb9",
         "fileUrl":null
      }
   },
   "extensions":{}
}
```

### `FILE_STORAGE`

If the `method` is set as `FILE_STORAGE`, the export result will be uploaded to Datasaur's temporary Amazon S3 bucket and the file URL is returned. Below is a sample response:

```
{
   "data":{
      "exportTeamOverview":{
         "exportId":"ExportQueue:09df73b8-c38a-4238-a2d7-bde51dc9d293",
         "fileUrl":"https://vulcan-prod-private.s3.amazonaws.com/export/team-overview/121/1643090963803/Team%20Overview%20-%20Team%20Alvin.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZ5X7NDLAVQ4BD4EC%2F20220125%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220125T060923Z&X-Amz-Expires=21600&X-Amz-Signature=315b6f89304f57ff47afdf388be5449f592b5be635d6d86e39a126a3ca6d3631&X-Amz-SignedHeaders=host"
      }
   },
   "extensions":{}
}
```

The client can download the file from the URL defined in `fileUrl`.

Note: `fileUrl` is returned optimistically, i.e., the export result might not have been completely uploaded to the Amazon S3 bucket yet, so there might be a case where the file is not ready to be downloaded yet. To mitigate this issue, the client should poll the result using [range request](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests) and only start downloading the result once the range request HTTP response code is 206.
