---
title: Create Worker
slug: tp-api/create-worker
docTags: 
createdAt: 2023-12-26T14:37:58.070Z
---

{
  "id": "6ZnkWV6_QgDHTTG05dy8L",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "{{url}}/api/portal/external/worker",
    "servers": [
      {
        "url": "{{url}}/api/portal/external/worker",
        "description": "Development environment"
      }
    ],
    "name": "Create Worker",
    "description": "This API is used for creating new workers with the system.",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [
        {
          "kind": "required",
          "name": "body",
          "type": "object",
          "customType": "WorkerDTO",
          "schema": [
            {
              "name": "workerId",
              "kind": "optional",
              "type": "string",
              "example": ""
            },
            {
              "name": "pipelineIdList",
              "kind": "optional",
              "type": "array",
              "example": "",
              "itemType": "string",
              "customType": "string[]",
              "itemExample": "",
              "itemDefault": ""
            },
            {
              "name": "infrastructureConfig",
              "kind": "optional",
              "type": "object",
              "modelRef": "#/components/schemas/InfrastructureConfig",
              "customType": "InfrastructureConfig",
              "schema": [
                {
                  "name": "workerId",
                  "kind": "optional",
                  "type": "string",
                  "example": ""
                },
                {
                  "name": "ports",
                  "kind": "optional",
                  "type": "array",
                  "modelRef": "#/components/schemas/PortConfig",
                  "customType": "PortConfig[]",
                  "schema": [
                    {
                      "name": "port",
                      "kind": "optional",
                      "type": "integer<int32>",
                      "example": 0
                    },
                    {
                      "name": "protocol",
                      "kind": "optional",
                      "type": "string<TCP | UDP>",
                      "example": ""
                    },
                    {
                      "name": "componentId",
                      "kind": "optional",
                      "type": "string",
                      "example": ""
                    }
                  ]
                },
                {
                  "name": "params",
                  "kind": "optional",
                  "type": "object",
                  "example": "",
                  "schema": []
                }
              ]
            },
            {
              "name": "params",
              "kind": "optional",
              "type": "object",
              "example": "",
              "schema": []
            }
          ],
          "modelRef": "#/components/schemas/WorkerDTO",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "cookieAuth",
          "name": "SESSION",
          "kind": "optional",
          "type": "apiKey",
          "in": "cookie"
        },
        {
          "id": "tokenAuth",
          "name": "X-XSRF-TOKEN",
          "kind": "optional",
          "type": "apiKey",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "OK",
        "jsonExample": "",
        "isExpanded": true
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "3DK0GgaOq0Hk8ZXh9eeat",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url {{url}}/api/portal/external/worker \\\n     --header 'accept: application/json'"
        },
        {
          "id": "N_ckjB0bKif_HgnG9D4Xy",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"{{url}}/api/portal/external/worker\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "TOe1HHkeVzAjn_OhE4UeI",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"{{url}}/api/portal/external/worker\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "dyDIJK2S34pM5aKRsqQts",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"{{url}}/api/portal/external/worker\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "3DK0GgaOq0Hk8ZXh9eeat"
    },
    "results": {
      "languages": [
        {
          "id": "LbddAInfCMOQ6wDyd3PxK",
          "language": "200",
          "code": "// OK\n"
        }
      ],
      "selectedLanguageId": "LbddAInfCMOQ6wDyd3PxK"
    }
  },
  "children": [
    {
      "id": "rfUw9eMNeksfPGRkxxMXu",
      "type": "paragraph",
      "children": [
        {
          "text": "This API is used for creating new workers with the system.",
          "id": "-ijzrelRHD9gKBCCbuAyw"
        }
      ]
    }
  ]
}