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

# Get or create a preview

> Returns a PDF preview of the current version of the specified file, creating it if it does not exist yet.
            
The 202 response has two shapes:
- Preview already exists: 'downloadUrl' contains a presigned URL to the PDF preview and 'expiry' is its expiry time.
  The URL is valid for 1 day.
- Preview does not exist yet: a conversion is requested and processed asynchronously; 'downloadUrl' and 'expiry' are null.
  Poll the 'Location' header (GetPreviewById) until it returns 200.
            
The preview is always generated as a PDF, regardless of the source file type.
Previews are keyed by document version, so uploading a new version of the file produces a new preview.



## OpenAPI

````yaml /openapi.json post /matters/{matterId}/documents/files/{fileId}/preview
openapi: 3.0.1
info:
  title: API
  version: '1.0'
servers:
  - url: https://api.smokeball.com
  - url: https://api.smokeball.com.au
  - url: https://api.smokeball.co.uk
  - url: https://stagingapi.smokeball.com
  - url: https://stagingapi.smokeball.com.au
  - url: https://stagingapi.smokeball.co.uk
security:
  - api-key: []
    token: []
paths:
  /matters/{matterId}/documents/files/{fileId}/preview:
    post:
      tags:
        - Files
      summary: Get or create a preview
      description: "Returns a PDF preview of the current version of the specified file, creating it if it does not exist yet.\r\n            \r\nThe 202 response has two shapes:\r\n- Preview already exists: 'downloadUrl' contains a presigned URL to the PDF preview and 'expiry' is its expiry time.\r\n  The URL is valid for 1 day.\r\n- Preview does not exist yet: a conversion is requested and processed asynchronously; 'downloadUrl' and 'expiry' are null.\r\n  Poll the 'Location' header (GetPreviewById) until it returns 200.\r\n            \r\nThe preview is always generated as a PDF, regardless of the source file type.\r\nPreviews are keyed by document version, so uploading a new version of the file produces a new preview."
      operationId: CreatePreview
      parameters:
        - name: matterId
          in: path
          description: Unique identifier of the matter to which the file belongs.
          required: true
          schema:
            type: string
        - name: fileId
          in: path
          description: Unique identifier of the file.
          required: true
          schema:
            type: string
      responses:
        '202':
          description: >-
            When the request is accepted. Returns a 'PreviewFileInfo' object,
            with 'downloadUrl' and 'expiry' populated if the preview already
            exists and null if conversion is still pending.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PreviewFileInfo'
        '400':
          description: When a supplied id is not a valid GUID.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationProblemDetails'
        '403':
          description: >-
            When the file does not belong to the authenticated account or does
            not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: When the file exists but has no uploaded version yet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
components:
  schemas:
    PreviewFileInfo:
      type: object
      properties:
        fileId:
          type: string
          description: Unique identifier of the requested file
          nullable: true
          example: b471682e-fa17-4e46-b7fe-9b2b8fdcb3c2
        documentVersionId:
          type: string
          description: >-
            Unique identifier of the document version the preview was generated
            from. Pass this to GetPreviewById.
          nullable: true
          example: 0f8fad5b-d9cb-469f-a165-70867728950e
        downloadUrl:
          type: string
          description: "Temporary presigned URL to download the PDF preview. Valid for 1 day.\r\nNull when the preview has not been generated yet (conversion is pending); poll GetPreviewById until it is available."
          nullable: true
          example: >-
            https://bucket.s3.amazonaws.com/previews/accounts/b471682e-fa17-4e46-b7fe-9b2b8fdcb3c2/documents/0f8fad5b-d9cb-469f-a165-70867728950e?X-Amz-Expires=86400&X-Amz-Signature=...
        expiry:
          type: string
          description: "Expiry date/time (UTC) after which the download link is no longer accessible.\r\nNull when the preview has not been generated yet (conversion is pending)."
          format: date-time
          nullable: true
          example: '2022-04-23T14:30:00Z'
      additionalProperties: false
    ValidationProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          nullable: true
      additionalProperties: {}
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}
  securitySchemes:
    api-key:
      type: apiKey
      name: x-api-key
      in: header
    token:
      type: apiKey
      name: Authorization
      in: header
      x-amazon-apigateway-authtype: cognito_user_pools

````