Skip to main content

Create version

POST 

/v2/actors/:actorId/versions

Creates a version of an Actor using values specified in a Version object 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 Version object table below and in more detail in the Apify documentation.

For example, if an Actor's source code is stored in a GitHub 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 Version object as returned by the Get version endpoint.

Request

Path Parameters

    actorId string required

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


    Example: janedoe~my-actor

Bodyrequired

  • versionNumber string | null nullable

    The version number of the Actor. Two numbers separated by a dot, that represent the MAJOR.MINOR part of the semantic versioning.

    Possible values: Value must match regular expression ^([0-9]|[1-9][0-9])\.([0-9]|[1-9][0-9])$


    Example: 1.6
  • sourceType object

    Where the source code of the version lives.

      anyOf
    • VersionSourceType (string)

      Possible values: [SOURCE_FILES, GIT_REPO, TARBALL, GITHUB_GIST, SOURCE_CODE]

  • envVars object

    Environment variables for the version.

      anyOf
    • name string required

      The name of the environment variable.


      Example: MY_ENV_VAR
    • value string

      The value of the environment variable. If isSecret is true, this value isn't returned by the API.


      Example: my-value
    • isSecret boolean | null nullable

      Whether the environment variable is encrypted. Secret values aren't returned by the API.


      Example: false
  • applyEnvVarsToBuild boolean | null nullable

    Whether to inject the environment variables at build time.


    Example: false
  • buildTag string | null nullable

    The tag name to apply to a successful build of this version. Can be null when the version has no build tag.


    Example: latest
  • sourceFiles object[]

    Applies when the sourceType is SOURCE_FILES. Represents the Actor's file structure as an array of files and folders.

      anyOf
    • format SourceCodeFileFormat (string)

      Format of the file's content, TEXT for plain text and BASE64 for encoded content.

      Possible values: [BASE64, TEXT]


      Example: TEXT
    • content string

      The contents of the file. Interpreted based on the value of format.


      Example: console.log('This is the main.js file');
    • name string required

      The path of the file relative to the Actor's root directory.


      Example: src/main.js
  • gitRepoUrl string | null nullable

    URL of the Git repository to clone the source code from. Applies when the sourceType is GIT_REPO.

  • tarballUrl string | null nullable

    URL of the tarball to download the source code from. Applies when the sourceType is TARBALL.

  • gitHubGistUrl string | null nullable

    URL of the GitHub Gist to clone the source code from. Applies when the sourceType is GITHUB_GIST.

Status 201

Response Headers
  • Location
{
"data": {
"versionNumber": "0.0",
"sourceType": "SOURCE_FILES",
"envVars": [
{
"name": "MY_ENV_VAR",
"value": "my-value",
"isSecret": false
}
],
"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"
}
}