Attachments
Upload files, such as requisition forms or shipping documents, to a job through the REST API.
Upload an attachment
POST /api/1.0/vendor/job/{jobId}/attachments
| Auth | Bearer token (see Authentication) |
| Body | multipart/form-data with a single file field named file |
| Max size | 12 MB |
| Optional header | x-mpx-checksum-sha1: base64-encoded SHA-1 of the file |
curl --request POST \
--url https://mpx-api-sandbox.natera.com/api/1.0/vendor/job/{jobId}/attachments \
--header 'authorization: Bearer eyJhbG[...]1LQ' \
--header 'x-mpx-checksum-sha1: Kq5sNclPz7QV2+lfQIuc6R7oRu0=' \
--form 'file=@document.pdf'
A successful request returns 201 Created with an empty body.
Verifying uploads with a checksum
To make sure the file wasn't corrupted in transit, send its SHA-1 digest, base64-encoded, in x-mpx-checksum-sha1. If the digest doesn't match the received file, MPX rejects the upload with 400. SHA-1 is currently the only supported algorithm.
openssl dgst -sha1 -binary document.pdf | base64
Errors
| Status | Code | Cause |
|---|---|---|
| 400 | BAD_REQUEST | No file was sent, or the checksum didn't match. |
| 400 | LIMIT_FILE_SIZE | The file is larger than 12 MB. |
| 400 | LIMIT_UNEXPECTED_FILE | The file wasn't sent in a field named file. |
| 403 | INVALID_JOB_STATE | The job is AVAILABLE. Assign or publish it first. |
| 404 | JOB_NOT_FOUND | The job doesn't exist or isn't visible to your vendor. |
Upload status
Uploads are processed asynchronously. Each attachment has an AttachmentUploadStatus:
| Status | Meaning |
|---|---|
PENDING | Waiting to be uploaded. |
SUCCESS | Uploaded successfully. url is populated. |
DUPLICATE | The file's checksum matches an attachment already on the job. |
ERROR | The upload failed. |
Attachments are only returned by the single-job job query:
query {
job(id: "s@mp!3ID") {
attachments { id mimeType uploadStatus url }
}
}
Adding an attachment also triggers a JOB_UPDATED webhook with attachments in changed.
You can't delete attachments through the API. Contact the MPX Operations team to have one removed.