Skip to content

File Operations Methods

This page presents the main API methods for working with files in the Brainysoft system: upload, retrieve, edit, delete, batch operations, as well as linking files to various entities (clients, contracts, leads, loan applications) and public file uploads.

File API Methods

MethodURLDescription
POSTapi/filesUpload file
GET|HEADapi/filesList all files
POSTapi/files/entities/clients/{id}
api/files/entities/contracts/{id}
api/files/entities/leads/{id}
api/files/entities/loan-apps/{id}
Upload client/contract/lead/loan application file
GET|HEADapi/files/entities/clients/{id}
api/files/entities/contracts/{id}
api/files/entities/leads/{id}
api/files/entities/loan-apps/{id}
Get client/contract/lead/loan application files
GET|HEADapi/files/{file}Get file information by ID
PUT|PATCHapi/files/{file}Edit file data
DELETEapi/files/{file}Delete file
GET|HEADapi/files/{file}/linksGet file link
GET|HEADapi/files/{file}/link-verified-copyGet verified file link
POSTapi/files/batch/linksGet links for a group of files (by ID)
POSTapi/files/batch/selectGet information for a group of files
GET|HEADapi/files/public-uploaderPublic file upload

Upload File

POST /api/files

Description

This method allows uploading a new file to the system. The file is sent in the request body in multipart/form-data format.

Request Parameters (query string)

ParameterTypeRequiredDescription
leadintegerChoose one of the entitiesLead ID
clientintegerChoose one of the entitiesClient ID
loanappintegerChoose one of the entitiesLoan application ID
contractintegerChoose one of the entitiesContract ID
collateralintegerChoose one of the entitiesCollateral ID
sharecontractintegerChoose one of the entitiesShare contract ID
depositcontractintegerChoose one of the entitiesDeposit contract ID
fundtransactionintegerChoose one of the entitiesFund transaction ID
tagsinteger✅ Always requiredTag ID

:::note Important:

  • The tags parameter is required for all requests
  • At least one of the following parameters must be specified: lead, client, loanapp, contract, collateral, sharecontract, depositcontract, or fundtransaction :::

Request Body (form-data)

FieldTypeDescription
filefileFile to upload (e.g., .pdf, .jpg, .png, .gif)

Request Example

POST /api/files?client=3168&tags=5

Content-Type: multipart/form-data

file: image.png

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750694475000, // Response time (UNIX timestamp, ms)
  "data": {
    "id": 235 // Unique file identifier
  }
}

List All Files

GET /api/files

Description

This method returns a list of files with detailed information about each file.

Request Example

GET /api/files

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750675264000, // Response time (UNIX timestamp, ms)
  "data": [
    {
      "id": 234, // Unique file identifier
      "name": "images.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/234/2e276a16b5219e4e06a5c8070d9a1a0784737062146ad1931633c17d0d7cf736fde4791182d5bd6b65e249c512a5f87e4887f3e935c40c59a7a79da42ed5c224", // File preview/thumbnail URL
      "userId": 1357, // ID of user who uploaded the file
      "connections": {
        "lead": null, // Lead ID
        "client": 3168, // Client ID
        "loanapp": null, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      },
      "createdAt": "2025-06-23T07:36:41+0000", // File upload date and time (ISO 8601)
      "tags": [
        // List of tag identifiers
        "2"
      ],
      "size": 3789, // File size in bytes
      "sizeForHumans": "4 Kb", // Human-readable file size
      "ocr": null // OCR recognition result
    }
  ]
}

Upload Client/Contract/Lead/Loan Application File

POST /api/files/entities/clients/{id} - Upload client file

POST /api/files/entities/contracts/{id} - Upload contract file

POST /api/files/entities/leads/{id} - Upload lead file

POST /api/files/entities/loan-apps/{id} - Upload loan application file

Description

These methods allow uploading a file and immediately linking it to a specific entity: client, contract, lead, or loan application. The file is sent in the request body in multipart/form-data format.

Request Parameters

{id} (integer, required) — unique identifier of the corresponding entity (client, contract, lead, or loan application).

Request Parameters (query string)

ParameterTypeDescription
tagsintegerTag identifier associated with the file

Request Body (form-data)

FieldTypeDescription
filefileFile to upload (e.g., .pdf, .jpg, .png, .gif)

Request Example

POST /api/files/entities/clients/3168?tags=8

Content-Type: multipart/form-data

file: image.png

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750696263000, // Response time (UNIX timestamp, ms)
  "data": {
    "id": 237 // Unique file identifier
  }
}

Get Client/Contract/Lead/Loan Application Files

GET /api/files/entities/clients/{id} - Get client file

GET /api/files/entities/contracts/{id} - Get contract file

GET /api/files/entities/leads/{id} - Get lead file

GET /api/files/entities/loan-apps/{id} - Get loan application file

Description

These methods allow retrieving a list of all files associated with a specific entity: client, contract, lead, or loan application. The response returns an array of file objects with detailed information about each of them.

Request Parameters

{id} (integer, required) — unique identifier of the corresponding entity (client, contract, lead, or loan application).

Request Example

GET /api/files/entities/clients/3168

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750697332000, // Response time (UNIX timestamp, ms)
  "data": [
    {
      "id": 223, // Unique file identifier
      "name": "default_logo.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/223/7a8a2e2296fadf0ea97c701f6edd2d5278ebf278ec2f87520e77687a89f2d59a003a94dd6f84094a682a5f2c3a44c8fd64bbb8f2b2b81098e654687f72f20e06", // File preview/thumbnail URL
      "userId": 1165, // ID of user who uploaded the file
      "connections": {
        "lead": null, // Lead ID
        "client": 3168, // Client ID
        "loanapp": null, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      },
      "createdAt": "2025-06-16T14:40:54+0000", // File upload date and time (ISO 8601)
      "tags": [
        // List of tag identifiers
        "14"
      ],
      "size": 6005, // File size in bytes
      "sizeForHumans": "6 Kb", // Human-readable file size
      "ocr": null // OCR recognition result
    },
    {
      "id": 234, // Unique file identifier
      "name": "images.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/234/2e276a16b5219e4e06a5c8070d9a1a0784737062146ad1931633c17d0d7cf736fde4791182d5bd6b65e249c512a5f87e4887f3e935c40c59a7a79da42ed5c224", // File preview/thumbnail URL
      "userId": 1357, // ID of user who uploaded the file
      "connections": {
        "lead": null, // Lead ID
        "client": 3168, // Client ID
        "loanapp": null, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      }
    }
  ]
}

Get File Information by ID

GET /api/files/{file}

Description

This method allows retrieving detailed information about a specific file by its identifier.

Request Parameters

{file} (integer, required) — unique file identifier.

Request Example

GET /api/files/233

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750186181000, // Response time (UNIX timestamp, ms)
  "data": [
    {
      "id": 233, // Unique file identifier
      "name": "images.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/193/...", // File preview/thumbnail URL
      "userId": 1357, // ID of user who uploaded the file
      "connections": {
        "lead": 7315, // Lead ID
        "client": 3166, // Client ID
        "loanapp": 6755, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      },
      "createdAt": "2025-06-19T11:52:22+0000", // File upload date and time (ISO 8601)
      "tags": ["9"], // List of tag identifiers
      "size": 3789, // File size in bytes
      "sizeForHumans": "4 Kb", // Human-readable file size
      "ocr": null // OCR recognition result
    }
  ]
}

Edit File Data

PUT/PATCH /api/files/{file}

Description

This method allows updating file information (e.g., tags, name, object associations). To edit a file, you must first retrieve it using the "Get File Information by ID" method, then send a PATCH/PUT request with the required changes.

Request Parameters

{file} (integer, required) — unique file identifier.

PUT Request Example

PUT /api/files/233
Content-Type: application/json
json
{
  "id": 233, // Unique file identifier
  "name": "images.png", // File name
  "extension": "png", // File extension
  "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/193/...", // File preview/thumbnail URL
  "userId": 1357, // ID of user who uploaded the file
  "connections": {
    "lead": 7315, // Lead ID
    "client": 3166, // Client ID
    "loanapp": 6755, // Loan application ID
    "contract": null, // Contract ID
    "collateral": null, // Collateral ID
    "sharecontract": null, // Share contract ID
    "depositcontract": null, // Deposit contract ID
    "fundtransaction": null, // Fund transaction ID
    "comment": null, // Comment ID
    "collateralline": null, // Collateral line ID
    "deal": null, // Deal ID
    "extra": [] // Additional connections
  },
  "createdAt": "2025-06-19T11:52:22+0000", // File upload date and time (ISO 8601)
  "tags": ["9", "12"], // List of tag identifiers
  "size": 3789, // File size in bytes
  "sizeForHumans": "4 Kb", // Human-readable file size
  "ocr": null // OCR recognition result
}

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750186181000, // Response time (UNIX timestamp, ms)
  "data": [
    {
      "id": 233, // Unique file identifier
      "name": "images.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/193/...", // File preview/thumbnail URL
      "userId": 1357, // ID of user who uploaded the file
      "connections": {
        "lead": 7315, // Lead ID
        "client": 3166, // Client ID
        "loanapp": 6755, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      },
      "createdAt": "2025-06-19T11:52:22+0000", // File upload date and time (ISO 8601)
      "tags": ["9", "12"], // List of tag identifiers
      "size": 3789, // File size in bytes
      "sizeForHumans": "4 Kb", // Human-readable file size
      "ocr": null // OCR recognition result
    }
  ]
}

PATCH Request Example

PATCH /api/files/233
Content-Type: application/json
json
{
  "tags": ["9", "12"]
}

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750186181000, // Response time (UNIX timestamp, ms)
  "data": [
    {
      "id": 233, // Unique file identifier
      "name": "images.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://fs-stage-svc-stage.brainysoft.ru/web/files/thumb/qat1/193/...", // File preview/thumbnail URL
      "userId": 1357, // ID of user who uploaded the file
      "connections": {
        "lead": 7315, // Lead ID
        "client": 3166, // Client ID
        "loanapp": 6755, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      },
      "createdAt": "2025-06-19T11:52:22+0000", // File upload date and time (ISO 8601)
      "tags": ["9", "12"], // List of tag identifiers
      "size": 3789, // File size in bytes
      "sizeForHumans": "4 Kb", // Human-readable file size
      "ocr": null // OCR recognition result
    }
  ]
}

Delete File

DELETE /api/files/{file}

Description

This method allows deleting a file by its identifier.

Request Parameters

{file} (integer, required) — unique file identifier.

Request Example

DELETE /api/files/233

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750348133000, // Response time (UNIX timestamp, ms)
  "data": {
    "status": "deleted" // File deletion status
  }
}

GET|HEAD /api/files/{file}/links

GET|HEAD /api/files/{file}/link-verified-copy

Description

These methods allow obtaining a download link for a file by its identifier.

  • /links — returns a regular file download link.
  • /link-verified-copy — returns a download link for a verified copy of the file, if such a copy is available.

Request Parameters

{file} (integer, required) — unique file identifier.

Request Example

GET /api/files/234/links

or

GET /api/files/234/link-verified-copy

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750690491000, // Response time (UNIX timestamp, ms)
  "data": {
    "download": "https://fs-stage-svc-stage.brainysoft.ru/web/files/download?ac-jar=..." // Download link for file or verified copy
  }
}

POST /api/files/batch/links

Description

This method allows obtaining download links for multiple files by their identifiers at once. The response returns an object where the key is the file ID and the value is an object with the download link.

Request Body (application/json)

FieldTypeDescription
idsarray[int]Array of file identifiers

Request Example

json
{
  "ids": [234, 236, 237] // Array of file IDs
}

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1751285233000, // Response time (UNIX timestamp, ms)
  "data": {
    "234": {
      "download": "https://fs-stage-svc-stage.brainysoft.ru/web/files/download?..." // Download link for file with ID 234
    },
    "236": {
      "download": "https://fs-stage-svc-stage.brainysoft.ru/web/files/download?..." // Download link for file with ID 236
    },
    "237": {
      "download": "https://fs-stage-svc-stage.brainysoft.ru/web/files/download?..." // Download link for file with ID 237
    }
  }
}

Get Information for a Group of Files

POST /api/files/batch/select

Description

This method allows obtaining detailed information for multiple files by their identifiers at once. The response returns an array of file objects with a complete structure similar to the get file information by ID method.

Request Body (application/json)

FieldTypeDescription
idsarray[int]Array of file identifiers

Request Example

json
{
  "ids": [234, 236, 237] // Array of file IDs
}

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1751285601000, // Response time (UNIX timestamp, ms)
  "data": [
    {
      "id": 234, // Unique file identifier
      "name": "images.png", // File name
      "extension": "png", // File extension
      "thumbUrl": "https://...", // File preview/thumbnail URL
      "userId": 1357, // ID of user who uploaded the file
      "connections": {
        "lead": null, // Lead ID
        "client": 3168, // Client ID
        "loanapp": null, // Loan application ID
        "contract": null, // Contract ID
        "collateral": null, // Collateral ID
        "sharecontract": null, // Share contract ID
        "depositcontract": null, // Deposit contract ID
        "fundtransaction": null, // Fund transaction ID
        "comment": null, // Comment ID
        "collateralline": null, // Collateral line ID
        "deal": null, // Deal ID
        "extra": [] // Additional connections
      },
      "createdAt": "2025-06-23T07:36:41+0000", // File upload date and time (ISO 8601)
      "tags": ["2"], // List of tag identifiers
      "size": 3789, // File size in bytes
      "sizeForHumans": "4 Kb", // Human-readable file size
      "ocr": null // OCR recognition result
    }
    // ... other files
  ]
}

Public File Upload

GET|HEAD /api/files/public-uploader

Description

This method returns a unique public link (URL) that can be used to upload a file without authorization. This link can be used to provide file upload capability to external users, integrations, or third-party services.

INFO

This method is used for user uploads without using bsauth on the client side

Request Example

GET /api/files/public-uploader

Successful Response Example

json
{
  "status": "ok", // Request execution status
  "timestamp": 1750757802000, // Response time (UNIX timestamp, ms)
  "data": {
    "url": "https://fs-stage-svc-stage.brainysoft.ru/web/files/public-uploader?ac-jar=tcBASegvBz5QslUbuPx3MbxfovoWmVfYHsBMMXcO7XrUzTowK19PN1RtcyWyKcbcTkCDc6Ui18GWC1XPg8SNPv9nYSXFD0Ekp3SlNcR9ZyptHzeL975HFfTGTOEhtqOlQWIwmdullkvTOr06xJTIRNQWCjto9DS2TFe5bB46gIbGWUzeqasJz8Za6NoTHF7cmxWLUQUsujyYSnmmC6RuLQWKtI0SWucn7mignXyk3HoYqkxxdAgleNdedmzAWCXkCwZl4Fvj7jGmI4v6By4c7ZXrHib3XyFnyJXUtcBHE8ik5TnaRXVwrsdzViiYZ3VbPMd4DnQEbtdPSe4eIp6RvNZMgbjKCkyeR1qJ8ld0gQkg1oKYIXLUSfH672K8Nhb7jFEP7nqg8uCFMQRl0v0hp8o25DrAliTURhuN0ZcEydFDTpUpg6sKFqrzwTzD8qVXe24hvpdh9R3DtSjCXozmDTFIyvYo2RrXHER6pgGrsMYBmEenOWvcLJUH9279a1z6" // Public link for file upload
  }
}

Field Descriptions

FieldTypeDescription
statusstringRequest execution status
timestampintegerResponse time (UNIX timestamp, ms)
dataobject/arrayMain response data
idintegerUnique file identifier
namestringFile name
extensionstringFile extension
thumbUrlstringFile preview/thumbnail URL
userIdintegerUser identifier
connectionsobjectAssociations with system objects
leadinteger|nullLead ID
clientinteger|nullClient ID
loanappinteger|nullLoan application ID
contractinteger|nullContract ID
collateralinteger|nullCollateral ID
sharecontractinteger|nullShare contract ID
depositcontractinteger|nullDeposit contract ID
fundtransactioninteger|nullFund transaction ID
commentinteger|nullComment ID
collaterallineinteger|nullCollateral line ID
dealinteger|nullDeal ID
extraarrayAdditional connections
createdAtstringFile upload date and time (ISO 8601)
tagsarrayList of tag identifiers
sizeintegerFile size in bytes
sizeForHumansstringHuman-readable size (e.g., 4 Kb)
ocrstring|nullOCR recognition result
downloadstringFile download link
urlstringPublic link for file upload