Download invoice attachment

Downloads a file that was attached to an invoice. Attachments are binary files (PDFs, images, documents) that have been uploaded and associated with the invoice.

GET /api/v1/invoices/{uuid}/attachments/{attachmentId}

Headers

NameTypeRequiredDescription
AuthorizationstringYesBearer token for authentication
X-CompanystringYesCompany UUID to scope the request

Path parameters

NameTypeRequiredDescription
uuidstringYesInvoice UUID
attachmentIdstringYesAttachment UUID

Finding attachment IDs

Get attachment IDs from the invoice details endpoint:

const invoice = await fetch('/api/v1/invoices/{uuid}').then(r => r.json());

invoice.attachments.forEach(attachment => {
  console.log(`${attachment.filename} - ${attachment.id}`);
});

Request

curl https://api.storno.ro/api/v1/invoices/7c9e6679-7425-40de-944b-e07fc1f90ae7/attachments/4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9a \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Company: 550e8400-e29b-41d4-a716-446655440000" \
  -o contract.pdf

Response

Returns the file as binary data with appropriate content type.

Response headers

HeaderValueDescription
Content-Type{mimeType}MIME type of the file
Content-Dispositionattachment; filename="{filename}"Original filename
Content-Length{size}File size in bytes
X-Upload-Date2024-02-15T08:45:00ZWhen file was uploaded

Common MIME types

File typeMIME type
PDFapplication/pdf
JPEGimage/jpeg
PNGimage/png
Wordapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
Excelapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
ZIPapplication/zip
Texttext/plain

Attachment types

Attachments can include:

Supporting documents

  • Purchase orders
  • Contracts
  • Delivery notes
  • Receipts
  • Correspondence

Visual documentation

  • Product photos
  • Delivery photos
  • Signed documents
  • Scanned invoices

Technical files

  • Specifications
  • Drawings
  • CAD files
  • Technical data sheets

Upload attachments

While this endpoint only handles downloads, you can upload attachments via:

// Upload attachment
const formData = new FormData();
formData.append('file', fileBlob, 'contract.pdf');
formData.append('description', 'Service contract');

await fetch('/api/v1/invoices/{uuid}/attachments', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'X-Company': '550e8400-e29b-41d4-a716-446655440000'
  },
  body: formData
});

Viewing attachments in invoice details

List all attachments for an invoice:

const invoice = await fetch('/api/v1/invoices/{uuid}').then(r => r.json());

invoice.attachments.forEach(attachment => {
  console.log({
    id: attachment.id,
    filename: attachment.filename,
    size: attachment.size,
    mimeType: attachment.mimeType,
    uploadedAt: attachment.uploadedAt
  });
});

Example response:

{
  "attachments": [
    {
      "id": "4d5e6f7a-8b9c-0d1e-2f3a-4b5c6d7e8f9a",
      "filename": "contract.pdf",
      "mimeType": "application/pdf",
      "size": 245678,
      "uploadedAt": "2024-02-15T08:45:00Z",
      "uploadedBy": {
        "id": "5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9a0b",
        "name": "John Doe"
      },
      "description": "Service contract"
    },
    {
      "id": "5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9a0b",
      "filename": "delivery-photo.jpg",
      "mimeType": "image/jpeg",
      "size": 128456,
      "uploadedAt": "2024-02-15T14:20:00Z",
      "uploadedBy": {
        "id": "5e6f7a8b-9c0d-1e2f-3a4b-5c6d7e8f9a0b",
        "name": "Jane Smith"
      },
      "description": "Proof of delivery"
    }
  ]
}

Security

Access control

  • Attachments are scoped to company
  • Requires valid authentication token
  • Only accessible to company members

File scanning

  • All uploads are scanned for malware
  • Suspicious files are quarantined
  • Safe files are stored encrypted

Storage

  • Files stored on secure cloud storage
  • Encrypted at rest and in transit
  • Automatic backups

File size limits

PlanMax file sizeMax attachments per invoiceTotal storage
Freemium5 MB3100 MB
Starter10 MB5500 MB
Professional25 MB105 GB
Business50 MB2550 GB

Performance

Download speeds depend on file size and location:

File sizeTypical download time
< 1 MB< 1 second
1-5 MB1-3 seconds
5-25 MB3-10 seconds
25-50 MB10-20 seconds

Files are served from a CDN for optimal performance.

Error codes

CodeDescription
401Missing or invalid authentication token
403No access to the specified company
404Invoice or attachment not found
410Attachment was deleted

Use cases

  • Audit trail - Download supporting documents for review
  • Client portal - Allow clients to download attachments
  • Accounting - Retrieve documents for bookkeeping
  • Archive - Download all attachments for backup
  • Compliance - Access documents for tax audits