# Create file

Creates a file resource (File, Folder, ContractDocument).
- File or ContractDocument upload: Use `Content-Type: multipart/form-data`
- Folder creation: Use `Content-Type: application/json`

Endpoint: POST /v2/files

## Request fields (multipart/form-data):

  - `file` (string, required)
    The file to be uploaded

  - `targetResourceType` (string, required)
    The type of the resource the file will be uploaded to
    Enum: "Matter", "Contract", "ContractCreation"

  - `targetResourceId` (integer)
    The id of the resource the file will be uploaded to. Required unless TargetResourceType is ContractCreation
    Example: 65436

  - `folderId` (integer)
    The parent folder id of the file. Leave null if the file is not in a folder
    Example: 32535

## Request fields (application/json):

  - `name` (string, required)
    The user defined name of the file resource
For file resources with a type of file this includes the file extension
    Example: Standard NDA.docx

  - `resource` (object, required)
    The resource where the file resource is located within

  - `resource.id` (integer)
    The system identifier for the resource
    Example: 78914

  - `resource.type` (string)
    The type of the resource
    Enum: "Contract", "Matter"

  - `folder` (object)
    The folder where the file resource is located 

Folder is null when the file resource is located at the root of the resource

  - `folder.folder` (object)
    The parent folder. 

The folder will be null when the folder is at the root of the resource

  - `folder.id` (integer)
    The system identifier for the folder
    Example: 786

## Request examples:

  - `Example of a file uploaded to create a contract` (unknown)
    **Request header**

`Content-Type: multipart/form-data; boundary=----Boundary7MA4YWxkTrZu0gW`

  - `Example of a file uploaded to a contract` (unknown)
    **Request header**

`Content-Type: multipart/form-data; boundary=----Boundary7MA4YWxkTrZu0gW`

  - `Example of a file uploaded to a matter` (unknown)
    **Request header**

`Content-Type: multipart/form-data; boundary=----Boundary7MA4YWxkTrZu0gW`

  - `Example of a file uploaded into a folder within a contract` (unknown)
    **Request header**

`Content-Type: multipart/form-data; boundary=----Boundary7MA4YWxkTrZu0gW`

  - `Example of creating a folder within a matter` (unknown)

  - `Example of creating a folder within a contract` (unknown)

  - `Example of creating a nested folder within an existing folder` (unknown)

## Response 201:

  - `201` (unknown)
    Created

## Response 201 fields (application/json):

  - `id` (integer)
    The system identifier for the file
    Example: 9456

## Response 201 headers (application/json):

  - `Location` (string)
    Relative location to retrieve the created file or folder

## Response 400:

  - `400` (unknown)
    Bad Request

## Response 400 fields (application/problem+json):

  - `detail` (string)
    More information about the problem.

  - `errors` (object)
    A dictionary of validation errors, where each key is a field api name and the value is a list of error messages.

  - `instance` (string)
    The URI of the resource which the error relates to.

  - `operationId` (string)
    A unique trace identifier for the request. This should be provided when requesting support.

  - `status` (integer)
    The HTTP status code for the problem.

  - `title` (string)
    A short description of the error.

  - `type` (string)
    A URI which can be followed to find out more about the problem.

## Response 409:

  - `409` (unknown)
    Conflict

## Response 409 fields (application/problem+json):

  - `detail` (string)
    More information about the problem.

  - `instance` (string)
    The URI of the resource which the error relates to.

  - `operationId` (string)
    A unique trace identifier for the request. This should be provided when requesting support.

  - `status` (integer)
    The HTTP status code for the problem.

  - `title` (string)
    A short description of the error.

  - `type` (string)
    A URI which can be followed to find out more about the problem.

## Response 415:

  - `415` (unknown)
    Unsupported Media Type

## Response 415 fields (application/problem+json):

  - `detail` (string)
    More information about the problem.

  - `instance` (string)
    The URI of the resource which the error relates to.

  - `operationId` (string)
    A unique trace identifier for the request. This should be provided when requesting support.

  - `status` (integer)
    The HTTP status code for the problem.

  - `title` (string)
    A short description of the error.

  - `type` (string)
    A URI which can be followed to find out more about the problem.

