Skip to content

mv.files

Documents you upload for a later request, such as a port’s signed LOA. These methods are on mv.files, where mv is your client (see the Node.js SDK). Each one returns the response object and throws when the API answers with an error.

Upload a file. Uploads a document for a later request, as multipart/form-data (a file part and purpose) or as JSON with the file base64: a PDF, JPEG or PNG of up to 10 MB (the type is read from the file itself). Today’s purpose is port_document: the signed LOA and the latest invoice of a port (POST /v1/ports). The file is stored encrypted; a file is used by one request, and an unused one is deleted after 7 days. At most 50 unused files at a time. Needs a live key and number porting on.

mv.files.create(body: FilesCreateData["body"], options?: RequestOptions): Promise<FilesCreateResponse>

POST /files · API reference

Name Type Required Description
body.purpose "port_document" yes What the file is for: port_document.
body.file object yes The document. JSON requests send it base64; multipart/form-data requests send a file part.
options.headers["MoreVoice-Version"] string no The API version to use for this request. Defaults to the version the API key is pinned to.
options.headers["Idempotency-Key"] string no A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice.
options RequestOptions no idempotencyKey, extra headers and an abort signal: see retries and idempotency.

File:

Field Type Description
object "file" Always file.
id string A file ID (prefix file_).
livemode boolean true in live mode, false in test mode.
purpose "port_document" What the file is for: port_document (a port’s signed LOA or latest invoice).
filename string —
mime_type string application/pdf, image/jpeg or image/png (read from the file itself).
size_bytes integer —
sha256 string SHA-256 of the file’s bytes (hex).
used boolean A request took it (a file is used once).
expires_at string | null An unused file is deleted after this; null once used.
created string An ISO-8601 timestamp in UTC.
import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
const file = await mv.files.create({
file: {
content_base64: "JVBERi0xLjQKJcfsj6IK",
filename: "loa-signed.pdf",
},
purpose: "port_document",
});
console.log(file);

Retrieve a file. An uploaded file’s facts (purpose, type, size, SHA-256, whether a request used it). The file itself is never returned.

mv.files.retrieve(id: FilesRetrieveData["path"]["id"], options?: RequestOptions): Promise<FilesRetrieveResponse>

GET /files/{id} · API reference

Name Type Required Description
id string yes A file ID (file_…).
options.headers["MoreVoice-Version"] string no The API version to use for this request. Defaults to the version the API key is pinned to.
options RequestOptions no idempotencyKey, extra headers and an abort signal: see retries and idempotency.

File:

Field Type Description
object "file" Always file.
id string A file ID (prefix file_).
livemode boolean true in live mode, false in test mode.
purpose "port_document" What the file is for: port_document (a port’s signed LOA or latest invoice).
filename string —
mime_type string application/pdf, image/jpeg or image/png (read from the file itself).
size_bytes integer —
sha256 string SHA-256 of the file’s bytes (hex).
used boolean A request took it (a file is used once).
expires_at string | null An unused file is deleted after this; null once used.
created string An ISO-8601 timestamp in UTC.
import MoreVoice from "@morevoice/sdk";
const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment
const file = await mv.files.retrieve("file_7Hk2Lm9Qp");
console.log(file);