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

# Export the filesystem changes to a presigned URL

> Archives everything the sandbox changed on top of its base image and streams it, uncompressed, to a presigned S3 PUT URL. The memory of the sandbox is not archived.
The sandbox is quiesced first: the process list is saved (unless saveProcesses is false), every process is stopped, and the API then refuses the calls that would write to the filesystem. The freeze is not lifted afterwards, since an exported sandbox is meant to be restored elsewhere; call POST /archive/resume to lift it.
A sandbox still frozen by an earlier export is exported as it is, with the process list that export saved.
Use dryRun to get the archive's content and exact size without stopping anything and without uploading.
Set async to start the export and answer immediately, which is what archiving a large filesystem needs: the export then reports itself through GET /archive/status.



## OpenAPI

````yaml /reference/sandbox-api/openapi.json post /archive/export
openapi: 3.0.0
info:
  description: API for manipulating filesystem, processes and network.
  title: Sandbox API
  contact: {}
  version: 0.0.1
servers:
  - url: https://{sandbox_host}
    description: >-
      Host from the sandbox's returned url, without the scheme or trailing
      slash.
    variables:
      sandbox_host:
        default: sandbox.example.com
security:
  - BearerAuth: []
paths:
  /archive/export:
    post:
      tags:
        - archive
      summary: Export the filesystem changes to a presigned URL
      description: >-
        Archives everything the sandbox changed on top of its base image and
        streams it, uncompressed, to a presigned S3 PUT URL. The memory of the
        sandbox is not archived.

        The sandbox is quiesced first: the process list is saved (unless
        saveProcesses is false), every process is stopped, and the API then
        refuses the calls that would write to the filesystem. The freeze is not
        lifted afterwards, since an exported sandbox is meant to be restored
        elsewhere; call POST /archive/resume to lift it.

        A sandbox still frozen by an earlier export is exported as it is, with
        the process list that export saved.

        Use dryRun to get the archive's content and exact size without stopping
        anything and without uploading.

        Set async to start the export and answer immediately, which is what
        archiving a large filesystem needs: the export then reports itself
        through GET /archive/status.
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExportOptions'
        description: Export options
        required: true
      responses:
        '200':
          description: Export result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExportResult'
        '202':
          description: The export was started and runs in the background
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExportProgress'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: >-
            An export is already in progress, or the sandbox is frozen for a
            restore
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Export failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ExportOptions:
      type: object
      properties:
        async:
          description: >-
            Async starts the export and answers immediately, leaving it to run:
            an

            archive of a large filesystem takes longer than a request may be
            held

            open. Its progress is reported by /archive/status.
          type: boolean
          example: false
        dryRun:
          description: |-
            DryRun reports what would be archived, and its exact size, without
            stopping anything and without uploading.
          type: boolean
          example: false
        excludes:
          description: Excludes are added to the paths excluded by default.
          type: array
          items:
            type: string
        headers:
          description: >-
            Headers are sent with the upload request as given. A presigned URL
            only

            accepts the headers it was signed for, so these have to match what
            the

            caller signed: sending one that was not signed, or signing one that
            is not

            sent, is rejected as a signature mismatch. Typical use is a storage
            class,

            x-amz-storage-class: GLACIER_IR.
          type: object
          additionalProperties:
            type: string
        imageDevice:
          description: >-
            ImageDevice is the device holding the pristine image. It is found on
            its

            own, wherever the sandbox booted from attached it, and naming one
            here

            only overrides that.
          type: string
          example: /dev/vda
        imageMountPoint:
          description: >-
            ImageMountPoint is a directory where the pristine image is already
            mounted.

            When set the image device is neither mounted nor unmounted.
          type: string
          example: /mnt/lower
        multipart:
          description: >-
            Multipart uploads the archive part by part instead, which is how an

            archive larger than the 5 GB a single PUT accepts is stored. It
            takes

            precedence over URL.
          allOf:
            - $ref: '#/components/schemas/MultipartUpload'
        saveProcesses:
          description: |-
            SaveProcesses stores the process list in the archive so restore can
            relaunch the workload. Defaults to true; set it to false to archive
            storage only.
          type: boolean
          example: true
        stopTimeoutSeconds:
          description: StopTimeoutSeconds bounds the graceful stop of each process.
          type: integer
          example: 30
        url:
          description: >-
            URL is a presigned S3 PUT URL the archive is streamed to. Empty is
            only

            valid with DryRun, or with Multipart.
          type: string
          example: https://bucket.s3.amazonaws.com/key?...
    ExportResult:
      type: object
      required:
        - manifest
      properties:
        changes:
          description: |-
            Changes lists every path in the archive. Only filled for a dry run,
            where it is the point of the call.
          type: array
          items:
            $ref: '#/components/schemas/archive.Change'
        duration:
          type: string
          example: 4.2s
        manifest:
          $ref: '#/components/schemas/ArchiveManifest'
        size:
          description: |-
            Size is the exact number of bytes uploaded, known before the upload
            starts since the archive is not compressed.
          type: integer
          example: 3074211
        stoppedProcesses:
          description: StoppedProcesses are the processes stopped to freeze the filesystem.
          type: array
          items:
            type: string
        uploaded:
          description: Uploaded is false for a dry run.
          type: boolean
          example: true
    ExportProgress:
      type: object
      properties:
        error:
          description: Error is why the export failed, without the presigned URL it used.
          type: string
        finishedAt:
          type: string
        size:
          description: >-
            Size is the archive's exact size, known once the filesystem is
            scanned.
          type: integer
          example: 3074211
        startedAt:
          type: string
        state:
          allOf:
            - $ref: '#/components/schemas/archive.ExportState'
          example: running
        uploaded:
          description: Uploaded reports whether the storage holds the archive.
          type: boolean
          example: false
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Error message
    MultipartUpload:
      type: object
      properties:
        abortUrl:
          description: >-
            AbortURL is a presigned DELETE URL that discards the parts already

            uploaded. Without it a failed export leaves them on the storage
            until a

            lifecycle rule removes them.
          type: string
        completeUrl:
          description: CompleteURL is a presigned POST URL that assembles the parts.
          type: string
        partSize:
          description: PartSize is the number of bytes sent to every part but the last.
          type: integer
          example: 536870912
        partUrls:
          description: >-
            PartURLs are presigned PUT URLs, one per part, in order. Extra ones
            are

            left unused.
          type: array
          items:
            type: string
    archive.Change:
      type: object
      required:
        - kind
        - path
      properties:
        kind:
          allOf:
            - $ref: '#/components/schemas/archive.ChangeKind'
          example: added
        path:
          description: Path is relative to the root, without a leading slash.
          type: string
          example: usr/bin/curl
        size:
          description: >-
            Size is the file content size in bytes, 0 for anything but a regular
            file.
          type: integer
          example: 256216
    ArchiveManifest:
      type: object
      required:
        - createdAt
        - root
        - version
      properties:
        added:
          description: Added and Modified count the archive's payload members.
          type: integer
          example: 11
        apiVersion:
          description: APIVersion is the sandbox-api build that produced the archive.
          type: string
          example: v0.1.0
        createdAt:
          type: string
        deleted:
          description: >-
            Deleted are paths the image has and the sandbox deleted. Tar cannot
            carry

            a deletion, so import applies these from the manifest.
          type: array
          items:
            type: string
        excludes:
          description: Excludes are the paths left out of the comparison.
          type: array
          items:
            type: string
        imageDevice:
          description: >-
            ImageDevice is the device the pristine image was read from, for the
            record:

            it says where the sandbox that exported the archive found its image.
          type: string
          example: /dev/vda
        modified:
          type: integer
          example: 3
        payloadBytes:
          description: PayloadBytes is the total content size of the payload members.
          type: integer
          example: 3073449
        processes:
          description: Processes tells whether ProcessesName is present.
          type: boolean
          example: true
        root:
          description: Root is the directory the paths are relative to.
          type: string
          example: /
        version:
          type: integer
          example: 1
    archive.ExportState:
      type: string
      enum:
        - running
        - succeeded
        - failed
      x-enum-varnames:
        - ExportRunning
        - ExportSucceeded
        - ExportFailed
    archive.ChangeKind:
      type: string
      enum:
        - added
        - modified
        - deleted
      x-enum-varnames:
        - ChangeAdded
        - ChangeModified
        - ChangeDeleted
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Sandbox access token created through POST /v1/token.

````