# Fetch Analytics Data Source

Start a fresh fetch of a data source now, without changing it, as Refresh does in the app. It answers 202 as soon as the fetch is queued; poll Get Analytics Data Source Result until its status is ready, and the panels that read it follow. A live source has nothing to fetch. For a source another member owns, send the id of a page shared with the creator that uses it; a view-only creator can refresh it as often as its schedule allows.

`POST https://connect.mindcloud.co/v2/analytics/data-sources/:dataSourceId/fetch`

Permissions: `analytics:page:create`.

## Parameters

### Path

- `dataSourceId` (string, required): The data source's id, from List Analytics Data Sources or a panel's dataSources.

### Headers

- `X-Company-Id` (string): Optional. The id of the organization to act in. Leave it out to act in the API key's own organization. Here a key acts in another organization only as one of its members: with "Use this key across all of your organizations" on, in an organization its creator belongs to with a role. Child organizations and MindCloud staff access do not reach this endpoint. Every response's X-Company-Id header names the organization it acted in. See [Organizations](https://mindcloud.co/docs/api/rest/introduction/organizations).

### Body

- `pageId` (string): For a source another member owns: a page shared with the key's creator that uses it, from List Analytics Pages.
  For a source another member owns: the id of a page shared with the key's creator that uses it, from List Analytics Pages.

## Example request

```bash
curl --request POST \
  --url 'https://connect.mindcloud.co/v2/analytics/data-sources/Ds3Hq9Lp2WxM/fetch' \
  --header 'Authorization: Bearer $MINDCLOUD_API_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "pageId": "Pq7Lm2Xc9RtA"
}'
```

## Response fields

- `id` (string): The data source's id.
- `status` (string): Where its data stands. live: a live source, which has no stored data; neverFetched: no fetch has run yet; noData: a fixed source with no rows yet; draft: waiting for its first fetch; queued: a fetch is waiting to start; refreshing: a fetch is running; ready: its rows are stored; empty: the last fetch returned no rows; failed: the last fetch failed (see message). A fetch that started answers queued or refreshing.
  Allowed values:
    - `live`
    - `neverFetched`
    - `noData`
    - `draft`
    - `queued`
    - `refreshing`
    - `ready`
    - `empty`
    - `failed`
