Skip to main content
Endpoints Cover

Overview

Endpoints allow you to create custom API interfaces with secure, controlled access. You can define two types of endpoints:
  1. Query Endpoints - Execute SQL queries on your datasets with dynamic filters
  2. Action Endpoints - Execute serverless Python functions for custom logic
Endpoint Detail

Creating Endpoints

  1. Navigate to your Project
  2. Create a new YAML file for your endpoint (e.g., api-orders.yaml)
  3. Define your endpoint configuration
  4. Reference it in your config.yaml file
Create Endpoint Step 1
Create Endpoint Step 2

Endpoint Types

Query-Based Endpoints

Query endpoints execute SQL queries on your data with dynamic filtering using Jinja templating. Example YAML Configuration:
endpoints:
  - name: consolidated-sales-endpoint
    type: query
    config:
      filters:
        - name: country
          type: string
          optional: true
        - name: city
          type: string
          optional: true
      query: |
          SELECT *
          FROM consolidated_sales_df_299ceb
          WHERE 1 = 1
          {% if country is defined %}
          AND CustomerCountry = '{{ country }}'
          {% endif %}
          {% if city is defined %}
          AND CustomerCity = '{{ city }}'
          {% endif %}

Action-Based Endpoints

Action endpoints execute serverless Python functions when called. Perfect for sending notifications, processing data, calling external APIs, or automating workflows. Example YAML Configuration:
endpoints:
  - name: process-data-endpoint
    type: action
    config:
      action_id: "507f1f77bcf86cd799439011"
The action_id references an action function in your project. Get the ID from your action details page.

Register in config.yaml

Reference your endpoint file in config.yaml:
project_name: TestProject
project_id: 688b3d0b7c5f93f0763a028c
endpoints:
  - path: api-orders.yaml
Learn more about the configuration file in the Project Configuration section.

Configuration Reference

Common Attributes

AttributeTypeRequiredDescription
namestringYesUnique endpoint identifier
typestringYesEndpoint type: query or action
configobjectYesType-specific configuration

Query Config Attributes

AttributeTypeRequiredDescription
querystringYesSQL query with Jinja templating
filtersarrayNoList of filter parameters

Action Config Attributes

AttributeTypeRequiredDescription
action_idstringYesAction function ID to execute

Filter Configuration

Filters are only for query endpoints and define dynamic parameters:
AttributeTypeRequiredDescription
namestringYesFilter parameter name (alphanumeric, -, _)
typestringYesData type (see types below)
optionalbooleanNoWhether filter is optional (default: true)

Filter Types

TypeDescriptionExample Usage
stringText parametercountry, category
integerNumeric parameteryear, limit
floatDecimal parameterprice, rating
dateDate parameterstart_date, end_date
datetimeDateTime parametercreated_at, updated_at
booleanBoolean parameteractive, is_featured
enumEnumeration parameterstatus, priority

Using Endpoints

All endpoints are accessible via HTTP GET requests with parameters passed as query parameters:
curl -X GET \
  "https://app.datazone.co/api/v1/endpoint/your-endpoint-name?param1=value1&param2=value2" \
  -H "x-api-key: <DATAZONE_API_KEY>" \
  -H "Content-Type: application/json"

Response Format

Query Endpoint Response

Query endpoints return JSON data with query results:
{
  "records": [
    {
      "column1": "value1",
      "column2": "value2"
    }
  ],
  "metadata": {
    "total_records": 100,
    "query_time_ms": 250,
    "endpoint_name": "consolidated-sales-endpoint"
  }
}

Action Endpoint Response

Action endpoints return execution results:
{
  "status": "success",
  "execution_id": "65f3a2b8c4e1a9d0c8b4e7f3",
  "message": "Action executed successfully",
  "metadata": {
    "action_id": "507f1f77bcf86cd799439011",
    "endpoint_name": "process-data-endpoint",
    "triggered_at": "2026-01-20T10:30:00Z"
  }
}

Authentication

Endpoints use API key authentication via the x-api-key header:
-H "x-api-key: YOUR_API_KEY"

Error Responses

Status CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
403Forbidden - Access denied
404Not Found - Endpoint doesn’t exist
500Internal Server Error
Example error response:
{
  "error": "Invalid parameter 'country': must be a string",
  "code": "INVALID_PARAMETER",
  "status": 400
}

Advanced Query Features

Jinja Templating

Endpoints support Jinja templating for dynamic queries:
query: |
    SELECT *
    FROM sales_data
    WHERE 1 = 1
    {% if start_date is defined %}
    AND order_date >= '{{ start_date }}'
    {% endif %}
    {% if end_date is defined %}
    AND order_date <= '{{ end_date }}'
    {% endif %}
    {% if categories is defined %}
    AND category IN ({{ categories | join("','") | surround("'") }})
    {% endif %}

Caching

Endpoint responses can be cached:
  • Default cache TTL: 60 minutes
  • Cache headers indicate freshness
  • Use cache-busting parameters when needed