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

# Add A New Task

> Add a new task.



## OpenAPI

````yaml post /{resourceSlug}/forms/task/add
openapi: 3.0.0
info:
  title: Agentcloud Webapp API Docs
  description: The API docs for Agentcloud's webapp.
  version: 0.2.1
servers:
  - url: https://app.agentcloud.dev
    description: Use our public api endpoints!
  - url: '{custom_url}'
    description: Test the endpoints on your own instance of Agent Cloud!
    variables:
      custom_url:
        default: https://app.agentcloud.dev
security: []
tags: []
paths:
  /{resourceSlug}/forms/task/add:
    post:
      tags:
        - Tasks
      summary: Add A New Task
      description: Add a new task.
      operationId: addTaskApi
      parameters:
        - name: resourceSlug
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/ObjectId'
          description: >-
            The resourceSlug is a url parameter of the teamId associated with
            the user. Anywhere the resourceSlug is used can be interpreted as a
            teamId
      requestBody:
        content:
          task.json:
            schema:
              $ref: '#/components/schemas/Task'
        description: >-
          Task object to be added with at minimum all required fields, _id must
          be ommited, this will be generated by the api and returned upon
          successful completion.
      responses:
        '302':
          description: Successful operation, redirect to '/{resourceSlug}/tasks'.
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/tempRedirectResponse'
        '400':
          description: >-
            Invalid toolIds, modelIds or function calling modelIds. The content
            will contain an error message which will detail which field is
            incorrect.
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/dynamicResponse'
        '403':
          description: >-
            Invalid Permissions on the resourceSlug, attempting to access a task
            outside the permissions of the team
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/dynamicResponse'
        '500':
          description: Internal error
          content:
            dynamicResponse:
              schema:
                $ref: '#/components/schemas/dynamicResponse'
components:
  schemas:
    ObjectId:
      description: >-
        Mongodb Object id, unique identifier, length of 24 characters fitting
        the following regex; [a-f0-9]{24}
      type: string
    Task:
      type: object
      description: >-
        Represents a task within the system, including its configuration,
        expected output, and optional form fields.
      required:
        - name
        - description
      properties:
        _id:
          description: Unique identifier for the task.
          oneOf:
            - $ref: '#/components/schemas/ObjectId'
            - type: string
        orgId:
          description: Identifier of the organization to which the task belongs.
          oneOf:
            - $ref: '#/components/schemas/ObjectId'
            - type: string
        teamId:
          description: Identifier of the team to which the task belongs.
          oneOf:
            - $ref: '#/components/schemas/ObjectId'
            - type: string
        name:
          description: The name of the task.
          type: string
        description:
          description: A detailed description of the task.
          type: string
        agentId:
          description: Identifier of the agent associated with the task.
          oneOf:
            - $ref: '#/components/schemas/ObjectId'
            - type: string
        expectedOutput:
          description: The expected output of the task.
          type: string
        toolIds:
          description: List of tool identifiers associated with the task.
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ObjectId'
              - type: string
        asyncExecution:
          description: Indicates if the task is executed asynchronously.
          type: boolean
        context:
          description: Contextual information related to the task.
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/ObjectId'
              - type: string
        outputJson:
          description: The JSON output of the task.
          type: object
          additionalProperties: true
        outputPydantic:
          description: The Pydantic output of the task.
          type: object
          additionalProperties: true
        outputFile:
          description: The file output of the task.
          type: string
        icon:
          description: >-
            Icon associated with the task, either an attachment or an object
            containing the icon details.
          oneOf:
            - $ref: '#/components/schemas/IconAttachment'
            - type: object
              properties:
                id:
                  description: Identifier for the icon.
                  type: string
                filename:
                  description: Filename of the icon.
                  type: string
        requiresHumanInput:
          description: Indicates if the task requires human input.
          type: boolean
        displayOnlyFinalOutput:
          description: Indicates if only the final output should be displayed.
          type: boolean
        hidden:
          description: Indicates if the task is hidden from standard views.
          type: boolean
        formFields:
          description: Array of form field configurations associated with the task.
          type: array
          items:
            $ref: '#/components/schemas/FormFieldConfig'
        isStructuredOutput:
          description: Indicates if the output of the task is structured.
          type: boolean
    tempRedirectResponse:
      description: Server response after successsfully adding a new object
      properties:
        _id:
          type: string
          description: The unique Mongo id of the newly inserted object.
        redirect:
          type: string
          description: >-
            a string containing the redirect link to get all objects after a
            successful insertion.
    dynamicResponse:
      description: Server response
      properties:
        message:
          type: string
          description: Error message to provide more detail
        code:
          type: integer
          description: the error code
    IconAttachment:
      description: Attachment, generally used for image upload
      required:
        - id
        - filename
      properties:
        id:
          description: >-
            this is NOT a unique id for the IconAttachment, this is a Mongo id
            that links to an Asset object (neet to implement assets in docs)
          additionalProperties:
            $ref: '#/components/schemas/ObjectId'
        filename:
          type: string
          description: Filename of the attachment at the point of upload
    FormFieldConfig:
      type: object
      description: >-
        Configuration for a form field within a task, including position, type,
        and optional settings.
      required:
        - position
        - type
        - name
        - label
      properties:
        position:
          description: The position of the form field within the form layout.
          type: string
        type:
          description: The data type of the form field.
          type: string
          enum:
            - string
            - number
            - radio
            - checkbox
            - select
            - multiselect
            - date
        name:
          description: The name attribute of the form field.
          type: string
        label:
          description: The label displayed for the form field.
          type: string
        description:
          description: An optional description for the form field.
          type: string
        required:
          description: Indicates if the form field is required.
          type: boolean
        options:
          description: Options available for fields like radio, select, or multiselect.
          type: array
          items:
            type: string
        tooltip:
          description: A tooltip providing additional information about the form field.
          type: string

````