Upload a sample image
Attach an image to the sample. Allowed extensions are jpg, jpeg, png, gif and bmp, and images can only be added while the order is in progress (status_id 3) - otherwise the endpoint returns the invalid_order_status error.
Send the file as a file field in a standard multipart/form-data request, and leave file fields out of signature generation.
subtype labels what the image shows: 0 Sample, 1 Microscope, 2 Micro Plate, 3 Chromatogram, 4 Client Logo, 5 Other, 6 Other 2, 7 Other 3, 8 Other 4.
Path parameters
Body parameters (multipart/form-data)
The image file to attach.
Set this image as the sample's cover image. Defaults to true.
Default: True
What the image shows; see the list above. Defaults to 0.
Default: 0
Try it
Log in to send test requests to this endpoint straight from the docs.
Responses
200 Success
No fields beyond the success envelope.
400 Bad request
The request was malformed or failed validation. Validation failures include per-field messages in error_details.
Possible error_code values: invalid_request, request_too_old.
401 Unauthorized
Authentication failed.
Possible error_code values: missing_api_key, invalid_api_key, invalid_credentials_type, api_access_restricted, api_access_denied, missing_signature, missing_timestamp, invalid_timestamp, invalid_signature.
403 Permission denied
The API key is valid but does not have permission for this endpoint (for example, a client key calling a labs endpoint).
Possible error_code values: permission_denied.
404 Not found
The requested record does not exist or is not visible to this organization.
Possible error_code values: not_found.
# X-ConfidentLims-Signature: see the Request Signing guide - https://api.confidentcannabis.com/v0/docs/request-signing.md
curl -X POST 'https://api.confidentcannabis.com/v0/labs/sample/{sample_id}/image' \
-H 'X-ConfidentLims-APIKey: YOUR_API_KEY' \
-H 'X-ConfidentLims-Timestamp: UNIX_TIMESTAMP' \
-H 'X-ConfidentLims-Signature: REQUEST_SIGNATURE' \
-F 'image=@/path/to/file'
import time import requests # sign_request() is defined in the Request Signing guide: # https://api.confidentcannabis.com/v0/docs/request-signing.md from sign_request import sign_request API_KEY = 'YOUR_API_KEY' API_SECRET = 'YOUR_API_SECRET' path = '/v0/labs/sample/{sample_id}/image' data = { # optional form fields go here - they are signed too } # file uploads are sent but never signed files = { "image": open('/path/to/file', 'rb'), } headers = {'X-ConfidentLims-Timestamp': str(int(time.time()))} headers['X-ConfidentLims-Signature'] = sign_request( 'POST', path, headers, data, API_KEY, API_SECRET) headers['X-ConfidentLims-APIKey'] = API_KEY response = requests.post( 'https://api.confidentcannabis.com' + path, headers=headers, data=data, files=files, ) print(response.json())
// signRequest() is defined in the Request Signing guide: // https://api.confidentcannabis.com/v0/docs/request-signing.md import { signRequest } from './sign_request.js'; const API_KEY = 'YOUR_API_KEY'; const API_SECRET = 'YOUR_API_SECRET'; const path = "/v0/labs/sample/{sample_id}/image"; const data = { // optional form fields go here - they are signed too }; const body = new FormData(); for (const [name, value] of Object.entries(data)) body.append(name, value); // file uploads are sent but never signed body.append("image", file); // a File or Blob const headers = { 'X-ConfidentLims-Timestamp': String(Math.floor(Date.now() / 1000)) }; headers['X-ConfidentLims-Signature'] = signRequest( "POST", path, headers, data, API_KEY, API_SECRET); headers['X-ConfidentLims-APIKey'] = API_KEY; const response = await fetch("https://api.confidentcannabis.com" + path, { method: "POST", headers, body, }); console.log(await response.json());
{
"success": true
}