---
title: "Create new variables on a task"
method: POST
path: "/cmmn-runtime/tasks/{taskId}/variables"
tags: ["Tasks", "Task Variables"]
---

# Create new variables on a task

`POST /cmmn-runtime/tasks/{taskId}/variables`

## Request

- Base URL: `https://developer-docs.flowable.com/cmmn-api`
- URL: `https://developer-docs.flowable.com/cmmn-api/cmmn-runtime/tasks/{taskId}/variables`
- Auth: HTTP basic
- TypeScript: <https://skmtc.dev/flowable/apis/flowable-cmmn-rest-api/docs/cmmn-runtime/tasks/:taskId/variables/post.ts> (a function with typed inputs; its response is checked against the schema)

This endpoint can be used in 2 ways: By passing a JSON Body (RestVariable or an Array of RestVariable) or by passing a multipart/form-data Object.
It is possible to create simple (non-binary) variable or list of variables or new binary variable 
Any number of variables can be passed into the request body array.
NB: Swagger V2 specification does not support this use case that is why this endpoint might be buggy/incomplete if used with other tools.

## Path parameters

- `taskId` string, required

## Request body

- TaskVariableCollectionResource

## Response `201`

Indicates the variables were created and the result is returned.

- object

## Other responses

- `400`: Indicates the name of a variable to create was missing or that an attempt is done to create a variable on a standalone task (without a process associated) with scope global or an empty array of variables was included in the request or request did not contain an array of variables. Status message provides additional information.
- `404`: Indicates the requested task was not found.
- `409`: Indicates the task already has a variable with the given name. Use the PUT method to update the task variable instead.
- `415`: Indicates the serializable data contains an object for which no class is present in the JVM running the Flowable engine and therefore cannot be deserialized.

---

[API](https://skmtc.dev/flowable/apis/flowable-cmmn-rest-api.md) - [All operations](https://skmtc.dev/flowable/apis/flowable-cmmn-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/flowable/apis/flowable-cmmn-rest-api/revisions/afdfa1fcacd0?raw)
