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

# Create job

> Converses with your data. Ask any question you have about your data and get insights instantly.  

On Powerdrill, a **job** refers to a task that Powerdrill performs to generate a response based on your request (e.g., a prompt or other workflows). 

For an in-depth explanation of **jobs**, see [What Is Job?](/enterprise/what-is-job).  




## OpenAPI

````yaml post /v2/team/jobs
openapi: 3.0.1
info:
  title: Team Open API Snake
  description: ''
  version: 1.0.0
servers:
  - url: https://ai.data.cloud/api
    description: 体验环境
security:
  - apikey-header-x-pd-api-key: []
tags:
  - name: Session
  - name: Dataset
  - name: Data source
  - name: File
  - name: Job
paths:
  /v2/team/jobs:
    post:
      tags:
        - Job
      summary: Create job
      description: >
        Converses with your data. Ask any question you have about your data and
        get insights instantly.  


        On Powerdrill, a **job** refers to a task that Powerdrill performs to
        generate a response based on your request (e.g., a prompt or other
        workflows). 


        For an in-depth explanation of **jobs**, see [What Is
        Job?](/enterprise/what-is-job).  
      parameters:
        - name: x-pd-external-trace-id
          in: header
          description: >-
            The trace ID you set in your system to trace this request. It can be
            up to 128 characters in length. If the request fails, you can
            provide it to the Powerdrill team to help with troubleshooting.
          required: false
          example: ''
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                session_id:
                  type: string
                  description: >-
                    The session ID.


                    To check sessions you created, call [GET
                    /v2/team/sessions](/api-reference/v2/list-sessions).
                stream:
                  type: boolean
                  description: >-
                    Whether to use stream mode. If set to `true`, Powerdrill
                    will send real-time updates to the client, delivering
                    continuous data as it becomes available. If set to `false`,
                    Powerdrill will return the full response only once the
                    entire answer is ready.


                    If not specified, the default value `false` will be used.


                    For details about how to understand streaming responses, see
                    "Content description" in
                    [Streaming](/api-reference/v2/streaming#content-description).
                  default: false
                question:
                  type: string
                  description: The question you want Powerdrill to answer.
                dataset_id:
                  type: string
                  description: >-
                    The ID of the dataset to attach to the job. 


                    To check the datasets you have access to, call [GET
                    /v2/team/datasets](/api-reference/v2/list-datasets).
                datasource_ids:
                  type: array
                  items:
                    type: string
                  description: >-
                    Specifies the IDs of the data sources to use in the
                    conversation, rather than the entire dataset. You can
                    specify up to 1,000 data sources. This parameter is
                    effective only when `dataset_id` is specified.
                output_language:
                  type: string
                  description: >-
                    The language in which the output is generated. For example,
                    if set to `EN`, the output will be in English. If not
                    specified, the session's `output_language` setting will be
                    used. Possible values are:

                    - `AUTO`: adaptive recognition

                    - `EN`: English

                    - `ES`: Spanish

                    - `AR`: Arabic

                    - `PT`: Portuguese

                    - `ID`: Indonesian

                    - `JA`: Japanese

                    - `RU`: Russian

                    - `HI`: Hindi

                    - `FR`: French

                    - `DE`: German

                    - `VI`: Vietnamese

                    - `TR`: Turkish

                    - `PL`: Polish

                    - `IT`: Italian

                    - `KO`: Korean

                    - `ZH-CN`: Simplified Chinese

                    - `ZH-TW`: Traditional Chinese
                  enum:
                    - AUTO
                    - EN
                    - ES
                    - AR
                    - PT
                    - ID
                    - JA
                    - RU
                    - HI
                    - FR
                    - DE
                    - VI
                    - TR
                    - PL
                    - IT
                    - KO
                    - ZH-CN
                    - ZH-TW
                job_mode:
                  type: string
                  description: >-
                    Job mode. Possible values are:

                    - `AUTO`: Powerdrill automatically detects your intent and
                    selects the appropriate mode for data analysis or
                    information retrieval.

                    - `DATA_ANALYSIS`: Powerdrill focuses solely on data
                    analysis.


                    If not specified, the session's `job_mode` setting will be
                    used.
                  enum:
                    - AUTO
                    - DATA_ANALYTICS
                  default: AUTO
                user_id:
                  type: string
                  description: >-
                    Your user ID, which uniquely identifies you within your
                    team. To obtain your ID:


                    - If you're the team admin, refer to [Check user
                    information](/enterprise/users#check-user-information).

                    - If you're a system or virtual user, ask your team admin to
                    check your user ID by referring to [Check user
                    information](/enterprise/users#check-user-information).
                custom_options:
                  type: object
                  properties:
                    user_prompt:
                      type: string
                      description: The prompt you set to replace the system prompt.
                    with_citation:
                      type: boolean
                      description: >-
                        Whether to include references and citations in the
                        response: true (default) to enable, false to disable.
                  description: A list of optional settings.
              required:
                - question
                - session_id
                - user_id
            example:
              session_id: cxxdgegeegeg3433fff
              user_id: tmm-dafasdfasdfasdf
              stream: true
              question: Hello World
              dataset_id: cm1gjmg8e0057r3x22v1fdu8m
              datasource_ids:
                - cm1gjmmoo0001h0x24uk1xgu9
              output_language: AUTO
              job_mode: AUTO
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    description: >-
                      Status code. **0** indicates that the operation is
                      successful. Otherwise, the operation fails. For error
                      troubleshooting, refer to [Error
                      Codes](/api-reference/error-codes).
                  data:
                    type: object
                    properties:
                      job_id:
                        type: string
                        description: >-
                          The job ID, which uniquely identifies the job in the
                          session.
                      blocks:
                        type: array
                        items:
                          $ref: '#/components/schemas/BlockDTO'
                          description: >-
                            A list of content blocks that make up the entire
                            answer.
                        description: >-
                          A list of answer blocks that make up the entire
                          answer.
                    required:
                      - job_id
                      - blocks
                    description: A job object.
                required:
                  - data
                  - code
              example:
                code: 0
                data:
                  job_id: job-cm3ikdeuj02zk01l1yeuirt77
                  blocks:
                    - type: CODE
                      content: |-
                        ```python

                        import pandas as pd

                        def invoke(input_0: pd.DataFrame) -> pd.DataFrame:
                            '''
                            input_0: pd.DataFrame  makeovermonday-a-century-of-global-deaths-from-disasters_decadal-deaths-disasters-type.csv
                            '''
                            # Group by 'Year' and sum the deaths for each type of disaster
                            aggregated_data = input_0.groupby('Year').sum().reset_index()
                            
                            # Select only the columns related to deaths
                            death_columns = [
                                'Deaths - Drought (decadal)', 'Deaths - Flood (decadal)', 
                                'Deaths - Earthquake (decadal)', 'Deaths - Extreme weather (decadal)', 
                                'Deaths - Extreme temperature (decadal)', 'Deaths - Volcanic activity (decadal)', 
                                'Deaths - Wildfire (decadal)', 'Deaths - Glacial lake outburst flood (decadal)', 
                                'Deaths - Dry mass movement (decadal)', 'Deaths - Wet mass movement (decadal)', 
                                'Deaths - Fog (decadal)'
                            ]
                            
                            # Create a new DataFrame with the aggregated results
                            output = aggregated_data[['Year'] + death_columns]
                            
                            # Rename columns to be more descriptive
                            output.columns = ['Decade'] + [col.replace('Deaths - ', '').replace(' (decadal)', '') for col in death_columns]
                            
                            return output

                        ```
                      group_id: 33063572-6e88-4912-8e2d-4166bcc8caee
                      group_name: >-
                        Analyze the dataset to observe the trend of deaths
                        caused by different types of natural disasters over the
                        past century. This involves aggregating the data by
                        decade and calculating the total number of deaths for
                        each type of disaster to identify any changes in trends.
                      stage: Analyze
                    - type: TABLE
                      content:
                        url: >-
                          https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/e24b6a5f-fdb8-48ca-ae35-dc91ac8e8ef7.csv
                        name: trend_data.csv
                        expires_at: '2024-11-21T09:56:34.290544Z'
                      group_id: 33063572-6e88-4912-8e2d-4166bcc8caee
                      group_name: >-
                        Analyze the dataset to observe the trend of deaths
                        caused by different types of natural disasters over the
                        past century. This involves aggregating the data by
                        decade and calculating the total number of deaths for
                        each type of disaster to identify any changes in trends.
                      stage: Analyze
                    - type: IMAGE
                      content:
                        url: >-
                          https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/81b75a33-a223-4954-9680-9f397872c8ad.png
                        name: >-
                          Trend of Deaths from Natural Disasters Over the
                          Century
                        expires_at: '2024-11-21T09:56:34.290544Z'
                      group_id: 7501680b-5879-441b-bd96-f58b1029ae17
                      group_name: >-
                        Visualize the trend data to show how the number of
                        deaths from different types of natural disasters has
                        changed over the past century. Use line charts to
                        represent the trends for each disaster type, which will
                        help in understanding the impact of measures and
                        technological advancements on reducing deaths.
                      stage: Analyze
                    - type: MESSAGE
                      content: >+


                        `Analyzing Conclusions` 


                        ### Analysis of Trends in the Number of Deaths from
                        Natural Disasters 


                        #### Data Analysis

                      group_id: b842aca7-6fd5-4190-85fa-97085e473877
                      group_name: Conclusions
                      stage: Respond
                    - type: TABLE
                      content:
                        url: >-
                          https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/e24b6a5f-fdb8-48ca-ae35-dc91ac8e8ef7.csv
                        name: trend_data.csv
                        expires_at: '2024-11-21T09:56:34.290544Z'
                      group_id: b842aca7-6fd5-4190-85fa-97085e473877
                      group_name: Conclusions
                      stage: Respond
                    - type: MESSAGE
                      content: >+


                        - **Droughts and Floods**: In the early 20th century,
                        droughts and floods caused extremely high death tolls,
                        particularly during the 1920s and 1930s.

                        - **Earthquakes and Extreme Weather**: Earthquakes and
                        extreme weather also led to significant death tolls
                        throughout the century, especially in the 1970s and
                        1990s.

                        - **Extreme Temperatures and Volcanic Activity**: These
                        disasters had relatively lower death tolls, but in
                        certain decades, such as the 2000s, deaths caused by
                        extreme temperatures increased.


                        #### Trend Visualization

                      group_id: b842aca7-6fd5-4190-85fa-97085e473877
                      group_name: Conclusions
                      stage: Respond
                    - type: IMAGE
                      content:
                        url: >-
                          https://static.powerdrill.ai/tmp_datasource_cache/code_result/cm37bchx106e301l1v9yf67yc/81b75a33-a223-4954-9680-9f397872c8ad.png
                        name: >-
                          Trend of Deaths from Natural Disasters Over the
                          Century
                        expires_at: '2024-11-21T09:56:34.290544Z'
                      group_id: b842aca7-6fd5-4190-85fa-97085e473877
                      group_name: Conclusions
                      stage: Respond
                    - type: MESSAGE
                      content: >-


                        - **Overall Trend**: The chart shows that although
                        certain decades experienced spikes in death tolls caused
                        by natural disasters, the overall trend is declining.

                        - **Impact of Technology and Measures**: Over time,
                        advancements in technology and the implementation of
                        disaster prevention measures are likely key factors in
                        reducing death tolls.


                        #### Conclusions and Insights

                        - **Technological Advancements**: Modern technological
                        progress, such as improved early warning systems and
                        better construction techniques, may have reduced the
                        fatalities caused by earthquakes and extreme weather.

                        - **Disaster Prevention Measures**: The enhancement of
                        disaster prevention measures and emergency response
                        capabilities on a global scale has likely contributed to
                        the decreased fatality rates of natural disasters.
                      group_id: b842aca7-6fd5-4190-85fa-97085e473877
                      group_name: Conclusions
                      stage: Respond
                    - type: SOURCES
                      content:
                        - source: >-
                            makeovermonday-a-century-of-global-deaths-from-disasters_decadal-deaths-disasters-type.csv
                          datasource_id: clxin6l9200oo01l1457bolx3
                          dataset_id: clxin6l8400ok01l1ff2m0s25
                          file_type: csv
                      group_id: ''
                      group_name: ''
                      stage: Respond
                    - type: QUESTIONS
                      content:
                        - >-
                          Analyze the trends in death tolls from different types
                          of natural disasters over the past century and explore
                          which disaster types have shown the most significant
                          reduction in fatalities.
                        - >-
                          Study the technological advancements and measures in
                          responding to natural disasters across different
                          regions globally, and analyze how these differences
                          have influenced changes in death tolls in each region.
                        - >-
                          Explore how future technological advancements and
                          policy measures could further reduce fatalities caused
                          by natural disasters, and assess their feasibility and
                          potential impacts.
                      group_id: '-1'
                      stage: Respond
          headers:
            x-pd-trace-id:
              example: ''
              required: true
              description: >-
                The trace ID returned by Powerdrill. If a failure occurs, you
                can provide it to the Powerdrill team to assist with
                troubleshooting.
              schema:
                type: string
        '400':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 210021
                msg: Job quota exceeded
          headers: {}
        '403':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 1003
                msg: insufficient.authentication
          headers: {}
        '500':
          description: ''
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                code: 210020
                msg: Something went wrong during job execution. Please try again.
          headers: {}
      deprecated: false
      security:
        - apikey-header-x-pd-api-key: []
components:
  schemas:
    BlockDTO:
      type: object
      properties:
        type:
          type: string
          description: >-
            The content type of the answer block. Possible values are:

            - `MESSAGE`: The content is a piece of text.

            - `CODE`: The content a code snippet.

            - `TABLE`: The content represents a table, consisting of:
                - `name`: The `.csv` file name.
                - `url`: The S3 key or URL to the file.
                - `expires_at`: The expiration time for `url`. To save the table for future use, make sure to download it before it expires.
            - `IMAGE`: The content represents an image, consisting of:
                - `name`: The image name.
                - `url`: The S3 key or URL to the image.
                - `expires_at`: The expiration time for `url`. To save the image for future use, make sure to download it before it expires.
            - `SOURCES`: The content represents a reference source of the answer
            block, including:
                - `id`: The ID of the source.
                - `content`: The chunk content.
                - `page_no`: The location of the chunk in the source file.

                - `source`: The file name of the data source.

                - `datasource_id`: The ID of the data source.

                - `dataset_id`: The ID of the dataset.

                - `file_type`: The name extension of the data source file.

            - `QUESTIONS`: Suggested questions generated by Powerdrill to help
            guide your follow-up exploration of the data.

            - `CHART_INFO`: The content is a generated chart or graph.


            - When the block content type is `CHART_INFO`:

                The content is a generated chart, including:

                - `code`: The code executed to generate the chart.

                - `code_type`: The code language, which is fixed to `PYTHON`.

                - `name`: The name of the **.csv** analysis result file on which the chart is based.

                - `url`: The URL of the **.csv** analysis result file.

                - `image`: The static image of the chart.

                - `options`: [Available chart types](https://pyecharts.org/#/en-us/) you can select.

                - `columns`: The column headers from the **.csv** analysis result file.

                - `chart_config`: A JSON string containing configuration settings for rendering the chart (details at [pyecharts.org](https://pyecharts.org/#/en-us/)).

                - `expires_at`: The expiration timestamp for the `url`. Make sure to download the file before it expires to retain access.
          enum:
            - MESSAGE
            - CODE
            - TABLE
            - SOURCES
            - QUESTIONS
        content:
          type: string
          description: >-
            The block content, which varies with the value of `type`:


            - When `type` is `MESSAGE`, the content is a piece of text.

            - When `type` is ` CODE`, the content a code snippet in Markdown
            format.

            - When `type` is `TABLE`, the content represents a table, consisting
            of:
                - `name`: The `.csv` file name.
                - `url`: The S3 key or URL to the file.
                - `expires_at`: The expiration time for `url`. To save the table for future use, make sure to download it before it expires.
            - When `type` is `IMAGE`, the content represents an image,
            consisting of:
                - `name`: The image name.
                - `url`: The S3 key or URL to the image.
                - `expires_at`: The expiration time for `url`. 
                
                To save the image for future use, make sure to download it before it expires.

            - When `type` is `SOURCE`, the content represents a reference source
            of the answer block, including:
                - `source`: The file name of the data source.
                - `datasource_id`: The ID of the data source.
                - `dataset_id`: The ID of the dataset.
                - `file_type`: The name extension of the data source file.

            - When `type` is `QUESTIONS`, the content is suggested questions
            generated by Powerdrill to help guide your follow-up exploration of
            the data.
        group_id:
          type: string
          description: The ID of the group containing the answer block.
        group_name:
          type: string
          description: The name of the group containing the answer block.
        stage:
          type: string
          enum:
            - Analyze
            - Respond
          description: >-
            There are two phases when Powerdrill generates an answer: `Analyze`
            and `Respond`. Answer blocks in the `Analyze` phase are not part of
            the final answer; they represent the output of the analysis process
            and are used to help you understand how the answer is generated.
            Answer blocks in the `Respond` phase are the final answer generated
            by Powerdrill in response to your question.
      required:
        - type
        - content
        - group_id
        - group_name
        - stage
  securitySchemes:
    apikey-header-x-pd-api-key:
      type: apiKey
      in: header
      name: x-pd-api-key

````