> ## Documentation Index
> Fetch the complete documentation index at: https://beta-docs-prod.indices.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a task

> <p>Create a new task to repeatedly perform an action on an external website.</p><p>Once created and ready, it can be repeatedly executed using the <code>run</code> endpoint.</p>



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/indices/openapi.documented.yml post /v1beta/tasks
openapi: 3.1.0
info:
  title: Indices API
  description: 'The Indices REST API. See docs for details: https://docs.indices.io'
  version: 0.0.1
servers:
  - url: https://api.indices.io
security:
  - ApiKeyAuth: []
tags:
  - name: Tasks
    description: Create a task to repeatedly perform an action on an external website.
  - name: Runs
    description: Execute a task.
  - name: Secrets
    description: Manage secrets like login credentials and API keys.
paths:
  /v1beta/tasks:
    post:
      tags:
        - Tasks
      summary: Create a task
      description: >-
        <p>Create a new task to repeatedly perform an action on an external
        website.</p><p>Once created and ready, it can be repeatedly executed
        using the <code>run</code> endpoint.</p>
      operationId: createTask
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskRequest'
        required: true
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Task'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      x-codeSamples:
        - lang: JavaScript
          source: |-
            import Indices from 'indicesio';

            const client = new Indices({
              apiKey: process.env['INDICES_API_KEY'], // This is the default and can be omitted
            });

            const task = await client.tasks.create({
              creation_params: {},
              display_name: 'display_name',
              task: 'task',
            });

            console.log(task.id);
        - lang: Python
          source: |-
            import os
            from indices import Indices

            client = Indices(
                api_key=os.environ.get("INDICES_API_KEY"),  # This is the default and can be omitted
            )
            task = client.tasks.create(
                creation_params={},
                display_name="display_name",
                task="task",
            )
            print(task.id)
components:
  schemas:
    CreateTaskRequest:
      properties:
        display_name:
          type: string
          description: >-
            Short title shown in the dashboard. Informational only; not used to
            generate the task.
        task:
          type: string
          description: Detailed explanation of the task to be performed.
        creation_params:
          $ref: '#/components/schemas/CreationParams'
          description: Information used during task creation.
      type: object
      required:
        - display_name
        - task
        - creation_params
      title: CreateTaskRequest
    Task:
      properties:
        id:
          type: string
          description: Unique identifier for the object.
          examples:
            - task_0R3kPq8mWxYz1aBcDeFgHi
          example: task_0R3kPq8mWxYz1aBcDeFgHi
        current_state:
          $ref: '#/components/schemas/TaskState'
          description: Current state of the task, in particular whether it is ready to use.
          examples:
            - ready
          example: ready
        display_name:
          type: string
          description: Short title shown in the dashboard. Informational only.
          examples:
            - Recent store orders
          example: Recent store orders
        task:
          type: string
          description: Detailed explanation of the task to be performed.
          examples:
            - Fetch the most recent orders from the signed-in user's account.
          example: Fetch the most recent orders from the signed-in user's account.
        website:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          description: >-
            The primary URL the task targets. May be null while the task is not
            ready; non-null once generation completes.
          examples:
            - https://shop.example.com
          example: https://shop.example.com
        input_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            Task input schema as a JSON Schema object. May be null while the
            task is not ready (e.g. schema generation in progress). Guaranteed
            non-null when current_state is ready.
          examples:
            - properties:
                limit:
                  type: integer
              required: []
              type: object
          example:
            properties:
              limit:
                type: integer
            required: []
            type: object
        output_schema:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          description: >-
            Task output schema as a JSON Schema object. May be null while the
            task is not ready (e.g. schema generation in progress). Guaranteed
            non-null when current_state is ready.
          examples:
            - properties:
                orders:
                  items:
                    properties:
                      id:
                        type: string
                      total:
                        type: number
                    type: object
                  type: array
              required:
                - orders
              type: object
          example:
            properties:
              orders:
                items:
                  properties:
                    id:
                      type: string
                    total:
                      type: number
                  type: object
                type: array
            required:
              - orders
            type: object
        creation:
          $ref: '#/components/schemas/TaskCreation'
          description: Parameters set during the creation of this task.
        required_secrets:
          items:
            $ref: '#/components/schemas/SecretSlotDefinition'
          type: array
          description: List of secrets that must be provided when running this task.
        failure_info:
          anyOf:
            - $ref: '#/components/schemas/TaskFailureInfo'
            - type: 'null'
          description: >-
            Failure information if the task failed, including user-friendly
            explanation and suggestions
        created_at:
          type: string
          format: date-time
          description: Timestamp when the object was created.
          examples:
            - '2026-01-01T12:00:00Z'
          example: '2026-01-01T12:00:00Z'
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the object was last updated.
          examples:
            - '2026-01-06T12:05:00Z'
          example: '2026-01-06T12:05:00Z'
      type: object
      required:
        - id
        - current_state
        - display_name
        - task
        - website
        - input_schema
        - output_schema
        - creation
        - created_at
        - updated_at
      title: Task
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CreationParams:
      properties:
        secrets:
          items:
            $ref: '#/components/schemas/CreationSecret'
          type: array
          description: 'List of secrets to use for this task. '
      type: object
      title: CreationParams
      description: Parameters for creating a task.
    TaskState:
      type: string
      enum:
        - not_ready
        - waiting_for_manual_completion
        - ready
        - failed
      title: TaskState
    TaskCreation:
      properties:
        secrets:
          items:
            $ref: '#/components/schemas/CreationSecret'
          type: array
          description: List of secrets provided during task creation.
        secret_bindings:
          additionalProperties:
            type: string
          type: object
          description: >-
            Mapping of required secret slot names to secret IDs bound during
            task creation.
          examples:
            - LOGIN: sec_8kPq2mWxYz1aBcDeFgHi3J
          example:
            LOGIN: sec_8kPq2mWxYz1aBcDeFgHi3J
      type: object
      title: TaskCreation
      description: Creation-related task data.
    SecretSlotDefinition:
      properties:
        name:
          type: string
          description: >-
            Name of the secret slot (used as env var prefix, e.g., 'LOGIN' →
            LOGIN_USERNAME).
          examples:
            - LOGIN
          example: LOGIN
        type:
          $ref: '#/components/schemas/SecretType'
          description: 'Type of secret required: ''login'' or ''string''.'
          examples:
            - login
          example: login
        requires_totp:
          type: boolean
          description: >-
            Whether this login slot requires 2FA/TOTP. Only applicable for
            'login' type.
          default: false
          examples:
            - false
          example: false
      type: object
      required:
        - name
        - type
      title: SecretSlotDefinition
      description: Definition of a secret slot that a task requires.
    TaskFailureInfo:
      properties:
        category:
          type: string
          description: Primary failure category
          examples:
            - authentication
          example: authentication
        message:
          type: string
          description: Summary of the failure cause
          examples:
            - The website requires a login we could not complete automatically.
          example: The website requires a login we could not complete automatically.
      type: object
      required:
        - category
        - message
      title: TaskFailureInfo
      description: Information about why a task failed, for user display.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    CreationSecret:
      properties:
        secret_id:
          type: string
          description: ID of the secret to bind.
          examples:
            - sec_8kPq2mWxYz1aBcDeFgHi3J
          example: sec_8kPq2mWxYz1aBcDeFgHi3J
        description:
          anyOf:
            - type: string
            - type: 'null'
          description: >-
            Optional description of what this secret is used for (helps generate
            meaningful slot names).
          examples:
            - Login credentials for the store account.
          example: Login credentials for the store account.
      type: object
      required:
        - secret_id
      title: CreationSecret
      description: A secret provided during task creation
    SecretType:
      type: string
      enum:
        - login
        - string
      title: SecretType
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        Enter your API key as the bearer token. Set header: `Authorization` to
        `Bearer <api_key>`

````