Attachments

Order attachments let you associate files with an order: invoices, CFDI (XML/PDF), shipping labels, delivery evidence, and more. Files are stored in S3 and accessed via short-lived presigned URLs — they never travel as base64 inside the API's JSON.

Response envelope

Every successful single-resource response follows { "data": {...} }. Errors are always { "error": { "code", "message", "details?" } }. Full catalog: Error Reference.

Real catalog of type (11 values)

CategoryValues
documentinvoice, ticket, cfdi-xml, cfdi-pdf, shipping-guide, customs, receipt, other
evidencepacking-photo, packing-video, condition-photo

Don't confuse it with the old catalog

Values like cfdi, shipping_guide, or custom don't exist — the real catalog uses cfdi-xml/cfdi-pdf, shipping-guide (hyphenated), and other, respectively.

Limits by category

CategoryMax sizeMax per order
document10 MB10
evidence200 MB30

Upload flow

Uploads use a two-step flow with a presigned URL, so the file bytes travel directly to S3 without passing through Fenicia's servers.

1

Request a presigned upload URL

Call POST /orders/{orderId}/attachments/upload-url. You receive a short-lived uploadUrl and an s3Key.

2

Upload the file to S3 with PUT

Upload the file bytes directly to the uploadUrl, using exactly the Content-Type you declared in the previous step.

3

Confirm the attachment

Call POST /orders/{orderId}/attachments with the same s3Key to register the attachment against the order.

Request an upload URL

Generates a presigned S3 URL to upload a file. Does not upload the file — it only prepares the destination.

{ "type": "invoice", "filename": "factura-1001.pdf", "contentType": "application/pdf" }
200
{
  "data": {
    "uploadUrl": "https://fenicia-order-attachments-prod.s3.us-east-2.amazonaws.com/attachments/...?X-Amz-Signature=...",
    "s3Key": "attachments/65f3a1b2c4d5e6f7a8b9c0d1/invoice-2026-04-11.pdf",
    "expiresIn": 900
  }
}
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments/upload-url \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"type":"invoice","filename":"factura-1001.pdf","contentType":"application/pdf"}'

Returns the presigned S3 URL to upload the file (uploadUrl), the s3Key to use in the confirmation step, and the expiration time in seconds (expiresIn).

Required permission: orders:update

Parameters

orderIdstringrequired

Order ID.

typestringrequired

Attachment type (see catalog above).

filenamestringrequired

Original filename.

contentTypestringrequired

MIME type of the file (e.g. application/pdf).

Confirm the attachment

Registers the attachment against the order, after the file has been uploaded to S3 with the presigned URL.

{
  "s3Key": "attachments/65f3a1b2c4d5e6f7a8b9c0d1/invoice-2026-04-11.pdf",
  "type": "invoice",
  "filename": "factura-1001.pdf",
  "contentType": "application/pdf"
}
201The created attachment travels under data.attachment, not directly under data
{
  "data": {
    "attachment": {
      "id": "a1b2c3d4-5e6f-4890-abcd-ef1234567890",
      "type": "invoice",
      "category": "document",
      "filename": "factura-1001.pdf",
      "contentType": "application/pdf",
      "s3Key": "attachments/65f3a1b2c4d5e6f7a8b9c0d1/invoice-2026-04-11.pdf",
      "size": 128340,
      "uploadedAt": "2026-04-11T14:30:00.000Z"
    }
  }
}
curl -X POST https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"s3Key":"attachments/65f3a1b2c4d5e6f7a8b9c0d1/invoice-2026-04-11.pdf","type":"invoice","filename":"factura-1001.pdf","contentType":"application/pdf"}'

Returns the created attachment, nested under data.attachment. Its identifier is id — a server-generated UUID (randomUUID()), not a Mongo ObjectId (_id) — because attachments live as subdocuments inside the order's attachments array, not as their own collection. It also carries category (derived from type) and s3Key, which weren't in the request.

Required permission: orders:update

Parameters

orderIdstringrequired

Order ID.

s3Keystringrequired

The same s3Key returned by upload-url.

typestringrequired

Attachment type (see catalog above).

filenamestringrequired

Original filename.

contentTypestringrequired

MIME type of the file.

The object is wrapped in attachment

The created attachment travels under data.attachment, not directly under data. If you destructure the response, remember that extra level of nesting.

List an order's attachments

Lists all attachments registered on the order.

200
{
  "data": {
    "attachments": [
      {
        "id": "a1b2c3d4-5e6f-4890-abcd-ef1234567890",
        "type": "invoice",
        "category": "document",
        "filename": "factura-1001.pdf",
        "contentType": "application/pdf",
        "s3Key": "attachments/65f3a1b2c4d5e6f7a8b9c0d1/invoice-2026-04-11.pdf",
        "size": 128340,
        "uploadedAt": "2026-04-11T14:30:00.000Z"
      }
    ],
    "count": 1
  }
}
curl https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments \
  -H "Authorization: Bearer fkapi_your_api_key"

Returns the order's list of attachments (attachments) along with the total count (count). Each attachment is identified by id (UUID), not _id — same detail as the confirmation response.

Required permission: orders:read

Parameters

orderIdstringrequired

Order ID.

Get an attachment's download URL

Returns a presigned URL to download a specific attachment.

200
{
  "data": {
    "downloadUrl": "https://fenicia-order-attachments-prod.s3.us-east-2.amazonaws.com/attachments/...?X-Amz-Signature=...",
    "filename": "factura-1001.pdf",
    "expiresIn": 900
  }
}
404
{ "error": { "code": "attachments:attachment_not_found", "message": "Attachment not found" } }
DOWNLOAD_URL=$(curl -s https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments/65f3a1b2c4d5e6f7a8b9c0e5 \
  -H "Authorization: Bearer fkapi_your_api_key" \
  | jq -r '.data.downloadUrl')
 
curl -o factura.pdf "$DOWNLOAD_URL"

Returns a presigned download URL (downloadUrl), the original filename (filename), and its expiration time in seconds (expiresIn) — all three fields are always present, filename is not optional.

Required permission: orders:read

Parameters

orderIdstringrequired

Order ID.

attachmentIdstringrequired

Attachment ID.

Don't confuse it with the singular /attachment route

GET /orders/{orderId}/attachment (singular, no ID) is a legacy route registered on the router but it always responds 501 — it's a disabled stub left over from a migration, not a functional endpoint. Always use the plural route with {attachmentId} documented here.

Delete an attachment

Deletes an attachment from the order and its file in S3.

200200 with a body, not 204
{ "data": { "success": true, "message": "Attachment deleted successfully" } }
curl -X DELETE https://api.fenicia.io/orders/65f3a1b2c4d5e6f7a8b9c0d1/attachments/65f3a1b2c4d5e6f7a8b9c0e5 \
  -H "Authorization: Bearer fkapi_your_api_key"

Returns success: true and a confirmation message — the literal text is "Attachment deleted successfully".

Required permission: orders:update

Parameters

orderIdstringrequired

Order ID.

attachmentIdstringrequired

Attachment ID.

200 with a body, not 204

This endpoint responds with 200 and { "data": { "success": true, "message": "..." } } — it is not a bodyless 204. Check data.success instead of relying solely on the status code.

Tip

Size and count limits are per category (document vs. evidence), not a single global limit — review the limits table above before uploading large evidence files.

Next steps