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

# Create a new task

> This endpoint allows you to create a new task using either natural language (crawler_automation) or code instructions (script_automation). You must specify the execution engine, project, location, and task steps.



## OpenAPI

````yaml POST /tasks
openapi: 3.0.3
info:
  title: BrowserAI Task API
  version: 1.0.0
  description: API for creating and retrieving browser automation tasks and their results.
servers:
  - url: https://browser.ai/api/v1
security: []
paths:
  /tasks:
    post:
      tags:
        - Task
      summary: Create a new task.
      description: >-
        This endpoint allows you to create a new task using either natural
        language (crawler_automation) or code instructions (script_automation).
        You must specify the execution engine, project, location, and task
        steps.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTaskRequest'
            examples:
              crawler_automation:
                summary: crawler_automation (natural language)
                value:
                  instructions:
                    - action: Open amazon.com and search for AirPods
                  geoLocation:
                    country: US
                  project: Project_1
                  type: crawler_automation
              script_automation:
                summary: script_automation (code instructions)
                value:
                  instructions:
                    - action: >-
                        await
                        page.goto('https://docs.stagehand.dev/reference/introduction')
                    - action: await page.act('Click the search box')
                  geoLocation:
                    country: US
                  project: Project_1
                  type: script_automation
      responses:
        '200':
          description: Task created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateTaskResponse'
        '400':
          description: Invalid input or project not found
          content:
            application/json:
              example:
                error: Invalid input or project not found
        '401':
          description: Unauthorized
          content:
            application/json:
              example:
                error: Unauthorized
        '500':
          description: Internal server error
          content:
            application/json:
              example:
                error: Internal server error
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CreateTaskRequest:
      type: object
      required:
        - instructions
        - geoLocation
        - project
        - type
      properties:
        instructions:
          type: array
          description: >-
            List of actions to perform. For 'crawler_automation', use natural
            language. For 'script_automation', use TypeScript code.
          items:
            type: object
            required:
              - action
            properties:
              action:
                type: string
                description: Instruction to be executed by the agent.
        geoLocation:
          $ref: '#/components/schemas/GeoLocation'
        project:
          type: string
        type:
          type: string
          enum:
            - crawler_automation
            - script_automation
          description: >-
            Execution engine: 'crawler_automation' for natural language,
            'script_automation' for code.
        inspect:
          type: boolean
    CreateTaskResponse:
      type: object
      properties:
        executionId:
          type: string
        scriptType:
          type: string
        status:
          type: string
        geoLocation:
          $ref: '#/components/schemas/GeoLocation'
        started:
          type: string
          format: date-time
          nullable: true
        estimatedCompletion:
          type: string
          format: date-time
          nullable: true
    GeoLocation:
      type: object
      required:
        - country
      properties:
        country:
          type: string
          description: '2-letter country code, for example: es for Spain.'
        city:
          type: string
        zipcode:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: Authorization
      description: 'Insert API token, use the format: `apikey <API-TOKEN>`.'

````