mirror of
https://github.com/n8n-io/n8n-docs.git
synced 2026-03-27 01:18:41 +07:00
docs(Custom Templates): Add info about /workflows/templates/{id} endpoint (#4245)
This commit is contained in:
@@ -6,14 +6,24 @@ Your API must provide the same endpoints and data structure as n8n's.
|
||||
|
||||
The endpoints are:
|
||||
|
||||
| Method | Path |
|
||||
| ------ | ---- |
|
||||
| GET | /templates/workflows/`<id>` |
|
||||
| GET | /templates/search |
|
||||
| GET | /templates/collections/`<id>` |
|
||||
| GET | /templates/collections |
|
||||
| GET | /templates/categories |
|
||||
| GET | /health |
|
||||
| Method | Path | Purpose |
|
||||
| ------ | ---- | ------- |
|
||||
| GET | `/templates/workflows/<id>` | Fetch template metadata for preview/browsing |
|
||||
| GET | `/workflows/templates/<id>` | Fetch workflow data to import onto canvas |
|
||||
| GET | `/templates/search` | Search for workflow templates |
|
||||
| GET | `/templates/collections/<id>` | Get a specific template collection |
|
||||
| GET | `/templates/collections` | List all template collections |
|
||||
| GET | `/templates/categories` | List all template categories |
|
||||
| GET | `/health` | Health check endpoint |
|
||||
|
||||
/// warning | Critical: Two different response formats required
|
||||
The two workflow endpoints require **different response formats**:
|
||||
|
||||
- **`/templates/workflows/{id}`**: Returns the template itself, which includes the workflow in the `workflow` key
|
||||
- **`/workflows/templates/{id}`**: Returns the workflow the template contains
|
||||
|
||||
See Schemas below for details.
|
||||
///
|
||||
|
||||
### Query parameters
|
||||
|
||||
@@ -33,11 +43,43 @@ The `/templates/collections` endpoint accepts the following query parameters:
|
||||
| `category` | comma-separated list of strings (categories) | The categories to search within |
|
||||
| `search` | string | The search query |
|
||||
|
||||
### Data schema
|
||||
### Schemas
|
||||
|
||||
You can explore the data structure of the items in the response object returned by endpoints here:
|
||||
The key difference between the two workflow endpoints:
|
||||
|
||||
```json
|
||||
// GET /templates/workflows/{id} returns (wrapped):
|
||||
{
|
||||
"workflow": {
|
||||
"id": 123,
|
||||
"name": "...",
|
||||
"totalViews": 1000,
|
||||
// ... see full workflow item schema below
|
||||
"workflow": { // actual workflow definition
|
||||
"nodes": [...],
|
||||
"connections": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GET /workflows/templates/{id} returns (flat):
|
||||
{
|
||||
"id": 123,
|
||||
"name": "...",
|
||||
"workflow": { // actual workflow definition
|
||||
"nodes": [...],
|
||||
"connections": {}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Detailed schemas for response objects:
|
||||
|
||||
??? note "Show `workflow` item data schema"
|
||||
Used by `/templates/workflows/{id}` endpoint (wrapped in a `workflow` key).
|
||||
|
||||
This schema describes the template metadata used for displaying templates in search/browse UI. It includes a nested `workflow` property that contains the actual importable workflow definition.
|
||||
|
||||
```json title="Workflow item data schema"
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
@@ -232,18 +274,79 @@ You can explore the data structure of the items in the response object returned
|
||||
"typeVersion"
|
||||
]
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"image": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number"
|
||||
},
|
||||
"url": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"categories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "number"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"workflowInfo": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodeCount": {
|
||||
"type": "number"
|
||||
},
|
||||
"nodeTypes": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"workflow": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"nodes": {
|
||||
"type": "array"
|
||||
},
|
||||
"connections": {
|
||||
"type": "object"
|
||||
},
|
||||
"settings": {
|
||||
"type": "object"
|
||||
},
|
||||
"pinData": {
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"nodes",
|
||||
"connections"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"name",
|
||||
"totalViews",
|
||||
"price",
|
||||
"purchaseUrl",
|
||||
"recentViews",
|
||||
"createdAt",
|
||||
"user",
|
||||
"nodes"
|
||||
"nodes",
|
||||
"workflow"
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -320,10 +423,10 @@ You can explore the data structure of the items in the response object returned
|
||||
|
||||
You can also interactively explore n8n's API endpoints:
|
||||
|
||||
[https://api.n8n.io/templates/categories](https://api.n8n.io/templates/categories)
|
||||
[https://api.n8n.io/templates/collections](https://api.n8n.io/templates/collections)
|
||||
[https://api.n8n.io/templates/search](https://api.n8n.io/templates/search)
|
||||
[https://api.n8n.io/health](https://api.n8n.io/health)
|
||||
[https://api.n8n.io/templates/categories](https://api.n8n.io/templates/categories)
|
||||
[https://api.n8n.io/templates/collections](https://api.n8n.io/templates/collections)
|
||||
[https://api.n8n.io/templates/search](https://api.n8n.io/templates/search)
|
||||
[https://api.n8n.io/health](https://api.n8n.io/health)
|
||||
|
||||
|
||||
You can [contact us](mailto:help@n8n.io) for more support.
|
||||
|
||||
Reference in New Issue
Block a user