attachments
4 operations
GET /v1/attachments/{sha256}Download a blobPUT /v1/attachments/{sha256}Upload a blob owned by the caller's tenantGET /v1/attachments/{sha256}/peaksWaveform peaks of a WAV blobPUT /v1/devices/{id}/attachments/{sha256}Upload the bytes of an attachment one of the device's envelopes references
GET /v1/attachments/{sha256}
Download a blob
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: attachment_read · getAttachment
Admins and auditors tenant-wide; an operator through envelopes of its facilities, and a tenant-owned upload (it has no facility) only when a certification, spray record or satellite check of a growing area of its tenant (or an unowned one) cites it. Visible when an envelope of the caller's tenant references the hash and its bytes were uploaded for that reference, or the caller's tenant uploaded it. The Content-Type is the stored media type. Not public: no /v1/public/ route serves blobs. The photo of a land-use right certificate (#250: a hash that a land certificate of a growing area of the caller's company names as its photo_sha256) holds the land user's personal data: it is served only to a caller that may read land certificates (the company's tenant admins and a platform admin acting for it) through a signed-in session, never to an auditor, an operator, an API token or an OAuth client, which get 404.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
sha256required | path | string | SHA-256 of the blob: exactly 64 lowercase hex characters (anything else is 400 before any lookup). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | stringapplication/pdf, audio/wav, image/jpeg, image/png | The blob's bytes. |
| 400 | Errorapplication/json | Malformed sha256 in the path, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No blob this caller may see: never uploaded, referenced but not uploaded yet, owned by another tenant, or (for a facility-scoped operator) referenced only by envelopes outside its facilities or a tenant upload no growing-area record cites, all answer exactly alike. So does a land certificate's photo for a caller that may not read land certificates through a signed-in session. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Content-Type-Options | 200 | string | Always |
Content-Disposition | 200 | string | Always |
Content-Security-Policy | 200 | string | Always |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/pdf
%PDF-1.7 ... (binary PDF bytes)Response 200 · audio/wav
RIFF....WAVEfmt ... (binary PCM WAV bytes)Response 200 · image/jpeg
(binary JPEG bytes, starting FF D8 FF)Response 200 · image/png
(binary PNG bytes, starting 89 50 4E 47 0D 0A 1A 0A)Response 400 · application/json · invalid_hash
{
"error": "invalid hash",
"code": "invalid_hash"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/attachments/{sha256}
Upload a blob owned by the caller's tenant
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: attachment_upload · uploadAttachment
For blobs no envelope references (a satellite-check image, a lab PDF). platform_admin and tenant_admin; the owner is the tenant the caller acts for (X-Tenant for a platform admin). The body must hash to sha256, be at most 1 MiB, have an allowlisted Content-Type (parameters ignored) and that type's signature. A blob the tenant already owns: 200 without reading the body. Audited (attachment.upload: the hash, media type and size, never the bytes).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
sha256required | path | string | SHA-256 of the blob: exactly 64 lowercase hex characters (anything else is 400 before any lookup). |
Request body
string (required)
Media type: application/pdf, audio/wav, image/jpeg, image/png
Example request · application/pdf
%PDF-1.7 ... (binary PDF bytes)Example request · audio/wav
RIFF....WAVEfmt ... (binary PCM WAV bytes)Example request · image/jpeg
(binary JPEG bytes, starting FF D8 FF)Example request · image/png
(binary PNG bytes, starting 89 50 4E 47 0D 0A 1A 0A)Responses
| Status | Type | Description |
|---|---|---|
| 200 | AttachmentStoredapplication/json | The tenant already owns this blob; nothing changed. |
| 201 | AttachmentStoredapplication/json | Stored and owned by the caller's tenant. |
| 400 | Errorapplication/json | Malformed sha256 in the path, a missing or malformed Content-Length, or a bad X-Request-Id. |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted, tenant not allowed (X-Tenant), origin not allowed or CSRF token missing or invalid (cookie sessions on unsafe methods). SELF-2-4 (#193): also company read-only while the company is leaving CropPath or has left (its records can be read and exported, not changed). |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 415 | Errorapplication/json | Media type outside the allowlist (audio/wav, image/jpeg, image/png, application/pdf) or not the one declared, or bytes that do not start with that type's signature. |
| 422 | Errorapplication/json | The body does not hash to |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 201 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 415 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"media_type": "audio/wav",
"size": 115244
}Response 201 · application/json
{
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"media_type": "audio/wav",
"size": 115244
}Response 400 · application/json · invalid_hash
{
"error": "invalid hash",
"code": "invalid_hash"
}Response 400 · application/json · bad_content_length
{
"error": "bad content length",
"code": "bad_content_length"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 403 · application/json · csrf_token_missing_or_invalid
{
"error": "csrf token missing or invalid",
"code": "csrf_token_missing_or_invalid"
}Response 403 · application/json · origin_not_allowed
{
"error": "origin not allowed",
"code": "origin_not_allowed"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 415 · application/json · unsupported_media_type
{
"error": "unsupported media type",
"code": "unsupported_media_type"
}Response 415 · application/json · content_does_not_match_the_media_type
{
"error": "content does not match the media type",
"code": "content_does_not_match_the_media_type"
}Response 422 · application/json
{
"error": "hash mismatch",
"code": "hash_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}GET /v1/attachments/{sha256}/peaks
Waveform peaks of a WAV blob
Authentication: cookie, bearer, oauth2 · OAuth2 scopes: attachment_read · getAttachmentPeaks
Same visibility as the blob. PCM 8/16/24/32-bit WAV, any channel count. The frames are split into n buckets as evenly as integer division allows (one bucket per frame when there are fewer frames than n); each bucket is [min, max] over every sample of every channel, normalised to -1..1 of full scale and rounded to 4 decimals.
Parameters
| Name | In | Type | Description |
|---|---|---|---|
sha256required | path | string | SHA-256 of the blob: exactly 64 lowercase hex characters (anything else is 400 before any lookup). |
noptional | query | integer | Number of buckets, 1 to 4096 (default 560). |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | AttachmentPeaksapplication/json | The peaks. |
| 400 | Errorapplication/json | Malformed sha256 in the path, |
| 401 | Errorapplication/json | No valid session, API token or legacy token. |
| 403 | Errorapplication/json | The caller is known but refused: role not permitted or tenant not allowed (X-Tenant). |
| 404 | Errorapplication/json | No blob this caller may see: never uploaded, referenced but not uploaded yet, owned by another tenant, or (for a facility-scoped operator) referenced only by envelopes outside its facilities or a tenant upload no growing-area record cites, all answer exactly alike. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 415 | Errorapplication/json | The blob is not audio/wav, or not a PCM WAV the server can read. |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
Cache-Control | 200 | string |
|
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 401 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 415 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"n": 4,
"channels": 1,
"sample_rate": 48000,
"frames": 57600,
"duration_s": 1.2,
"peaks": [
[
-0.5,
0.5
],
[
-0.25,
0.75
],
[
0,
0
],
[
-1,
0.9999
]
]
}Response 400 · application/json · invalid_hash
{
"error": "invalid hash",
"code": "invalid_hash"
}Response 400 · application/json · bad_n
{
"error": "bad n",
"code": "bad_n"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 401 · application/json
{
"error": "missing or invalid token",
"code": "missing_or_invalid_token"
}Response 403 · application/json · role_not_permitted
{
"error": "role not permitted",
"code": "role_not_permitted"
}Response 403 · application/json · tenant_not_allowed
{
"error": "tenant not allowed",
"code": "tenant_not_allowed"
}Response 404 · application/json
{
"error": "not found: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 415 · application/json · not_a_wav_attachment
{
"error": "not a wav attachment",
"code": "not_a_wav_attachment"
}Response 415 · application/json · not_a_pcm_wav_attachment
{
"error": "not a pcm wav attachment",
"code": "not_a_pcm_wav_attachment"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}PUT /v1/devices/{id}/attachments/{sha256}
Upload the bytes of an attachment one of the device's envelopes references
Authentication: deviceMtls · uploadDeviceAttachment
For devices and gateways after the envelope was sent (the SDK's WAV upload, #24, targets this route). Accepted only when a stored envelope of device {id} lists sha256 as an attachment; any bytes that hash to it are the signed content. Over mTLS the client certificate CN must be the device or the active gateway the envelope names (403 otherwise, the ingest rule); over plain HTTP (development) the reference and the hash are the whole check. Content-Type (parameters ignored) must equal the declared mediaType and be allowlisted; the body must hash to sha256 and, when the envelope declares size, have that length; the bytes must carry the media type's signature. Already uploaded: 200 without reading the body. SELF-2-4 (#193): refused 403 company_read_only once the envelope's company is leaving CropPath or has left (storing the bytes would change its public fruit page). Never returns blob bytes. Not audited: the attachments row records the upload (see AUDIT_EXEMPT).
Parameters
| Name | In | Type | Description |
|---|---|---|---|
idrequired | path | string | Device id of the envelope that references the blob. |
sha256required | path | string | SHA-256 of the blob: exactly 64 lowercase hex characters (anything else is 400 before any lookup). |
Request body
string (required)
Media type: application/pdf, audio/wav, image/jpeg, image/png
Example request · application/pdf
%PDF-1.7 ... (binary PDF bytes)Example request · audio/wav
RIFF....WAVEfmt ... (binary PCM WAV bytes)Example request · image/jpeg
(binary JPEG bytes, starting FF D8 FF)Example request · image/png
(binary PNG bytes, starting 89 50 4E 47 0D 0A 1A 0A)Responses
| Status | Type | Description |
|---|---|---|
| 200 | AttachmentStoredapplication/json | Already uploaded for this reference; nothing changed. |
| 201 | AttachmentStoredapplication/json | Stored. |
| 400 | Errorapplication/json | Malformed sha256 in the path, a missing or malformed Content-Length, or a bad X-Request-Id. |
| 403 | Errorapplication/json | Over mTLS, the client certificate is neither the device nor the gateway the envelope names ( |
| 404 | Errorapplication/json | No stored envelope of this device references the hash. |
| 405 | Errorapplication/json | The path exists but not for this method. |
| 413 | Errorapplication/json | The request body is over 1 MiB. |
| 415 | Errorapplication/json | Media type outside the allowlist (audio/wav, image/jpeg, image/png, application/pdf) or not the one declared, or bytes that do not start with that type's signature. |
| 422 | Errorapplication/json | The body does not hash to |
| 500 | Errorapplication/json | Unexpected failure; the detail is only in the server log. |
Response headers
| Name | Status | Type | Description |
|---|---|---|---|
X-Request-Id | 200 | string | Request id: the caller's |
X-Request-Id | 201 | string | Request id: the caller's |
X-Request-Id | 400 | string | Request id: the caller's |
X-Request-Id | 403 | string | Request id: the caller's |
X-Request-Id | 404 | string | Request id: the caller's |
X-Request-Id | 405 | string | Request id: the caller's |
Allow | 405 | string | Comma-separated methods the path accepts. |
X-Request-Id | 413 | string | Request id: the caller's |
X-Request-Id | 415 | string | Request id: the caller's |
X-Request-Id | 422 | string | Request id: the caller's |
X-Request-Id | 500 | string | Request id: the caller's |
Example responses
Response 200 · application/json
{
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"media_type": "audio/wav",
"size": 115244
}Response 201 · application/json
{
"sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"media_type": "audio/wav",
"size": 115244
}Response 400 · application/json · invalid_hash
{
"error": "invalid hash",
"code": "invalid_hash"
}Response 400 · application/json · bad_content_length
{
"error": "bad content length",
"code": "bad_content_length"
}Response 400 · application/json · bad_request_id
{
"error": "bad request id",
"code": "bad_request_id"
}Response 403 · application/json · peer_mismatch
{
"error": "peer mismatch",
"code": "peer_mismatch"
}Response 403 · application/json · company_read_only
{
"error": "company read-only: the company is leaving or has left CropPath; its records can be read and exported but not changed",
"code": "company_read_only"
}Response 404 · application/json
{
"error": "not found: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"code": "not_found"
}Response 405 · application/json
{
"error": "method not allowed",
"code": "method_not_allowed"
}Response 413 · application/json
{
"error": "body too large",
"code": "body_too_large"
}Response 415 · application/json · unsupported_media_type
{
"error": "unsupported media type",
"code": "unsupported_media_type"
}Response 415 · application/json · content_does_not_match_the_media_type
{
"error": "content does not match the media type",
"code": "content_does_not_match_the_media_type"
}Response 422 · application/json · hash_mismatch
{
"error": "hash mismatch",
"code": "hash_mismatch"
}Response 422 · application/json · size_mismatch
{
"error": "size mismatch",
"code": "size_mismatch"
}Response 500 · application/json
{
"error": "internal error",
"code": "internal_error"
}