---
updatedAt: 2026-04-23T07:24:55.000Z
agentTools:
  projectIndex: https://docs.oneschema.co/llms.txt
---

# Upload a custom sample file

Upload a file to serve as the downloadable sample file shown to end users in the importer's upload pane. When set, this file replaces the sample file that OneSchema otherwise auto-generates from the template's columns. Subject to a 5 MiB file size limit. Accepted extensions: `.xlsx`, `.xls`, `.xlsm`, `.xlsb`, `.csv`. Requires `multipart/form-data` with a single `file` field.

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Templates",
    "version": "1",
    "contact": {
      "name": "OneSchema Support",
      "email": "support@oneschema.co"
    },
    "license": {
      "name": "proprietary",
      "url": "https://www.oneschema.co/terms-and-conditions"
    },
    "termsOfService": "https://www.oneschema.co/terms-and-conditions",
    "description": "An API for managing OneSchema Templates."
  },
  "tags": [
    {
      "name": "Templates",
      "description": "Template operations"
    }
  ],
  "paths": {
    "/v1/templates/{key}/sample-file": {
      "post": {
        "operationId": "upload-template-sample-file",
        "summary": "Upload a custom sample file",
        "description": "Upload a file to serve as the downloadable sample file shown to end users in the importer's upload pane. When set, this file replaces the sample file that OneSchema otherwise auto-generates from the template's columns. Subject to a 5 MiB file size limit. Accepted extensions: `.xlsx`, `.xls`, `.xlsm`, `.xlsb`, `.csv`. Requires `multipart/form-data` with a single `file` field.",
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "The key of the template to attach the sample file to.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UploadTemplateSampleFileResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        },
        "tags": [
          "Templates"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/TemplateSampleFileUploadRequest"
              },
              "encoding": {
                "file": {
                  "contentType": "application/octet-stream"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "components": {
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        }
      },
      "TemplateSampleFileUploadRequest": {
        "type": "object",
        "properties": {
          "file": {
            "description": "The file that end users will download when the `includeExcelTemplate` importer customization is enabled. Must be one of `.xlsx`, `.xls`, `.xlsm`, `.xlsb`, `.csv` and at most 5 MiB.",
            "format": "binary",
            "type": "string"
          }
        },
        "required": [
          "file"
        ]
      },
      "UploadTemplateSampleFileResponse": {
        "type": "object",
        "properties": {
          "template_key": {
            "type": "string",
            "description": "The key of the template the file was attached to."
          },
          "sample_file_name": {
            "type": "string",
            "description": "The original filename of the uploaded file."
          }
        }
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-KEY"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.oneschema.co",
      "description": "Production server (hosted in the US)",
      "variables": {}
    },
    {
      "url": "https://api.eu.oneschema.co",
      "description": "Production server (hosted in the EU)",
      "variables": {}
    },
    {
      "url": "https://api.ca.oneschema.co",
      "description": "Production server (hosted in Canada)",
      "variables": {}
    },
    {
      "url": "https://api.au.oneschema.co",
      "description": "Production server (hosted in Australia)",
      "variables": {}
    }
  ],
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  }
}
```