# Query data as CSV

**POST** `https://api.zoined.com/v2/query/table.csv?includeNames=false&namesOnly=false`
Retrieve tabular data in CSV format. First row contains headers (field names for dimensions and metrics), and rest of the rows contain data values.

Endpoint: POST /v2/query/table.csv
Security: bearerAuth

## Security:

  - `bearerAuth` (unknown)
    http bearer token

## Query parameters:

  - `includeNames` (boolean)
    If true also include names for dimensions, not just ids

  - `namesOnly` (boolean)
    If true only include names for dimensions, omit ids

## Request fields (application/json):

  - `context` (object)
    Context for the queries
    Example: {"locale":"en","currency":"EUR"}

  - `context.locale` (string)
    Locale for the results
    Example: en

  - `context.currency` (string)
    Currency for returned monetary values
    Example: EUR

  - `query` (object)
    Query parameters
    Example: {"grouping":["day","store"],"metrics":["sales","sales_margin"],"filters":{},"seriesType":"actual","sort":["day"],"limit":1000,"offset":0,"label":"forecast","fillTimeSeries":true}

  - `query.grouping` (array, required)
    Dimensions to group over
    Example: ["day","store"]

  - `query.metrics` (array, required)
    Metrics that should be returned
    Example: ["sales","sales_margin"]

  - `query.filters` (object)
    Example: {}

  - `query.seriesType` (string)
    Type of result series. Valid values are `actual`, `budget` and `scheduled`. Default is `actual`
    Example: actual

  - `query.sort` (array)
    Fields to use for sorting the results. `-` before the field name reverses sort order
    Example: ["day"]

  - `query.limit` (number)
    Amount of rows to return
    Example: 1000

  - `query.offset` (number)
    Starting index for returned rows
    Example: 0

  - `query.label` (string)
    Optional label used with budget series type to select which budget to fetch.
    Example: forecast

  - `query.fillTimeSeries` (boolean)
    Fill empty time gaps (days, hours etc.) in time series with either zeroes or in case of sparse metrics with previous value
    Example: true

## Response 200:

  - `200` (unknown)
    Request has been processed successfully.

## Response 200 headers:

  - `X-Zoined-Total-Items` (string)
    Example: 30

  - `X-Zoined-Limit` (string)
    Example: 1000

  - `X-Zoined-Offset` (string)
    Example: 0

## Response 400:

  - `400` (unknown)
    Invalid or malformed request.
**Headers**
- `Content-Type: application/json`

## Response 400 fields (application/json):

  - `status` (string, required)
    Status of the operation OK / Not OK
    Example: Not OK

  - `msg` (string, required)
    Message describing result of operation
    Example: Reason for error

## Response 401:

  - `401` (unknown)
    Missing or invalid authorization token in header
**Headers**
- `Content-Type: application/json`

## Response 401 fields (application/json):

  - `status` (string, required)
    Status of the operation OK / Not OK
    Example: Not OK

  - `msg` (string, required)
    Message describing result of operation
    Example: Unauthorized

## Response 500:

  - `500` (unknown)
    Internal error or exception
**Headers**
- `Content-Type: application/json`

## Response 500 fields (application/json):

  - `status` (string, required)
    Status of the operation OK / Not OK
    Example: Not OK

  - `msg` (string, required)
    Message describing result of operation
    Example: Reason for error

## Response 200 examples:

  - `response` (unknown)

## Response 400 examples:

  - `response` (unknown)

## Response 401 examples:

  - `response` (unknown)

## Response 500 examples:

  - `response` (unknown)

