post
https://api-sandboxdash.norcapsecurities.com/tapiv3/index.php/v3/uploadEntityDocument
This method is used to upload a document to a particular entity party (createEntity). The Party ID is required as a request parameter for this method. Files cannot be larger than 100 MB.
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| clientID | yes | string | TransactAPI Client ID |
| developerAPIKey | yes | string | TransactAPI Developer Key |
| partyId | yes | string | Entity ID that is generated by the API when an entity is created (createEntity) |
| documentTitle | yes | string | Uploaded document title. Please use prefix "documentTitle0=" in the value of documentTitle field |
| file_name | yes | string | Uploaded document file name. Please use prefix "filename0=" in the value of file_name field |
| userfile0 | yes | string | Raw file data. Specification of raw file data is application specific. Accepted file types are PDF, JPG, PNG, HEIC and BMP. Minimum file size is 1 kB. Maximum file size is 100 MB. Please refer to the Sample Requests section for reference implementations. |
| createdIpAddress | no | string | Requested IP Address |
Requirements
- File size: Files must be at least 1 kB and cannot exceed 100 MB.
- Accepted Formats: pdf, jpg, jpeg, and png.
- Content Type: The request must use
multipart/form-datafor proper file handling. - Multiple Files:
documentTitle,userfileandfilenameare indexed parameters. You may provide multiple userfile parameters (e.g.userfile0,userfile1,userfile2, ...). Each userfile parameter must be accompanied by a correspondingdocumentTitleandfilename. These should be separated by an&character. (e.g. (cURL)--form 'documentTitle="documentTitle0=DOC_TITLE_0&documentTitle1=DOC_TITLE_1"') - A valid entity ID is required; use the createEntity endpoint if the entity does not exist.
Sample Requests
curl --location --request POST 'https://api-sandboxdash.norcapsecurities.com/tapiv3/index.php/v3/uploadEntityDocument'
--form 'clientID=someclientid'
--form 'partyId=someentityid'
--form 'createdIpAddress="127.0.0.1"'
--form 'file_name="filename0=Testing Document Size12.pdf"'
--form 'userfile0=@"/path/to/file"'
--form 'documentTitle="documentTitle0=Testing Document Size12.pdf"'
--form 'developerAPIKey=somedeveloperAPIkey'import axios from 'axios';
import { Readable } from 'stream';
import FormData from 'form-data';
const apiHost = process.env.TAPI_HOST || 'https://api-sandboxdash.norcapsecurities.com';
const tapiUriSegment = 'tapiv3/index.php/v3';
const tapiUri = `${apiHost}/${tapiUriSegment}`;
const mimeType = 'application/json';
const tapi = axios.create({
baseURL: tapiUri,
timeout: 10000,
headers: { accept: mimeType, 'content-type': mimeType },
});
const auth = {
clientID: process.env.TAPI_CLIENT_ID,
developerAPIKey: process.env.TAPI_API_KEY,
};
const uploadEntityDocument = (partyId, file) => {
const data = new FormData();
data.append('clientID', auth.clientID);
data.append('developerAPIKey', auth.developerAPIKey);
data.append('partyId', partyId);
data.append('file_name', `filename0="${file.originalname}"`);
data.append('documentTitle', `documentTitle0="${file.originalname}"`);
data.append('userfile0', Readable.from(file.buffer), { filename: file.originalname });
data.append('createdIpAddress', '127.0.0.1');
return tapi.post('/uploadEntityDocument', data, {
timeout: 60000,
headers: { ...data.getHeaders() },
});
};
const entityId = process.env.TAPI_ENTITY_ID;
const fakeFile = {
buffer: Buffer.from('a'.repeat(1e3)),
originalname: 'test-entity-file.pdf',
};
const response = await uploadEntityDocument(entityId, fakeFile);
console.log(response.data);
/*
output:
{
statusCode: '101',
statusDesc: 'Ok',
document_details: 'Document has been uploaded Successfully'
}
*/Response Parameters
| Parameter | Type | Description |
|---|---|---|
| statusCode | string | API Status Code |
| statusDesc | string | API Status Description |
| document_details | string | Document has been uploaded |
| Errors(s) | string | (optional) provides more information about error response |
Sample Response
{
"statusCode": "101",
"statusDesc": "Ok",
"document_details": "Document has been uploaded Successfully"
}
Errors
| HTTP response code | TAPI error code | Description |
|---|---|---|
| 404 | 103 | Invalid credentials |
| 400 | 1400 | Invalid content-type (must be multipart/form-data) |
| 400 | 1400 | No file data set in request |
| 404 | 106 | Invalid request parameters |
| 404 | 106 | partyId required but not provided |
| 404 | 198 | partyId does not exist |
| 422 | 1422 | documentTitlemalformed |
| 422 | 1422 | file_name malformed |
| 422 | 1422 | userfile0required but not provided |
| 404 | 106 | documentTitlecount does not match userfilecount |
| 404 | 106 | userfilename count does not match userfilecount |
| 404 | 106 | File content does not meet minimum byte size requirement (1 kilobyte) |
