> For the complete documentation index, see [llms.txt](https://www.pionex.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pionex.com/docs/api-docs/institution-api/file.md).

# File

File upload and download for KYB and supporting documents.

## Upload a file (KYB / supporting documents)

> Upload a file (KYB / supporting documents), referenced elsewhere by\
> \`fileId\`. \`userId\` is passed in the \*\*query string\*\* (the request body is\
> multipart, so \`userId\` cannot go in the body here).<br>

```json
{"openapi":"3.0.3","info":{"title":"Pionex Institution Open API (v2)","version":"2.0.0"},"tags":[{"name":"File","description":"File upload and download for KYB and supporting documents."}],"servers":[{"url":"https://api.pionex.com","description":"Production"}],"security":[{"ApiKey":[],"Signature":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"X-APIKEY","description":"Your institution API Key, in the form `webot_xxxxxxxx`. Used to look up\nyour registered public key. Must be accompanied by the `X-Signature`\nheader. See the Authentication section for the full signing algorithm\n(RSA-PSS over SHA-256, or Ed25519) and the canonical-string construction.\n"}},"parameters":{"Timestamp":{"name":"timestamp","in":"query","required":true,"description":"Current time in **seconds** (Unix). Required on every signed request and\nparticipates in the signature. Must be within +/-5 seconds of server time.\n","schema":{"type":"integer","format":"int64"}},"UserIdQueryRequired":{"name":"userId","in":"query","required":true,"description":"Target sub-account UUID. Participates in the signature.","schema":{"type":"string"}}},"schemas":{"BaseResponse":{"type":"object","properties":{"result":{"type":"boolean","description":"Success indicator."},"timestamp":{"type":"integer","format":"int64","description":"Response timestamp in milliseconds."},"code":{"type":"string","description":"Error code (present only on failure)."},"message":{"type":"string","description":"Error message (present only on failure)."}}}},"responses":{"BadRequest":{"description":"Bad Request - the request body could not be read.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"}]}}}},"Unauthorized":{"description":"Unauthorized - authentication failed (missing key, bad signature, etc.).","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"}]}}}},"InternalError":{"description":"Internal or business error. Note that most business failures are returned\nas HTTP `200` with `result: false` and a `code`; this `500` covers\nserver-side internal errors.\n","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"}]}}}}}},"paths":{"/api/v2/institution/file/upload":{"post":{"tags":["File"],"summary":"Upload a file (KYB / supporting documents)","description":"Upload a file (KYB / supporting documents), referenced elsewhere by\n`fileId`. `userId` is passed in the **query string** (the request body is\nmultipart, so `userId` cannot go in the body here).\n","operationId":"institutionFileUpload","parameters":[{"$ref":"#/components/parameters/Timestamp"},{"$ref":"#/components/parameters/UserIdQueryRequired"}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"The file to upload."}}}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"},{"type":"object","properties":{"data":{"type":"object","properties":{"fileId":{"type":"string"}}}}}]}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}}}}
```

## Download a file

> Download a previously uploaded file by \`fileId\`. Returns a binary stream.<br>

```json
{"openapi":"3.0.3","info":{"title":"Pionex Institution Open API (v2)","version":"2.0.0"},"tags":[{"name":"File","description":"File upload and download for KYB and supporting documents."}],"servers":[{"url":"https://api.pionex.com","description":"Production"}],"security":[{"ApiKey":[],"Signature":[]}],"components":{"securitySchemes":{"ApiKey":{"type":"apiKey","in":"header","name":"X-APIKEY","description":"Your institution API Key, in the form `webot_xxxxxxxx`. Used to look up\nyour registered public key. Must be accompanied by the `X-Signature`\nheader. See the Authentication section for the full signing algorithm\n(RSA-PSS over SHA-256, or Ed25519) and the canonical-string construction.\n"}},"parameters":{"Timestamp":{"name":"timestamp","in":"query","required":true,"description":"Current time in **seconds** (Unix). Required on every signed request and\nparticipates in the signature. Must be within +/-5 seconds of server time.\n","schema":{"type":"integer","format":"int64"}},"UserIdQueryRequired":{"name":"userId","in":"query","required":true,"description":"Target sub-account UUID. Participates in the signature.","schema":{"type":"string"}}},"responses":{"BadRequest":{"description":"Bad Request - the request body could not be read.","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"}]}}}},"Unauthorized":{"description":"Unauthorized - authentication failed (missing key, bad signature, etc.).","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"}]}}}},"InternalError":{"description":"Internal or business error. Note that most business failures are returned\nas HTTP `200` with `result: false` and a `code`; this `500` covers\nserver-side internal errors.\n","content":{"application/json":{"schema":{"allOf":[{"$ref":"#/components/schemas/BaseResponse"}]}}}}},"schemas":{"BaseResponse":{"type":"object","properties":{"result":{"type":"boolean","description":"Success indicator."},"timestamp":{"type":"integer","format":"int64","description":"Response timestamp in milliseconds."},"code":{"type":"string","description":"Error code (present only on failure)."},"message":{"type":"string","description":"Error message (present only on failure)."}}}}},"paths":{"/api/v2/institution/file/download":{"get":{"tags":["File"],"summary":"Download a file","description":"Download a previously uploaded file by `fileId`. Returns a binary stream.\n","operationId":"institutionFileDownload","parameters":[{"$ref":"#/components/parameters/Timestamp"},{"$ref":"#/components/parameters/UserIdQueryRequired"},{"name":"fileId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Binary file stream","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"500":{"$ref":"#/components/responses/InternalError"}}}}}}
```
