> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peaka.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Parametric Table

> Creates a new Parametric Table under the specified catalog. A Parametric Table binds specific query parameter values to a source table from a REST catalog, producing a new named table (e.g., `xyz_customers`) that can be queried directly without supplying those parameters at query time. For example, if the source table `customers` requires a `_q_account` parameter, you can create a Parametric Table that fixes this value and exposes the result as a standalone table.

Date and timestamp parameters also accept **relative-date macros**, re-evaluated on every query, so a table saved as "this week's sales" always returns the current week. Grammar: `@<anchor>[(+|-)<n><unit>]`

- Anchors: `@today`, `@yesterday`, `@now` (current instant), `@sow` / `@eow` (week, Monday start), `@som` / `@eom` (month), `@soq` / `@eoq` (quarter), `@soy` / `@eoy` (year)
- Units: `d` day, `w` week, `M` month, `q` quarter, `y` year, `h` hour, `m` minute (lowercase `m` is minute, uppercase `M` is month)
- Offsets can be chained: `@today-7d`, `@som-1M`, `@now-24h`
- Whitelisted Trino date expressions (e.g. `date_trunc('month', current_date)`) are accepted as well

<span style={{display: "flex", gap: "10px", flexDirection: "row", alignItems: "center"}}>
  <img src="https://cdn.peaka.com/badges/partner-api-key-badge.png" />

  <img src="https://cdn.peaka.com/badges/project-api-key-badge.png" />
</span>


## OpenAPI

````yaml post /data/projects/{projectId}/catalogs/{catalogId}/parametricTables
openapi: 3.0.1
info:
  title: Peaka Gateway API
  description: Peaka Gateway API Documentation
  version: '1.0'
servers:
  - url: https://partner.peaka.studio/api/v1
    description: Default Server URL (US Zone)
  - url: https://partner.eu.peaka.studio/api/v1
    description: EU Zone
security:
  - bearerAuth: []
paths:
  /data/projects/{projectId}/catalogs/{catalogId}/parametricTables:
    post:
      tags:
        - Data -- Parametric Tables
      summary: Create Parametric Table
      description: >-
        Creates a new Parametric Table under the specified catalog. A Parametric
        Table binds specific query parameter values to a source table from a
        REST catalog, producing a new named table (e.g., `xyz_customers`) that
        can be queried directly without supplying those parameters at query
        time. For example, if the source table `customers` requires a
        `_q_account` parameter, you can create a Parametric Table that fixes
        this value and exposes the result as a standalone table.


        Date and timestamp parameters also accept **relative-date macros**,
        re-evaluated on every query, so a table saved as "this week's sales"
        always returns the current week. Grammar: `@<anchor>[(+|-)<n><unit>]`


        - Anchors: `@today`, `@yesterday`, `@now` (current instant), `@sow` /
        `@eow` (week, Monday start), `@som` / `@eom` (month), `@soq` / `@eoq`
        (quarter), `@soy` / `@eoy` (year)

        - Units: `d` day, `w` week, `M` month, `q` quarter, `y` year, `h` hour,
        `m` minute (lowercase `m` is minute, uppercase `M` is month)

        - Offsets can be chained: `@today-7d`, `@som-1M`, `@now-24h`

        - Whitelisted Trino date expressions (e.g. `date_trunc('month',
        current_date)`) are accepted as well
      operationId: createParametricTable
      parameters:
        - name: projectId
          in: path
          description: ID of the project
          required: true
          schema:
            type: string
          example: mtKDhe1U
        - name: catalogId
          in: path
          description: ID of the catalog
          required: true
          schema:
            type: string
          example: 846085284821991600
      requestBody:
        description: Parametric Table definition
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ParametricTable'
            examples:
              Create Parametric Table Example:
                description: Create Parametric Table Example
                value:
                  fromSchema: public
                  fromTable: customers
                  toSchema: public
                  toTable: xyz_customers
                  paramValues:
                    - key: _q_account
                      value: acme-corp
              Dynamic Date Range (relative-date macros):
                description: >-
                  Date parameters bound to macros are recomputed on every run:
                  this table always returns the current week (Monday through
                  now). Other examples: last 7 days = @today-7d .. @today, last
                  month = @som-1M .. @eom-1M.
                value:
                  fromSchema: integrations
                  fromTable: sales_report
                  toSchema: integrations
                  toTable: this_weeks_sales
                  paramValues:
                    - key: _q_from
                      value: '@sow'
                    - key: _q_to
                      value: '@today'
        required: true
      responses:
        '200':
          description: Parametric table created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ParametricTable'
              examples:
                Created Table:
                  description: Created Table
                  value:
                    fromSchema: public
                    fromTable: products
                    toSchema: analytics
                    toTable: param_products
                    paramValues:
                      - key: country
                        value: US
                      - key: year
                        value: 2024
        '400':
          description: Target table already exists
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/ParametricTable'
components:
  schemas:
    ParametricTable:
      type: object
      properties:
        fromSchema:
          type: string
          description: Schema of the base table
        fromTable:
          type: string
          description: Name of the base table
        toSchema:
          type: string
          description: Schema of the target table
        toTable:
          type: string
          description: Name of the target table
        paramValues:
          type: array
          description: List of parametric columns
          items:
            $ref: '#/components/schemas/ParametricTableColumn'
    ParametricTableColumn:
      type: object
      properties:
        key:
          type: string
          description: Column name
        value:
          type: object
          description: Column value
      description: Parametric table column
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Use the Authorization header with the value 'Bearer <apiKey>' to
        authenticate. Partner API Keys have full access; Project API Keys are
        limited to their project scope. Learn more:
        https://docs.peaka.com/api-reference/authentication
      scheme: bearer
      bearerFormat: Api Key

````