FileAttachment

Insert a file attachment

Uploads a file and attaches it to exactly one existing record. On success the file is stored and served back through the url on the response, so a single call both persists the document and makes it downloadable.

Send the request as multipart/form-data with three parts: • file — the binary to upload. Required, and must be non-empty (a zero-byte file is rejected). • name — optional display name; defaults to the uploaded file's original filename when omitted or blank. • exactly one reference id (product_id, order_id, purchase_id, ...) naming the record to attach to. Supply the id — the same id that record's own endpoint returns. Providing no reference id is rejected, and providing more than one is also rejected; exactly one is required.

This endpoint is create-only. There is no public endpoint to update or delete an attachment, and a file cannot be replaced once uploaded — upload a new attachment instead. The response echoes the attachment with all reference-id fields present but only the one you set populated; the rest are null.

The attachment is owned by the company tied to the API key you authenticate with, and the response's uploader is the user that key belongs to. On success you get a 201 with the created attachment wrapped in a data envelope; its url is immediately downloadable.

System effects: the upload counts against your company's storage quota. If it would exceed the remaining quota the call fails with 400 and nothing is stored — free space under Settings (or remove other attachments) and retry. This endpoint does not move inventory and does not push to Metrc or BioTrack; it only associates a document with the referenced record.

Required permission: products_permissions_edit.

post/public/v1/file-attachments

Request

  • Base URL
    https://app.distru.com
  • Auth
    HTTP bearer

Request body multipart/form-data

filestring binary required

The binary file to upload, sent as a multipart part. Required and must be non-empty — a zero-byte file is rejected. When name is omitted or blank, the uploaded file's original filename becomes the attachment name.

namestring

Display name for the attachment. Defaults to the uploaded file's original filename when omitted or blank. Max 255 characters.

product_idstring

ID of the product to attach this file to, as returned by the product endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

order_idstring

ID of the order to attach this file to, as returned by the order endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

purchase_idstring

ID of the purchase to attach this file to, as returned by the purchase endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

invoice_idstring

ID of the invoice to attach this file to, as returned by the invoice endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

batch_idstring

ID of the batch to attach this file to, as returned by the batch endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

contact_idstring

ID of the contact to attach this file to, as returned by the contact endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

company_relationship_idstring

ID of the company relationship to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

request_idstring

ID of the request to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

task_idstring

ID of the task to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

stock_transfer_idstring

ID of the stock transfer to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

assembly_idstring

ID of the assembly to attach this file to, as returned by the assembly endpoints. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

return_idstring

ID of the return to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

order_shipment_idstring

ID of the order shipment to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

license_idstring

ID of the license to attach this file to. Exactly one reference id must be provided across all *_id fields on this request — providing none, or more than one, is rejected.

Example request

{
  "product_id": "550e8400-e29b-41d4-a716-446655440000",
  "order_id": "550e8400-e29b-41d4-a716-446655440000",
  "purchase_id": "550e8400-e29b-41d4-a716-446655440000",
  "invoice_id": "550e8400-e29b-41d4-a716-446655440000",
  "batch_id": "550e8400-e29b-41d4-a716-446655440000",
  "contact_id": "550e8400-e29b-41d4-a716-446655440000",
  "company_relationship_id": "550e8400-e29b-41d4-a716-446655440000",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "task_id": "550e8400-e29b-41d4-a716-446655440000",
  "stock_transfer_id": "550e8400-e29b-41d4-a716-446655440000",
  "assembly_id": "550e8400-e29b-41d4-a716-446655440000",
  "return_id": "550e8400-e29b-41d4-a716-446655440000",
  "order_shipment_id": "550e8400-e29b-41d4-a716-446655440000",
  "license_id": "550e8400-e29b-41d4-a716-446655440000"
}

Response

File attachment inserted successfully

Changes

No recorded changes to this operation across all 17 revisions of this API.