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

# 异步转换 — 提交任务

> 提交 PDF 转 Office 任务并立即获取 task_id

该接口会立即返回 `task_id`，PDF 解析和 Office 转换在后台继续执行。

1. 调用当前接口提交 PDF。
2. 保存响应中的 `task_id`。
3. 使用 `task_id` 调用[异步结果查询](/api-reference/endpoint/pdf2office-async-check)。
4. 建议每隔 **3\~5 秒**查询一次，直到状态变为 `succeeded` 或 `failed`。

`target_type` 和 `layout_mode` 的取值规则与[同步转换](/api-reference/endpoint/pdf2office-sync)相同。

<Note>
  任务提交成功时，初始状态通常为 `parsing`。提交接口不会直接返回 Office 文件下载地址。
</Note>


## OpenAPI

````yaml POST /pdf2office/async
openapi: 3.0.3
info:
  title: SoMark 文档智能 API
  description: SoMark 文档智能 API，支持 PDF、图片、Word、PPT 和 Excel 文件解析，以及 PDF 转 Word/PPT。
  version: 1.0.0
servers:
  - url: https://somark.cn/api/v1
security: []
paths:
  /pdf2office/async:
    post:
      summary: PDF 转 Office — 提交异步任务
      description: 提交 PDF 转 Office 任务并立即返回 task_id。解析和转换在后台执行。
      operationId: pdf2officeAsyncSubmit
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Pdf2OfficeSubmitRequest'
      responses:
        '202':
          description: 任务提交成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Pdf2OfficeResponse'
      x-codeSamples:
        - lang: python
          label: Python
          source: |-
            import requests

            url = "https://somark.cn/api/v1/pdf2office/async"

            data = {
                "api_key": "sk-***",
                "target_type": "ppt",
                "layout_mode": "layout",
            }

            with open("example.pdf", "rb") as file:
                response = requests.post(url, data=data, files={"file": file})

            result = response.json()
            print(result["data"]["task_id"])
        - lang: bash
          label: cURL
          source: |-
            curl -X POST https://somark.cn/api/v1/pdf2office/async \
              -F "file=@example.pdf" \
              -F "api_key=sk-***" \
              -F "target_type=ppt" \
              -F "layout_mode=layout"
components:
  schemas:
    Pdf2OfficeSubmitRequest:
      type: object
      required:
        - api_key
      properties:
        file:
          type: string
          format: binary
          description: PDF 文件，与 file_url 二选一；最大 200MB、300 页
        file_url:
          type: string
          format: uri
          description: PDF 的公开或有效预签名下载链接，与 file 二选一
        api_key:
          type: string
          description: API 密钥，格式 sk-***
          example: sk-***
        target_type:
          type: string
          enum:
            - word
            - ppt
          default: word
          description: >-
            目标文件类型。请根据 PDF 的原始文件类型选择：由 Word 导出的 PDF 选择 word，由 PPT 导出的 PDF 选择
            ppt。选择错误可能影响内容结构和版式还原效果
        layout_mode:
          type: string
          nullable: true
          enum:
            - flow
            - layout
          description: 排版模式。Word 未传时默认 flow；PPT 未传时默认 layout，且 PPT 仅支持 layout
    Pdf2OfficeResponse:
      type: object
      properties:
        code:
          type: integer
          description: 状态码，0 为成功，非 0 见错误码说明
          example: 0
        message:
          type: string
          example: 查询成功
        data:
          type: object
          properties:
            task_id:
              type: string
              description: 任务 ID
              example: c5e6c983f28a4e6eb5d6c061343a8642
            status:
              type: string
              description: 任务状态
              enum:
                - parsing
                - queued
                - converting
                - succeeded
                - failed
              example: succeeded
            target_type:
              type: string
              enum:
                - word
                - ppt
              example: word
            layout_mode:
              type: string
              enum:
                - flow
                - layout
              example: flow
            file_name:
              type: string
              description: 原始 PDF 文件名
              example: document.pdf
            page_num:
              type: integer
              description: PDF 页数
              example: 12
            result_file_name:
              type: string
              nullable: true
              description: 转换结果文件名
              example: document.docx
            error_code:
              type: integer
              nullable: true
              description: 任务失败错误码，成功时为 null
              example: null
            error_message:
              type: string
              nullable: true
              description: 任务失败原因，成功时为 null
              example: null
            created_at:
              type: string
              nullable: true
              description: 任务创建时间，ISO 8601 格式
            started_at:
              type: string
              nullable: true
              description: 转换开始时间，ISO 8601 格式
            finished_at:
              type: string
              nullable: true
              description: 任务完成时间，ISO 8601 格式
            download_url:
              type: string
              format: uri
              description: 结果文件的短期签名下载地址，仅 succeeded 状态返回
              example: https://example.com/result.docx?signature=***
            expires_in:
              type: integer
              description: download_url 有效期，单位为秒
              example: 1800
      example:
        code: 0
        message: 查询成功
        data:
          task_id: c5e6c983f28a4e6eb5d6c061343a8642
          status: succeeded
          target_type: word
          layout_mode: flow
          file_name: document.pdf
          page_num: 12
          result_file_name: document.docx
          error_code: null
          error_message: null
          created_at: '2026-08-24T10:00:00'
          started_at: '2026-08-24T10:00:10'
          finished_at: '2026-08-24T10:01:20'
          download_url: https://example.com/result.docx?signature=***
          expires_in: 1800

````