Skip to main content
GET
/
v2
/
imports
/
templates
/
{template_id}
Get Import Template
const options = {method: 'GET', headers: {'x-api-key': '<x-api-key>'}};

fetch('https://api.dcycle.io/v2/imports/templates/{template_id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
{
  "template_id": "<string>",
  "description": {},
  "columns": {
    "key": "<string>",
    "label": "<string>",
    "type": "<string>",
    "required": true,
    "aliases": {},
    "options": {},
    "options_source": {},
    "default": "<any>",
    "validations": {}
  },
  "required_context_fields": {},
  "submit_context_fields": {},
  "submit_columns": {},
  "defaults": {}
}

Get Import Template

Retrieve the metadata for a backend import template, including its column definitions, validation rules, and required context fields. Templates define the expected structure of an import file.
Templates are static configuration — not organization-specific. Any authenticated caller can fetch any template.

Request

Headers

x-api-key
string
required
Your API key for authenticationExample: sk_live_1234567890abcdef

Path Parameters

template_id
string
required
Template identifierExamples: logistics_requests, purchases, wastes, invoices_electricity, transport_routes

Response

template_id
string
Template identifier
description
string | null
Human-readable description of the template
columns
array[object]
Column definitions for this template
required_context_fields
array[string]
Context fields that must be provided at session creation (e.g. ["facility_id"] for wastes)
submit_context_fields
array[string]
Context fields that can be provided at submit time
submit_columns
array[string]
Columns included in the submitted output
defaults
object
Global default values applied across all columns

Example

curl -X GET "https://api.dcycle.io/v2/imports/templates/logistics_requests" \
  -H "x-api-key: ${DCYCLE_API_KEY}"

Successful Response

{
  "template_id": "logistics_requests",
  "description": "Logistics transport requests",
  "columns": [
    {
      "key": "origin",
      "label": "Origin",
      "type": "string",
      "required": true,
      "aliases": ["from", "origen", "departure"],
      "options": null,
      "options_source": null,
      "default": null,
      "validations": []
    },
    {
      "key": "destination",
      "label": "Destination",
      "type": "string",
      "required": true,
      "aliases": ["to", "destino", "arrival"],
      "options": null,
      "options_source": null,
      "default": null,
      "validations": []
    },
    {
      "key": "weight",
      "label": "Weight (kg)",
      "type": "number",
      "required": true,
      "aliases": ["peso", "weight_kg"],
      "options": null,
      "options_source": null,
      "default": null,
      "validations": [{"rule": "range", "params": {"min": 0}}]
    },
    {
      "key": "vehicle_type",
      "label": "Vehicle Type",
      "type": "category",
      "required": false,
      "aliases": ["tipo_vehiculo"],
      "options": null,
      "options_source": "toc_types",
      "default": null,
      "validations": []
    }
  ],
  "required_context_fields": [],
  "submit_context_fields": [],
  "submit_columns": ["origin", "destination", "weight", "vehicle_type", "date"],
  "defaults": {}
}

Common Errors

401 Unauthorized

Cause: Missing or invalid API key
{"detail": "Invalid API key for organization", "code": "INVALID_API_KEY"}

403 Forbidden

Cause: The authenticated user is not a member of the organization
{"detail": "Logged User is not Member of Organization", "code": "LOGGED_USER_NOT_MEMBER"}

404 Not Found

Cause: Template does not exist
{
  "detail": "Template 'invalid_template' not found."
}

Create Session

Use the template_id when creating an import session

Get Options Source

Resolve dynamic option values for category columns