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

# Create Download Token

> Mint a short-lived token for a browser-native download.

The browser writes the response straight to disk only when it
issues the request itself, and such a request carries no custom
header — hence a credential in the URL. Fetching with ``X-User-ID``
instead works but holds the whole file in the tab.

Minting depends on the normal identity, so whatever replaces
``X-User-ID`` guards this too.

The session is resolved here only to fail early: the download is a
browser navigation, so an error there surfaces as a raw error page
rather than something the UI can show.



## OpenAPI

````yaml /versions/2.0.6dev/en/deploy/openapi.json post /workspace/files/download-token
openapi: 3.1.0
info:
  title: AgentScope
  version: 2.0.6dev
servers: []
security: []
paths:
  /workspace/files/download-token:
    post:
      tags:
        - workspace
      summary: Create Download Token
      description: |-
        Mint a short-lived token for a browser-native download.

        The browser writes the response straight to disk only when it
        issues the request itself, and such a request carries no custom
        header — hence a credential in the URL. Fetching with ``X-User-ID``
        instead works but holds the whole file in the tab.

        Minting depends on the normal identity, so whatever replaces
        ``X-User-ID`` guards this too.

        The session is resolved here only to fail early: the download is a
        browser navigation, so an error there surfaces as a raw error page
        rather than something the UI can show.
      operationId: create_download_token_workspace_files_download_token_post
      parameters:
        - name: agent_id
          in: query
          required: true
          schema:
            type: string
            title: Agent Id
        - name: session_id
          in: query
          required: true
          schema:
            type: string
            title: Session Id
        - name: path
          in: query
          required: true
          schema:
            type: string
            description: The path the token will authorize.
            title: Path
          description: The path the token will authorize.
        - name: x-user-id
          in: header
          required: true
          schema:
            type: string
            description: >-
              Caller's user ID. Temporary header-based identity; will be
              replaced by JWT auth.
            title: X-User-Id
          description: >-
            Caller's user ID. Temporary header-based identity; will be replaced
            by JWT auth.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DownloadTokenResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DownloadTokenResponse:
      properties:
        token:
          type: string
          title: Token
          description: >-
            Pass as the ``token`` query parameter of ``GET /workspace/files``,
            in place of the ``X-User-ID`` header. Valid for this path only.
        expires_at:
          type: number
          title: Expires At
          description: Unix timestamp after which the token is refused.
      type: object
      required:
        - token
        - expires_at
      title: DownloadTokenResponse
      description: A capability authorizing one download of one path.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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

````