# `POST /v1/workspace/domain/add` — Add files

Part of the [Bkper Managed Agent API](https://bkper.com/docs/api/managed-agent.md). Read its guide for authentication, conventions, and examples.

Write files from the user's computer into the working copy, 1 to 100 at their full paths, all or none; folders there merge. Each file is a PNG or JPEG by its bytes up to 5 MiB or UTF-8 text up to 256 KiB, written byte for byte, at most 10 MiB together; the body at most 14 MiB (413 request_too_large). 409 file_exists with `paths`, every file there not marked `replace`, so the user can be asked once; 422 file_invalid (with reason) when it cannot be written. In context what agents would not load yet is written: the listing warns of it, and Save refuses it. Nothing is published until Save; the agent sees it at once. 409 workspace_busy while Git works in the repository (the agent's, or a sync): nothing changed, try again. The user's verified domain's, for everyone in it; changes only for the domain's admin (403 workspace_forbidden), and none without a domain.

## Operation contract

```json
{
  "operationId": "addDomainContextFiles",
  "tags": [
    "Workspace"
  ],
  "summary": "Add files",
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "parameters": [],
  "description": "Write files from the user's computer into the working copy, 1 to 100 at their full paths, all or none; folders there merge. Each file is a PNG or JPEG by its bytes up to 5 MiB or UTF-8 text up to 256 KiB, written byte for byte, at most 10 MiB together; the body at most 14 MiB (413 request_too_large). 409 file_exists with `paths`, every file there not marked `replace`, so the user can be asked once; 422 file_invalid (with reason) when it cannot be written. In context what agents would not load yet is written: the listing warns of it, and Save refuses it. Nothing is published until Save; the agent sees it at once. 409 workspace_busy while Git works in the repository (the agent's, or a sync): nothing changed, try again. The user's verified domain's, for everyone in it; changes only for the domain's admin (403 workspace_forbidden), and none without a domain.",
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/AddWorkspaceFiles"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Success",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/WorkspaceChanged"
          }
        }
      }
    },
    "400": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "401": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "403": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "404": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "409": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "410": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "411": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "413": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "422": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    },
    "503": {
      "description": "Rejected; never contains credentials or upstream payloads.",
      "content": {
        "application/json": {
          "schema": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}
```

## Schemas

### AddWorkspaceFiles

```json
{
  "type": "object",
  "properties": {
    "files": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "path": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "Its full path in the repository (not relative to a folder), each once. Folders on the way are made, or merged with those there."
          },
          "content": {
            "type": "string",
            "description": "Standard base64 of the file's exact bytes, written byte for byte. A PNG or JPEG by its bytes up to 5 MiB, else UTF-8 text up to 256 KiB (422 file_invalid, reason `type` or `size`)."
          },
          "replace": {
            "description": "Replace a file there (keeping its mode). Default false: 409 file_exists with `paths`.",
            "type": "boolean"
          }
        },
        "required": [
          "path",
          "content"
        ],
        "additionalProperties": false
      },
      "description": "1 to 100 files, at most 10 MiB together."
    }
  },
  "required": [
    "files"
  ],
  "additionalProperties": false
}
```

### WorkspaceChanged

```json
{
  "type": "object",
  "properties": {
    "paths": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "What changed in the working copy, by path: a move's `from` and `to`, a delete's path, the files an add wrote, a discard put back or removed, or an undo changed."
    }
  },
  "required": [
    "paths"
  ],
  "description": "A change to the working copy: not published until Save."
}
```

### Error

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Stable code, e.g. not_found, idempotency_conflict, session_working, usage_limit_exceeded. Open."
        },
        "type": {
          "description": "Category, e.g. invalid_request_error, authentication_error, usage_limit_error. Open.",
          "type": "string"
        },
        "message": {
          "type": "string"
        },
        "host": {
          "description": "host_in_use: the host another service holds.",
          "type": "string"
        },
        "service": {
          "description": "host_in_use: the id of the service that holds the host.",
          "type": "string"
        },
        "reason": {
          "description": "file_invalid: why the change, or a picture, was refused. Open: path | text | size | skill | skills | count | type.",
          "type": "string"
        },
        "paths": {
          "description": "file_exists from an add: every path of the request where a file is and `replace` was not set, all at once, so the person can be asked once. publish_conflict: the files someone published changes to the same lines of.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "publishers": {
          "description": "publish_conflict: who published those changes, by name.",
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "code"
      ]
    }
  },
  "required": [
    "error"
  ]
}
```

## Authentication

```json
{
  "bearerAuth": {
    "type": "http",
    "scheme": "bearer"
  }
}
```
