Templates
Start a project from a ready-made setup for a common use: the endpoint, the mapping, an example file, a suggested schedule and alerts.
A template is a ready-made project for a common use, such as tracking Amazon prices. It brings the endpoint, the mapping its example file fits, a suggested schedule, the alerts to subscribe to, the fields compared between runs, the output formats and the pace. You bring the rows.
In the dashboard, choose Start from a template when you create a project: drop your file (or try the example), check the schedule and alerts, then Create or Create and launch.
List the templates
curl https://dataflow.piloterr.com/v1/templates \
-H "x-api-key: YOUR_API_KEY"{
"items": [
{
"id": "amazon-price-tracking",
"name": "Amazon price tracking",
"description": "Follow the price and stock of a list of products.",
"category": "E-commerce",
"endpoint": {
"id": "ENDPOINT_ID",
"name": "Amazon Product",
"path": "/v2/amazon/product",
"credit_cost": 1,
"billing_mode": "per_call"
},
"mapping": {
"query": { "column": "asin" },
"domain": { "value": "com" }
},
"sample_columns": ["asin"],
"sample_rows": [{ "asin": "B0BSHF7WHW" }, { "asin": "B09G9FPHY6" }],
"schedule": { "interval": "daily", "cron": null, "timezone": "UTC" },
"alert_events": ["run.failed", "run.changes_detected"],
"tracked_fields": ["price", "stock"],
"output_formats": ["csv"],
"rate_percent": 50
}
]
}Only templates whose endpoint can run are listed. GET /v1/templates/{id} returns one.
| Field | Holds |
|---|---|
endpoint | The endpoint the project calls, with its credit cost and billing mode. |
mapping | The mapping: it reads the columns in sample_columns. |
sample_columns, sample_rows | The example file: the columns your input needs, and a few rows. |
schedule | The suggested schedule, or null: runs only when you start them. |
alert_events | The events the alert channels you choose subscribe to. |
tracked_fields | The fields the comparison between runs looks at. |
output_formats, rate_percent | The project's settings. |
Get the example file
curl https://dataflow.piloterr.com/v1/templates/amazon-price-tracking/sample \
-H "x-api-key: YOUR_API_KEY" -o amazon-price-tracking.csvA CSV with the template's columns and example rows, UTF-8 with a byte order mark. Replace the rows with yours, and keep the column names.
Create a project
First upload your rows as an input, with the example file's columns:
curl https://dataflow.piloterr.com/v1/inputs \
-H "x-api-key: YOUR_API_KEY" \
-F file=@amazon-price-tracking.csvThen create the project from the template, with the input's id:
curl https://dataflow.piloterr.com/v1/templates/amazon-price-tracking/projects \
-H "x-api-key: YOUR_API_KEY" -H "content-type: application/json" \
-d '{"input": {"type": "file", "input_id": "INPUT_ID"}, "name": "Prices – US", "alert_channel_ids": ["CHANNEL_ID"]}'| Field | Default | Holds |
|---|---|---|
input | Required | The project's input: a file, a list, a URL or searches. |
name | The template's name | Up to 120 characters. |
mapping | The template's | Your own mapping, when your columns have other names. |
schedule | The template's suggestion | Another schedule, or {"interval": "manual"} for none. |
alert_channel_ids | None | Up to 20 alert channels, each once, each subscribed to the template's alert_events. The project also keeps its dashboard notifications on Problems only, unless that channel is in the list. An id that is not one of your channels is refused (422 validation_failed, with path alert_channel_ids.0…) before anything is created. |
max_cost_per_run | null | A cap on the credits of each run: see Project settings. Required when the template's endpoint is billed per result or per GB (billing_mode per_row or per_gb). |
api_key_id | null | The API key the project's calls go out with; null: the managed Dataflow key. |
The answer is the new project, 201, with template_id set to the template's id. It is checked like POST /v1/projects: the input must have the columns the mapping reads. When the project has a schedule, its first run starts on its own; otherwise start one with POST /v1/projects/{id}/runs.
Without api_key_id and max_cost_per_run, the project runs with the managed Dataflow key and no cost cap; on an endpoint billed per result or per GB, leaving max_cost_per_run out answers 422 validation_failed (path max_cost_per_run). Send an Idempotency-Key to retry the request without creating two projects. Every setting can change afterwards with PATCH /v1/projects/{id}: see Project settings.
Errors
| Status | Code | Meaning |
|---|---|---|
404 | template_not_found | No such template, or its endpoint cannot run right now. |
422 | validation_failed | With path input.input_id: upload the input first. With path alert_channel_ids.0…: no such alert channel. With path max_cost_per_run: the endpoint is billed per result or per GB and needs a cap. Otherwise a field is missing or wrong. |
422 | api_key_invalid | The api_key_id is not a usable key of your workspace. |
409 | projects_limit | The workspace already has as many projects as it may, archived ones aside (500 by default, details.max_projects, details.project_count). |
422 | mapping_invalid | The input lacks a column the mapping reads: rename your columns, or send your own mapping. |
422 | schedule_invalid | The schedule is not valid. |
Creating a project from a URL or a search input can also fail like POST /v1/projects: see Error codes.