Skip to main content

Actor input schema specification

Learn how to define and validate a schema for your Actor's input with code examples. Provide an autogenerated input UI for your Actor's users.


The Actor input schema serves three main purposes:

  • It ensures the input data supplied to the Actor adhere to specified requirements and validation rules.
  • It is used by the Apify platform to generate a user-friendly interface for configuring and running your Actor.
  • It simplifies invoking your Actors from external systems by generating calling code and connectors for integrations.

To define an input schema for an Actor, set input field in the .actor/actor.json file to an input schema object (described below), or path to a JSON file containing the input schema object. For backwards compatibility, if the input field is omitted, the system looks for an INPUT_SCHEMA.json file either in the .actor directory or the Actor's top-level directory—but note that this functionality is deprececated and might be removed in the future. The maximum allowed size for the input schema file is 500 kB.

When you provide an input schema, the system will validate the input data passed to the Actor on start (via the API or Apify Console) against the specified schema to ensure compliance before starting the Actor. If the input object doesn't conform the schema, the caller receives an error and the Actor is not started.

Validation aid

You can also use our visual input schema editor to guide you through the creation of the INPUT_SCHEMA.json file. If you need to validate your input schemas, you can use the apify validate-schema command in the Apify CLI.

Example

Imagine a simple web crawler that accepts an array of start URLs and a JavaScript function to execute on each visited page. The input schema for such a crawler could be defined as follows:

{
"title": "Cheerio Crawler input",
"description": "To update crawler to another site, you need to change startUrls and pageFunction options!",
"type": "object",
"schemaVersion": 1,
"properties": {
"startUrls": {
"title": "Start URLs",
"type": "array",
"description": "URLs to start with",
"prefill": [
{ "url": "http://example.com" },
{ "url": "http://example.com/some-path" }
],
"editor": "requestListSources"
},
"pageFunction": {
"title": "Page function",
"type": "string",
"description": "Function executed for each request",
"prefill": "async () => { return $('title').text(); }",
"editor": "javascript"
}
},
"required": ["startUrls", "pageFunction"]
}

The generated input UI will be:

Apify Actor input schema example

If you switch the input to the JSON display using the toggle, then you will see the entered input stringified to JSON, as it will be passed to the Actor:

{
"startUrls": [
{
"url": "http://example.com"
},
{
"url": "http://example.com/some-path"
}
],
"pageFunction": "async () => { return $('title').text(); }"
}

Structure

{
"title": "Cheerio Crawler input",
"type": "object",
"schemaVersion": 1,
"properties": { /* define input fields here */ },
"required": []
}
PropertyTypeRequiredDescription
titleStringYesAny text describing your input schema.
descriptionStringNoHelp text for the input that will be
displayed above the UI fields.
typeStringYesThis is fixed and must be set
to string object.
schemaVersionIntegerYesThe version of the input schema
specification against which
your schema is written.
Currently, only version 1 is out.
propertiesObjectYesThis is an object mapping each field key
to its specification.
requiredStringNoAn array of field keys that are required.
Input schema differences

Even though the structure of the Actor input schema is similar to JSON schema, there are some differences. We cannot guarantee that JSON schema tooling will work on input schema documents. For a more precise technical understanding of the matter, feel free to browse the code of the @apify/input_schema package.

Fields

Each field of your input is described under its key in the inputSchema.properties object. The field might have integer, string, array, object, or boolean type, and its specification contains the following properties:

PropertyValueRequiredDescription
typeOne of
  • string
  • array
  • object
  • boolean
  • integer
YesAllowed type for the input value.
Cannot be mixed.
titleStringYesTitle of the field in UI.
descriptionStringYesDescription of the field that will be
displayed as help text in Actor input UI.
defaultMust match type property.NoDefault value that will be
used when no value is provided.
prefillMust match type property.NoValue that will be prefilled
in the Actor input interface.
Only the boolean type doesn't
support prefill property.
exampleMust match type property.NoSample value of this field
for the Actor to be displayed when
Actor is published in Apify Store.
sectionCaptionStringNoIf this property is set,
then all fields following this field
(this field included) will be separated
into a collapsible section
with the value set as its caption.
The section ends at the last field
or the next field which has the
sectionCaption property set.
sectionDescriptionStringNoIf the sectionCaption property is set,
then you can use this property to
provide additional description to the section.
The description will be visible right under
the caption when the section is open.

Prefill vs. default vs. required

Here is a rule of thumb for whether an input field should have a prefill, default, or be required:

  • Prefill - Use for fields that don't have a reasonable default. The provided value is prefilled for the user to show them an example of using the field and to make it easy to test the Actor (e.g., search keyword, start URLs). In other words, this field is only used in the user interface but does not affect the Actor functionality and API.
  • Required - Use for fields that don't have a reasonable default and MUST be entered by the user (e.g., API token, password).
  • Default - Use for fields that MUST be set for the Actor run to some value, but where you don't need the user to change the default behavior (e.g., max pages to crawl, proxy settings). If the user omits the value when starting the Actor via any means (API, CLI, scheduler, or user interface), the platform automatically passes the Actor this default value.
  • No particular setting - Use for purely optional fields where it makes no sense to prefill any value (e.g., flags like debug mode or download files).

In summary, you can use each option independently or use a combination of Prefill + Required, but the combinations Prefill + Default or Default + Required don't make sense to use.

Additional properties

Most types also support additional properties defining, for example, the UI input editor.

String

Example of a code input:

{
"title": "Page function",
"type": "string",
"description": "Function executed for each request",
"editor": "javascript",
"prefill": "async () => { return $('title').text(); }"
}

Rendered input:

Apify Actor input schema page function

Example of country selection using a select input:

{
"title": "Country",
"type": "string",
"description": "Select your country",
"editor": "select",
"default": "us",
"enum": ["us", "de", "fr"],
"enumTitles": ["USA", "Germany", "France"]
}

Rendered input:

Apify Actor input schema - country input

Example of date selection using absolute and relative datepicker editor:

{
"absoluteDate": {
"title": "Date",
"type": "string",
"description": "Select absolute date in format YYYY-MM-DD",
"editor": "datepicker",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$"
},
"relativeDate": {
"title": "Relative date",
"type": "string",
"description": "Select relative date in format: {number} {unit}",
"editor": "datepicker",
"dateType": "relative",
"pattern": "^(\\d+)\\s*(day|week|month|year)s?$"
},
"anyDate": {
"title": "Any date",
"type": "string",
"description": "Select date in format YYYY-MM-DD or {number} {unit}",
"editor": "datepicker",
"dateType": "absoluteOrRelative",
"pattern": "^(\\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$|^(\\d+)\\s*(day|week|month|year)s?$"
}
}

The absoluteDate property renders a date picker that allows selection of a specific date and returns string value in YYYY-MM-DD format. Validation is ensured thanks to pattern field. In this case the dateType property is omitted, as it defaults to "absolute".

Apify Actor input schema - country input

The relativeDate property renders an input field that enables the user to choose the relative date and returns the value in {number} {unit} format, for example "2 days". The dateType parameter is set to "relative" to restrict input to relative dates only.

Apify Actor input schema - country input

The anyDate property renders a date picker that accepts both absolute and relative dates. The Actor author is responsible for parsing and interpreting the selected date format.

Apify Actor input schema - country input

Properties:

PropertyValueRequiredDescription
editorOne of
  • textfield
  • textarea
  • javascript
  • python
  • select
  • datepicker
  • hidden
YesVisual editor used for
the input field.
patternStringNoRegular expression that will be
used to validate the input.
If validation fails,
the Actor will not run.
minLengthIntegerNoMinimum length of the string.
maxLengthIntegerNoMaximum length of the string.
enum[String]Required if
editor
is select
Using this field, you can limit values
to the given array of strings.
Input will be displayed as select box.
enumTitles[String]NoTitles for the enum keys described.
nullableBooleanNoSpecifies whether null
is an allowed value.
isSecretBooleanNoSpecifies whether the input field
will be stored encrypted.
Only available
with textfield and textarea editors.
dateTypeOne of
  • absolute
  • relative
  • absoluteOrRelative
NoThis property, which is only available with datepicker editor, specifies what date format should visual editor accept (The JSON editor accepts any string without validation.).

  • absolute value enables date input in YYYY-MM-DD format. To parse returned string regex like this can be used: ^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$.

  • relative value enables relative date input in
    {number} {unit} format.
    Supported units are: days, weeks, months, years.

    The input is passed to the Actor as plain text (e.g., "3 weeks"). To parse it, regex like this can be used: ^(\d+)\s*(day|week|month|year)s?$.

  • absoluteOrRelative value enables both absolute and relative formats and user can switch between them. It's up to Actor author to parse a determine actual used format - regexes above can be used to check whether the returned string match one of them.

Defaults to absolute.
Regex escape

When using escape characters \ for the regular expression in the pattern field, be sure to escape them to avoid invalid JSON issues. For example, the regular expression https:\/\/(www\.)?apify\.com\/.+ would become https:\\/\\/(www\\.)?apify\\.com\\/.+.

Boolean

Example options with group caption:

{
"verboseLog": {
"title": "Verbose log",
"type": "boolean",
"description": "Debug messages will be included in the log.",
"default": true,
"groupCaption": "Options",
"groupDescription": "Various options for this Actor"
},
"lightspeed": {
"title": "Lightspeed",
"type": "boolean",
"description": "If checked then actors runs at the
speed of light.",
"prefill": true
}
}

Rendered input:

Apify Actor input schema options

Properties:

PropertyValueRequiredDescription
editorOne of
  • checkbox
  • hidden
NoVisual editor used for the input field.
groupCaptionStringNoIf you want to group
multiple checkboxes together,
add this option to the first
of the group.
groupDescriptionStringNoDescription displayed as help text
displayed of group title.
nullableBooleanNoSpecifies whether null is
an allowed value.

Integer

Example:

{
"title": "Memory",
"type": "integer",
"description": "Select memory in megabytes",
"default": 64,
"maximum": 1024,
"unit": "MB"
}

Rendered input:

Apify Actor input schema memory

Properties:

PropertyValueRequiredDescription
editorOne of:
  • number
  • hidden
NoVisual editor used for input field.
maximumIntegerNoMaximum allowed value.
minimumIntegerNoMinimum allowed value.
unitStringNoUnit displayed next to the field in UI,
for example second, MB, etc.
nullableBooleanNoSpecifies whether null is an allowed value.

Object

Example of proxy configuration:

{
"title": "Proxy configuration",
"type": "object",
"description": "Select proxies to be used by your crawler.",
"prefill": { "useApifyProxy": true },
"editor": "proxy"
}

Rendered input:

Apify Actor input schema proxy

The object where the proxy configuration is stored has the following structure:

{
// Indicates whether Apify Proxy was selected.
"useApifyProxy": Boolean,

// Array of Apify Proxy groups. Is missing or null if
// Apify Proxy's automatic mode was selected
// or if proxies are not used.
"apifyProxyGroups": String[],

// Array of custom proxy URLs.
// Is missing or null if custom proxies were not used.
"proxyUrls": String[],
}

Example of a blackbox object:

{
"title": "User object",
"type": "object",
"description": "Enter object representing user",
"prefill": {
"name": "John Doe",
"email": "janedoe@gmail.com"
},
"editor": "json"
}

Rendered input:

Apify Actor input schema user object

Properties:

PropertyValueRequiredDescription
editorOne of
  • json
  • proxy
  • hidden
YesUI editor used for input.
patternKeyStringNoRegular expression that will be used
to validate the keys of the object.
patternValueStringNoRegular expression that will be used
to validate the values of object.
maxPropertiesIntegerNoMaximum number of properties
the object can have.
minPropertiesIntegerNoMinimum number of properties
the object can have.
nullableBooleanNoSpecifies whether null is
an allowed value.

Array

Example of request list sources configuration:

{
"title": "Start URLs",
"type": "array",
"description": "URLs to start with",
"prefill": [{ "url": "https://apify.com" }],
"editor": "requestListSources"
}

Rendered input:

Apify Actor input schema start urls array

Example of an array:

{
"title": "Colors",
"type": "array",
"description": "Enter colors you know",
"prefill": ["Red", "White"],
"editor": "json"
}

Rendered input:

Apify Actor input schema colors array

Properties:

PropertyValueRequiredDescription
editorOne of
  • json
  • requestListSources
  • pseudoUrls
  • globs
  • keyValue
  • stringList
  • select
  • hidden
YesUI editor used for input.
placeholderKeyStringNoPlaceholder displayed for
key field when no value is specified.
Works only with keyValue editor.
placeholderValueStringNoPlaceholder displayed in value field
when no value is provided.
Works only with keyValue and
stringList editors.
patternKeyStringNoRegular expression that
will be used to validate
the keys of items in the array.
Works only with keyValue
editor.
patternValueStringNoRegular expression that
will be used to validate the values
of items in the array.
Works only with keyValue and
stringList editors.
maxItemsIntegerNoMaximum number of items
the array can contain.
minItemsIntegerNoMinimum number of items
the array can contain.
uniqueItemsBooleanNoSpecifies whether the array
should contain only unique values.
nullableBooleanNoSpecifies whether null is
an allowed value.
itemsobjectNoSpecifies format of the items of the array, useful mainly for multiselect (see below)

Usage of this field is based on the selected editor:

  • requestListSources - value from this field can be used as input for the RequestList class from Crawlee.
  • pseudoUrls - is intended to be used with a combination of the PseudoUrl class and the enqueueLinks() function from Crawlee.

Editor type requestListSources supports input in formats defined by the sources property of RequestListOptions.

Editor type globs maps to the Crawlee's GlobInput used by the UrlPatterObject.

Editor type select allows the user to pick items from a select, providing multiple choices. Please check this example of how to define the multiselect field:

{
"title": "Multiselect field",
"description": "My multiselect field",
"type": "array",
"editor": "select",
"items": {
"type": "string",
"enum": ["value1", "value2", "value3"],
"enumTitles": ["Label of value1", "Label of value2", "Label of value3"]
}
}

To correctly define options for multiselect, you need to define the items property and then provide values and (optionally) labels in enum and enumTitles properties.

Resource type

Resource type identifies what kind of Apify Platform object is referred to in the input field. For example, the Key-value store resource type can be referred to using a string ID. Currently, it supports storage resources only, allowing the reference of a Dataset, Key-Value Store or Request Queue.

For Actor developers, the resource input value is a string representing the storage ID. The type of the property is either string or array. In case of array (for multiple resources) the return value is an array of IDs. In the user interface, a picker is provided for easy selection, where users can search and choose from their own storages or those they have access to.

Example of a Dataset input:

{
"title": "Dataset",
"type": "string",
"description": "Select a dataset",
"resourceType": "dataset"
}

Rendered input:

Apify Actor input schema dataset

The returned value is resource reference, in this example it's the dataset ID as can be seen in the JSON tab:

Apify Actor input schema dataset

Example of multiple datasets input:

{
"title": "Datasets",
"type": "array",
"description": "Select multiple datasets",
"resourceType": "dataset"
}

Rendered input:

Apify Actor input schema datasets

Properties:

PropertyValueRequiredDescription
typeOne of
  • string
  • array
YesSpecifies the type of input - string for single value or array for multiple values
editorOne of
  • resourcePicker
  • hidden
NoVisual editor used for
the input field. Defaults to resourcePicker.
resourceTypeOne of
  • dataset
  • keyValueStore
  • requestQueue
YesType of Apify Platform resource
minItemsIntegerNoMinimum number of items the array can contain. Only for type: array
maxItemsIntegerNoMaximum number of items the array can contain. Only for type: array