TypeScript SDK
import { createClient } from "@toloka-platform/sdk";
const client = createClient({
baseUrl: "https://platform.toloka.ai",
apiKey: process.env.TOLOKA_API_KEY!,
});
const snapshot = await client.pipelines.getGraph({ pipelineId: "pl.019a0000-0000-7000-8000-000000000001" });
const pipeline = await client.pipelines.import({
projectId: "pp.019a0000-0000-7000-8000-000000000001",
name: "Imported pipeline",
graph: snapshot.graph
});
console.log(pipeline);curl --request POST \
--url https://platform.toloka.ai/api/v2-beta/projects/{projectId}/pipelines/import \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"graph": {
"connections": [
{
"from": {
"handle": "<string>",
"node": "<string>"
},
"settings": {},
"to": {
"handle": "<string>",
"node": "<string>"
}
}
],
"fields": [
{
"id": "<string>",
"jsonSchema": {
"additionalProperties": true,
"allOf": [
"<unknown>"
],
"anyOf": [
"<unknown>"
],
"const": "<string>",
"default": "<string>",
"description": "<string>",
"enum": [
"<string>"
],
"examples": [
"<string>"
],
"exclusiveMaximum": 123,
"exclusiveMinimum": 123,
"format": "<string>",
"items": "<unknown>",
"maxItems": 4503599627370495,
"maxLength": 4503599627370495,
"maximum": 123,
"minItems": 4503599627370495,
"minLength": 4503599627370495,
"minimum": 123,
"oneOf": [
"<unknown>"
],
"pattern": "<string>",
"properties": {},
"required": [
"<string>"
],
"title": "<string>",
"uniqueItems": true
},
"name": "<string>"
}
],
"nodes": [
{
"id": "<string>",
"settings": {
"completedFieldProxies": {
"input": [
{
"id": "<string>",
"optional": true
}
]
},
"startedFieldProxies": {
"output": [
{
"id": "<string>",
"optional": true
}
]
},
"datasetId": "<string>",
"itemFilter": {
"createdBefore": "2023-11-07T05:31:56Z",
"excludeParts": [
{
"fieldId": "<string>",
"names": [
"<string>"
]
}
],
"fieldSources": [
{
"fieldId": "<string>",
"sources": [
{
"type": "user",
"userId": "<string>"
}
]
}
],
"fieldValues": [
{
"fieldId": "<string>",
"jsonPath": "<string>",
"value": "<string>",
"latestOnly": true,
"sources": []
}
],
"missingRevisionFields": [
"<string>"
]
},
"itemLimit": 123
},
"type": "root"
}
],
"version": 1,
"layout": {}
},
"name": "<string>"
}
'import requests
url = "https://platform.toloka.ai/api/v2-beta/projects/{projectId}/pipelines/import"
payload = {
"graph": {
"connections": [
{
"from": {
"handle": "<string>",
"node": "<string>"
},
"settings": {},
"to": {
"handle": "<string>",
"node": "<string>"
}
}
],
"fields": [
{
"id": "<string>",
"jsonSchema": {
"additionalProperties": True,
"allOf": ["<unknown>"],
"anyOf": ["<unknown>"],
"const": "<string>",
"default": "<string>",
"description": "<string>",
"enum": ["<string>"],
"examples": ["<string>"],
"exclusiveMaximum": 123,
"exclusiveMinimum": 123,
"format": "<string>",
"items": "<unknown>",
"maxItems": 4503599627370495,
"maxLength": 4503599627370495,
"maximum": 123,
"minItems": 4503599627370495,
"minLength": 4503599627370495,
"minimum": 123,
"oneOf": ["<unknown>"],
"pattern": "<string>",
"properties": {},
"required": ["<string>"],
"title": "<string>",
"uniqueItems": True
},
"name": "<string>"
}
],
"nodes": [
{
"id": "<string>",
"settings": {
"completedFieldProxies": { "input": [
{
"id": "<string>",
"optional": True
}
] },
"startedFieldProxies": { "output": [
{
"id": "<string>",
"optional": True
}
] },
"datasetId": "<string>",
"itemFilter": {
"createdBefore": "2023-11-07T05:31:56Z",
"excludeParts": [
{
"fieldId": "<string>",
"names": ["<string>"]
}
],
"fieldSources": [
{
"fieldId": "<string>",
"sources": [
{
"type": "user",
"userId": "<string>"
}
]
}
],
"fieldValues": [
{
"fieldId": "<string>",
"jsonPath": "<string>",
"value": "<string>",
"latestOnly": True,
"sources": []
}
],
"missingRevisionFields": ["<string>"]
},
"itemLimit": 123
},
"type": "root"
}
],
"version": 1,
"layout": {}
},
"name": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"createdAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"projectId": "<string>",
"updatedAt": "2023-11-07T05:31:56Z",
"version": 123
}Pipelines
Import a pipeline into a project
Send an exported pipeline document containing name and graph, up to 2 MiB. Returns the new pipeline. Returns 400 for an invalid graph or a reference to a secret missing from the project.
POST
/
projects
/
{projectId}
/
pipelines
/
import
TypeScript SDK
import { createClient } from "@toloka-platform/sdk";
const client = createClient({
baseUrl: "https://platform.toloka.ai",
apiKey: process.env.TOLOKA_API_KEY!,
});
const snapshot = await client.pipelines.getGraph({ pipelineId: "pl.019a0000-0000-7000-8000-000000000001" });
const pipeline = await client.pipelines.import({
projectId: "pp.019a0000-0000-7000-8000-000000000001",
name: "Imported pipeline",
graph: snapshot.graph
});
console.log(pipeline);curl --request POST \
--url https://platform.toloka.ai/api/v2-beta/projects/{projectId}/pipelines/import \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"graph": {
"connections": [
{
"from": {
"handle": "<string>",
"node": "<string>"
},
"settings": {},
"to": {
"handle": "<string>",
"node": "<string>"
}
}
],
"fields": [
{
"id": "<string>",
"jsonSchema": {
"additionalProperties": true,
"allOf": [
"<unknown>"
],
"anyOf": [
"<unknown>"
],
"const": "<string>",
"default": "<string>",
"description": "<string>",
"enum": [
"<string>"
],
"examples": [
"<string>"
],
"exclusiveMaximum": 123,
"exclusiveMinimum": 123,
"format": "<string>",
"items": "<unknown>",
"maxItems": 4503599627370495,
"maxLength": 4503599627370495,
"maximum": 123,
"minItems": 4503599627370495,
"minLength": 4503599627370495,
"minimum": 123,
"oneOf": [
"<unknown>"
],
"pattern": "<string>",
"properties": {},
"required": [
"<string>"
],
"title": "<string>",
"uniqueItems": true
},
"name": "<string>"
}
],
"nodes": [
{
"id": "<string>",
"settings": {
"completedFieldProxies": {
"input": [
{
"id": "<string>",
"optional": true
}
]
},
"startedFieldProxies": {
"output": [
{
"id": "<string>",
"optional": true
}
]
},
"datasetId": "<string>",
"itemFilter": {
"createdBefore": "2023-11-07T05:31:56Z",
"excludeParts": [
{
"fieldId": "<string>",
"names": [
"<string>"
]
}
],
"fieldSources": [
{
"fieldId": "<string>",
"sources": [
{
"type": "user",
"userId": "<string>"
}
]
}
],
"fieldValues": [
{
"fieldId": "<string>",
"jsonPath": "<string>",
"value": "<string>",
"latestOnly": true,
"sources": []
}
],
"missingRevisionFields": [
"<string>"
]
},
"itemLimit": 123
},
"type": "root"
}
],
"version": 1,
"layout": {}
},
"name": "<string>"
}
'import requests
url = "https://platform.toloka.ai/api/v2-beta/projects/{projectId}/pipelines/import"
payload = {
"graph": {
"connections": [
{
"from": {
"handle": "<string>",
"node": "<string>"
},
"settings": {},
"to": {
"handle": "<string>",
"node": "<string>"
}
}
],
"fields": [
{
"id": "<string>",
"jsonSchema": {
"additionalProperties": True,
"allOf": ["<unknown>"],
"anyOf": ["<unknown>"],
"const": "<string>",
"default": "<string>",
"description": "<string>",
"enum": ["<string>"],
"examples": ["<string>"],
"exclusiveMaximum": 123,
"exclusiveMinimum": 123,
"format": "<string>",
"items": "<unknown>",
"maxItems": 4503599627370495,
"maxLength": 4503599627370495,
"maximum": 123,
"minItems": 4503599627370495,
"minLength": 4503599627370495,
"minimum": 123,
"oneOf": ["<unknown>"],
"pattern": "<string>",
"properties": {},
"required": ["<string>"],
"title": "<string>",
"uniqueItems": True
},
"name": "<string>"
}
],
"nodes": [
{
"id": "<string>",
"settings": {
"completedFieldProxies": { "input": [
{
"id": "<string>",
"optional": True
}
] },
"startedFieldProxies": { "output": [
{
"id": "<string>",
"optional": True
}
] },
"datasetId": "<string>",
"itemFilter": {
"createdBefore": "2023-11-07T05:31:56Z",
"excludeParts": [
{
"fieldId": "<string>",
"names": ["<string>"]
}
],
"fieldSources": [
{
"fieldId": "<string>",
"sources": [
{
"type": "user",
"userId": "<string>"
}
]
}
],
"fieldValues": [
{
"fieldId": "<string>",
"jsonPath": "<string>",
"value": "<string>",
"latestOnly": True,
"sources": []
}
],
"missingRevisionFields": ["<string>"]
},
"itemLimit": 123
},
"type": "root"
}
],
"version": 1,
"layout": {}
},
"name": "<string>"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"createdAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"name": "<string>",
"projectId": "<string>",
"updatedAt": "2023-11-07T05:31:56Z",
"version": 123
}Authorizations
apiKeyAuthscopedTokenAuth
Enter ApiKey <your-api-key> in Authorization, including the ApiKey prefix. In cURL and Python samples, <api-key> means this full value. The TypeScript SDK adds the prefix for you.
Path Parameters
Project ID with prefix pp..
Pattern:
^pp\.[0-9a-f]{8}-[0-9a-f]{4}-[7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$Body
application/json
Response
Pipeline imported
A pipeline within a project.
Time the pipeline was created, as an ISO 8601 timestamp.
Pattern:
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$Pipeline ID with prefix pl..
Pattern:
^pl\.[0-9a-f]{8}-[0-9a-f]{4}-[7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$Name of the pipeline.
Project ID with prefix pp..
Pattern:
^pp\.[0-9a-f]{8}-[0-9a-f]{4}-[7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$Time the pipeline was last updated, as an ISO 8601 timestamp.
Pattern:
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$Pipeline version number; copying a pipeline increments the source version.
Was this page helpful?