---
title: "Create/Update a file."
method: POST
path: "/file/upsert"
tags: ["Documents|File"]
---

# Create/Update a file.

`POST /file/upsert`

This endpoint can be used to create/update files and assign them to an employee, vehicle, project, order or tool. The
file must be base64 encoded and provided in the data field. The base64 encoded file can only be up to 256 MB in size.
The object type allows you to choose whether to
associate the file with an employee or one of the other options provided. You must also provide a `tagId` or
`targetReference` to associate the document with a target. The filename must be the full filename including the
extension, for example: document.pdf. You risk corrupting the file if you do not specify the extension. You can
add a file type by specifying its id. You can see a list of available file types at the `fetch_type` endpoint.
If none is specified, the default file type is used.

## Request body

- StandardFileUpsertRequest
  - `records` object[] — The records. This Parameter is optional.
    - `keyField` string — This parameter specifies the name of the unique key used to distinctly assign each dataset in the API. | Value | Description | |-----------------|-----------------------------| | id | The internal file ID | | externalId | The external id |
    - `data` FileUpsertRequestRecordData
      - `id` integer — The file id.
      - `externalId` string — The files external id. (max. 128 characters)
      - `objectType` string — The object Type. This Parameter is required. VEHICLE, ORDER, PROJECT, TOOL or EMPLOYEE
      - `targetId` integer — Id of the object to attach the file to. This paramter is optional.
      - `targetReference` string — Reference of the object to attach the file to (Used if targetId not provided). This paramter is optional.
      - `typeId` integer — Id of the file type. This paramter is optional.
      - `typeReference` string — Reference of the file type (Used if typeId not provided). This paramter is optional.
      - `filename` string — Filename with extension. This paramter is required. (max. 255 characters)
      - `description` string — The file description. This paramter is required.
      - `date` string — Represents a date. (ISO 8601) ICU-Format: yyyy-MM-dd
      - `validTo` string — Represents a date. (ISO 8601) ICU-Format: yyyy-MM-dd
      - `data` string — The data of the file (base64 encoded). This paramter is required.
  - `dryRun` boolean — Simulate the operation. (No records will be created or changed) This Parameter is optional.

## Response `200`

Success Response:

- StandardFileUpsertResponse
  - `createdFiles` object[] — The created files.
    - `id` integer — The internal ID of the file.
    - `objectType` string — Object type of the object to which the file was added. VEHICLE, ORDER, PROJECT, TOOL or EMPLOYEE
    - `objectId` integer — The internal ID of the object to which the file was added.
  - `updatedFiles` object[] — The changed files.
    - `id` integer — The internal ID of the file.
    - `objectType` string — Object type of the object to which the file was added. VEHICLE, ORDER, PROJECT, TOOL or EMPLOYEE
    - `objectId` integer — The internal ID of the object to which the file was added.
  - `deletedFiles` object[] — The deleted files.
    - `id` integer — The internal ID of the file.
    - `objectType` string — Object type of the object to which the file was added. VEHICLE, ORDER, PROJECT, TOOL or EMPLOYEE
    - `objectId` integer — The internal ID of the object to which the file was added.

---

[API](https://skmtc.net/geocapture/apis/geocapture-api.md) · [All operations](https://skmtc.net/geocapture/apis/geocapture-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/geocapture/geocapture-api/versions/869b05603541/schema)
