# Create version


```
POST 
https://api.apify.com/v2/acts/:actorId/versions
```


Creates a version of an Actor using values specified in a  passed as JSON in the POST payload.

The request must specify `versionNumber` and `sourceType` parameters (as strings) in the JSON payload and a `Content-Type: application/json` HTTP header.

Each `sourceType` requires its own additional properties to be passed to the JSON payload object. These are outlined in the  table below and in more detail in the [Apify documentation](https://docs.apify.com/platform/actors/development/deployment/source-types).

For example, if an Actor's source code is stored in a [GitHub repository](https://docs.apify.com/platform/actors/development/deployment/source-types#git-repository), you will set the `sourceType` to `GIT_REPO` and pass the repository's URL in the `gitRepoUrl` property.


```
{
    "versionNumber": "0.1",
    "sourceType": "GIT_REPO",
    "gitRepoUrl": "https://github.com/my-github-account/actor-repo"
}
```


The response is the  as returned by the  endpoint.

## Request

### Path Parameters

* **actorId** string required

  Actor ID or a tilde-separated owner's username and Actor name.

  **Example:** `janedoe~my-actor`

### Body**required**

* **versionNumber** string | null nullable\
  **Example:** `0.0`

* **sourceType** object

  * anyOf

    * VersionSourceType
    * null

    VersionSourceType (string)

    **Possible values:** \[`SOURCE_FILES`, `GIT_REPO`, `TARBALL`, `GITHUB_GIST`]

* **envVars** object\[]

  * **name** string required\
    **Example:** `MY_ENV_VAR`
  * **value** string required\
    **Example:** `my-value`
  * **isSecret** boolean | null nullable\
    **Example:** `false`

* **applyEnvVarsToBuild** boolean | null nullable\
  **Example:** `false`

* **buildTag** string | null nullable\
  **Example:** `latest`

* **sourceFiles** object\[]

  * anyOf

    * SourceCodeFile
    * SourceCodeFolder

    **format** SourceCodeFileFormat (string) required

    **Possible values:** \[`BASE64`, `TEXT`]

    **Example:** `TEXT`

  * **content** string required\
    **Example:** `console.log('This is the main.js file');`

  * **name** string required\
    **Example:** `src/main.js`

* **gitRepoUrl** string | null nullable

  URL of the Git repository when sourceType is GIT\_REPO.

* **tarballUrl** string | null nullable

  URL of the tarball when sourceType is TARBALL.

* **gitHubGistUrl** string | null nullable

  URL of the GitHub Gist when sourceType is GITHUB\_GIST.

### Status 201

**Response Headers**

* **Location**


```
{
  "data": {
    "versionNumber": "0.0",
    "sourceType": "SOURCE_FILES",
    "envVars": "Unknown Type: array,null",
    "applyEnvVarsToBuild": false,
    "buildTag": "latest",
    "sourceFiles": [
      {
        "format": "TEXT",
        "content": "console.log('This is the main.js file');",
        "name": "src/main.js"
      },
      {
        "name": "src/utils",
        "folder": true
      }
    ],
    "gitRepoUrl": "string",
    "tarballUrl": "string",
    "gitHubGistUrl": "string"
  }
}
```


**Schema**

* **data** object required

  * **versionNumber** string required\
    **Example:** `0.0`

  * **sourceType** object required

    * anyOf

      * VersionSourceType
      * null

      VersionSourceType (string)

      **Possible values:** \[`SOURCE_FILES`, `GIT_REPO`, `TARBALL`, `GITHUB_GIST`]

  * **envVars** object\[]

    * **name** string required\
      **Example:** `MY_ENV_VAR`
    * **value** string required\
      **Example:** `my-value`
    * **isSecret** boolean | null nullable\
      **Example:** `false`

  * **applyEnvVarsToBuild** boolean | null nullable\
    **Example:** `false`

  * **buildTag** string\
    **Example:** `latest`

  * **sourceFiles** object\[]

    * anyOf

      * SourceCodeFile
      * SourceCodeFolder

      **format** SourceCodeFileFormat (string) required

      **Possible values:** \[`BASE64`, `TEXT`]

      **Example:** `TEXT`

    * **content** string required\
      **Example:** `console.log('This is the main.js file');`

    * **name** string required\
      **Example:** `src/main.js`

  * **gitRepoUrl** string | null nullable

    URL of the Git repository when sourceType is GIT\_REPO.

  * **tarballUrl** string | null nullable

    URL of the tarball when sourceType is TARBALL.

  * **gitHubGistUrl** string | null nullable

    URL of the GitHub Gist when sourceType is GITHUB\_GIST.

### Status 400

Bad request - invalid input parameters or request body.


```
{
  "error": {
    "type": "invalid-input",
    "message": "Invalid input: The request body contains invalid data."
  }
}
```


**Schema**

* **error** object required

  * **type** string required\
    **Example:** `run-failed`
  * **message** string required\
    **Example:** `Actor run did not succeed (run ID: 55uatRrZib4xbZs, status: FAILED)`
