# Upload file

Upload a file and link it to the specified Moov account.

The maximum file size is 20MB. Each account is allowed a maximum of 50 files. Acceptable file types include csv, jpg, pdf, and png.

To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/) you'll need to specify the `/accounts/{accountID}/files.write` scope.

## POST

/accounts/{accountID}/files

### Sample Requests

#### Curl

```shell
curl -X POST "https://api.moov.io/accounts/{accountID}/files" \
  -H "Authorization: Bearer {token}" \
  -H "X-Moov-Version: v2026.07.00" \
  -F "file=@/path/to/file" \
  -F "filePurpose=representative_verification" \
  -F 'metadata={}''
```

#### Go

```go
mc, _ := moov.NewClient()

var accountID string
file, _ := os.Open("/path/to/file.csv")

mc.UploadFile(ctx, accountID, moov.UploadFile{
    FilePurpose: moov.FilePurpose_MerchantUnderwriting,
    Metadata: map[string]string{
        "requirement_id": "business.underwriting-documents-tier-one",
        "other_keys":     "for customer use",
    },
    Filename: "file.csv",
    File:     file,
})
```

#### TypeScript

```typescript
import { Moov } from "@moovio/sdk";
import { openAsBlob } from "node:fs";

const moov = new Moov({
  security: {
    username: "",
    password: "",
  },
});

async function run() {
  const result = await moov.files.upload({
    accountID: "221c30bd-2551-4ae4-9a14-07bf6599b728",
    fileUploadRequestMultiPart: {
      file: await openAsBlob("example.file"),
      filePurpose: "representative_verification",
    },
  });

console.log(result);
}

run();
```

#### PHP

```php
declare(strict_types=1);

require 'vendor/autoload.php';

use Moov\\MoovPhp;
use Moov\\MoovPhp\Models\Components;

$sdk = MoovPhp\Moov::builder()
    ->setSecurity(
        new Components\Security(
            username: '',
            password: '',
        )
    )
    ->build();

$fileUploadRequestMultiPart = new Components\FileUploadRequestMultiPart(
    file: new Components\FileUploadRequestMultiPartFile(
        fileName: 'example.file',
        content: file_get_contents('example.file');,
    ),
    filePurpose: Components\FilePurpose::RepresentativeVerification,
);

$response = $sdk->files->upload(
    accountID: '51ae4a14-07bf-4659-b9b7-285439b7a22e',
    fileUploadRequestMultiPart: $fileUploadRequestMultiPart
);

if ($response->fileDetails !== null) {
    // handle response
}
```

#### Java

```java
package hello.world;

import io.moov.sdk.Moov;
import io.moov.sdk.models.components.*;
import io.moov.sdk.models.errors.FileValidationError;
import io.moov.sdk.models.errors.GenericError;
import io.moov.sdk.models.operations.UploadFileResponse;
import io.moov.sdk.utils.Utils;
import java.io.FileInputStream;
import java.lang.Exception;

public class Application {

public static void main(String[] args) throws GenericError, FileValidationError, Exception {

Moov sdk = Moov.builder()
                .security(Security.builder()
                    .username("")
                    .password("")
                    .build())
            .build();

UploadFileResponse res = sdk.files().upload()
                .accountID("51ae4a14-07bf-4659-b9b7-285439b7a22e")
                .fileUploadRequestMultiPart(FileUploadRequestMultiPart.builder()
                    .file(FileUploadRequestMultiPartFile.builder()
                        .fileName("example.file")
                        .content(Utils.readBytesAndClose(new FileInputStream("example.file")))
                        .build())
                    .filePurpose(FilePurpose.REPRESENTATIVE_VERIFICATION)
                    .build())
                .call();

}
}
```

#### Python

```python
from moovio_sdk import Moov
from moovio_sdk.models import components

with Moov(
    security=components.Security(
        username="",
        password="",
    ),
) as moov:

res = moov.files.upload(account_id="221c30bd-2551-4ae4-9a14-07bf6599b728", file={
        "file_name": "example.file",
        "content": open("example.file", "rb"),
    }, file_purpose=components.FilePurpose.REPRESENTATIVE_VERIFICATION)

# Handle response
    print(res)
```

#### Ruby

```ruby
require 'moov_ruby'

Models = ::Moov::Models
s = ::Moov::Client.new(
  security: Models::Components::Security.new(
    username: '',
    password: ''
  )
)
res = s.files.upload(account_id: '221c30bd-2551-4ae4-9a14-07bf6599b728', file_upload_request_multi_part: Models::Components::FileUploadRequestMultiPart.new(
  file: Models::Components::FileUploadRequestMultiPartFile.new(
    file_name: 'example.file',
    content: File.binread('example.file')
  ),
  file_purpose: Models::Components::FilePurpose::REPRESENTATIVE_VERIFICATION
))

unless res.file_details.nil?
  # handle response
end
```

#### C#

```csharp
using Moov.Sdk;
using Moov.Sdk.Models.Components;

var sdk = new MoovClient(security: new Security() {
    Username = "",
    Password = "",
});

var res = await sdk.Files.UploadAsync(
    accountID: "221c30bd-2551-4ae4-9a14-07bf6599b728",
    body: new FileUploadRequestMultiPart() {
        File = new FileUploadRequestMultiPartFile() {
            FileName = "example.file",
            Content = System.IO.File.ReadAllBytes("example.file"),
        },
        FilePurpose = FilePurpose.RepresentativeVerification,
    }
);

// handle response
```

## The request completed successfully.

## Example Response

Describes a file linked to a Moov account.

```json
{
  "fileID": "string",
  "fileName": "logo.png",
  "accountID": "string",
  "filePurpose": "representative_verification",
  "fileStatus": "pending",
  "metadata": "{\"error_code\": \"document-name-mismatch\", \"requirement_id\": \"document.individual.verification\", \"representative_id\": \"c63ab175-251d-497e-a267-7346d087e180\", \"comment\": \"testing comment\"}",
  "decisionReason": "not correct file",
  "fileSizeBytes": 0,
  "createdOn": "2019-08-24T14:15:22Z",
  "updatedOn": "2019-08-24T14:15:22Z"
}
```

### Error Response Examples

```json
{
  "error": "string"
}
```

```json
{
  "error": "string",
  "file": "string",
  "FileName": "string",
  "filePurpose": "string",
  "metadata": "string"
}
```

### Additional Information
- Set this header to v2026.07.00 to use the API described in this specification.
