Variants and media

This page covers the three endpoints with their own surface over a product's variants and media: reading the variant structure, updating an existing variant, and uploading images via a presigned URL. It also documents, explicitly, what falls outside that surface — because it is more than you would assume.

Variant and option summary

Returns a product's variant and option structure

200The product's variant and option structure
{
  "sku": "CAM-ROJO-M",
  "variants": [
    {
      "id": "65f3a1b2c4d5e6f7a8b9c0f1",
      "sku": "CAM-ROJO-M-CH",
      "title": { "value": "Camisa Roja - Chica" },
      "price": 499.00,
      "position": 0,
      "options": [{ "id": "opt-talla", "name": "Talla", "value": "CH" }]
    }
  ],
  "options": [{ "id": "opt-talla", "name": "Talla", "values": ["CH", "M", "G"] }],
  "hasVariants": true,
  "hasOptions": true
}
404No product with that SKU exists in your tenant
{ "code": "not-found", "message": "Product CAM-ROJO-M not found" }

Returns the queried sku, the variants and options arrays (empty, never null, if the product has none) and the hasVariants and hasOptions booleans.

Required permission: products:read

Parameters

skustringrequired

SKU of the parent product. It also accepts an `_id`: identifier resolution is the same as in `GET /products/{id}`.

The full response example is in Retrieve a product.

Update fields on an existing variant

Updates one or more fields on an existing variant

{ "price": 549.00 }
200Variant updated
{
  "message": "Variant updated successfully",
  "productSku": "CAM-ROJO-M",
  "variantSku": "CAM-ROJO-M-CH",
  "variant": {
    "id": "65f3a1b2c4d5e6f7a8b9c0f1",
    "sku": "CAM-ROJO-M-CH",
    "price": 549.00,
    "position": 0,
    "taxable": true,
    "options": [{ "id": "opt-talla", "name": "Talla", "value": "CH" }]
  }
}
400Body missing, or present but with no field to update
{ "code": "bad-request", "message": "Request body must contain at least one field to update" }
404The parent product does not exist, or the variant does not belong to it
{ "code": "not-found", "message": "Product 'CAM-ROJO-M' or variant 'CAM-ROJO-M-CH' not found" }

Returns an acknowledgement with message, the affected productSku and variantSku, and the updated variant object.

Required permission: products:update

Parameters

productSkustringrequired

SKU of the parent product.

variantSkustringrequired

SKU of the variant to update. It must belong to the given parent product; otherwise the response is `404`.

Request body

The body is a flat { [field]: value } object with one or more variant fields — for example price, title, position, taxable, minAlertStock, sellIfOutOfStock or countryOfOrigin. There is no allowlist that rejects an unknown name, but it is not written either: a misspelled field is silently discarded and the request still returns 200. See the note below.

(any variant field)objectestructura libre

Flat object with the fields to update. A missing body, a non-object body, or an empty object `{}` returns `400`.

The update is NOT atomic: it writes field by field

The handler iterates over the body's keys and performs one independent write per field. If you send three fields and the second fails, the first is already persisted and you still get a 404. There is no transaction and no rollback. With multiple fields at once, treat an error response as "partial, unknown state" and re-read the variant before retrying.

This endpoint validates NOTHING you send it

The write is a direct $set via findOneAndUpdate, with Mongoose validators disabled and no application-level check whatsoever. In practice, on a variant:

  • No schema enum and no schema minimum is checked. Not even the field's own min: 0: {"compareAtPrice": -50} or {"price": -1} return 200 and are persisted.
  • compareAtPrice is not checked against price. That rule lives in a pre('save') hook that only runs when a product is created.
  • A misspelled field is silently discarded. There is no allowlist to reject it, but it is not written either: Mongoose strict mode strips from the $set any path absent from the schema. So {"pirce": 549} returns 200 with "Variant updated successfully" and changes nothing — the success acknowledgement does not prove anything was stored.

Validate on your side before calling, and re-read the variant to confirm what landed: the API will not do it for you, and its 200 does not distinguish "saved" from "discarded". The same applies, with somewhat more coverage, to PUT /products/{id} — see Update a product.

curl -X PUT https://api.fenicia.io/products/CAM-ROJO-M/variants/CAM-ROJO-M-CH \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "price": 549.00 }'

There is no create or delete for a variant — only update an existing one

This endpoint updates fields on a variant that already exists. There is no POST to create a new variant and no DELETE to remove one. The full variants[] array structure (add, remove, reorder) is managed by resending the entire array inside the PUT /products/{id} payload.

Upload an image

Generates a presigned S3 URL to upload a product image or video

{ "contentType": "image/jpeg", "filename": "cam-rojo-m-1.jpg" }
200Presigned URL generated
{
  "uploadUrl": "https://fenicia-product-media.s3.us-east-2.amazonaws.com/products/65f2a0b1c4d5e6f7a8b9c0aa/media/9f1c0f2e-6d4a-4c31-9a77-2b0e5d8c1a44.jpg?X-Amz-Signature=...",
  "s3Key": "products/65f2a0b1c4d5e6f7a8b9c0aa/media/9f1c0f2e-6d4a-4c31-9a77-2b0e5d8c1a44.jpg",
  "publicUrl": "https://cdn.fenicia.io/products/65f2a0b1c4d5e6f7a8b9c0aa/media/9f1c0f2e-6d4a-4c31-9a77-2b0e5d8c1a44.jpg",
  "expiresIn": 900
}
400The contentType is not allowed, or the size exceeds the maximum
{
  "code": "bad-request/invalid-media",
  "message": "File type \"application/pdf\" not allowed. Allowed: JPEG, PNG, GIF, WEBP, MP4, WebM, MOV",
  "parameter": "contentType"
}

Returns the presigned upload URL (uploadUrl), the key the object will land on (s3Key), the final public URL (publicUrl) and the URL's lifetime in seconds (expiresIn, always 900).

Required permission: products:update

Parameters

contentTypestringrequired

MIME type of the file. Closed list of 7 accepted values — images: image/jpeg, image/png, image/gif, image/webp; video: video/mp4, video/webm, video/quicktime (.mov). There is no escape value: any other MIME is rejected with `400`, including plausible ones such as image/svg+xml, image/avif, image/heic or application/pdf.

filenamestringrequired

Original file name. It is used only as S3 metadata, not to build the key: it is sanitized to `[a-zA-Z0-9._-]` and truncated to 100 characters. The object's actual extension is derived from `contentType`, not from this name.

sizenumber

File size in bytes. If you omit it the size is NOT validated here, and an upload exceeding the limit will fail later against S3. Maximums: 10 MB (10485760 bytes) for images and 100 MB (104857600 bytes) for video.

This endpoint does not upload the file

It returns a presigned S3 URL that you PUT the binary to directly from your client, using the same Content-Type you declared. The publicUrl is what you then persist in the product's media[].src. The upload URL expires after 900 seconds (15 minutes).

The `s3Key` carries a UUID, not your file name

The key is generated with the format products/{tenantId}/media/{uuid}.{ext}. Two uploads of the same file produce two different keys: the endpoint never overwrites an existing object, so you cannot use it to "replace" an image.

Examples

# 1. Request the presigned URL
curl -X POST https://api.fenicia.io/products/media/upload \
  -H "Authorization: Bearer fkapi_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "contentType": "image/jpeg", "filename": "cam-rojo-m-1.jpg" }'
 
# 2. Upload the binary directly to the returned uploadUrl
curl -X PUT "<uploadUrl from the response>" \
  -H "Content-Type: image/jpeg" \
  --data-binary @cam-rojo-m-1.jpg

After uploading the binary, add the entry to the product's media[] array with publicUrl as src, via PUT /products/{id}:

{
  "media": [
    {
      "id": "m2",
      "src": "https://cdn.fenicia.io/products/65f2a0b1c4d5e6f7a8b9c0aa/media/9f1c0f2e-6d4a-4c31-9a77-2b0e5d8c1a44.jpg",
      "type": "image",
      "position": 1,
      "alt": { "value": "Camisa roja, vista frontal" }
    }
  ]
}

There is no endpoint to delete or reorder media

There is no dedicated route to remove an image or change its order. To delete, reorder or modify any media[] entry, resend the entire media[] array —with the entry removed, reordered or modified— inside the PUT /products/{id} payload. Removing the entry from the array does not delete the S3 object: the binary stays reachable at its publicUrl.

What is only managed through a full PUT

Several parts of the product model have no granular read/write endpoint of their own: they are managed by sending the relevant subset of fields to PUT /products/{id}.

attributesarray

Attributes / custom fields. They are read as part of the full product and written by resending the entire `attributes[]` array via `PUT /products/{id}`.

attributes.idstring

Attribute identifier. Default: `null`.

attributes.nameobjectrequired

Translatable attribute name.

attributes.name.valuestringrequired

Name in the base language.

attributes.name.translationsarray

Name translations. Default: empty array.

attributes.name.translations.localestringrequired

Language code of the translation.

attributes.name.translations.valuestringrequired

Translated text.

attributes.valueobjectrequiredestructura libre

Attribute value. It is `Mixed` in the schema: it accepts text, number, date, boolean or array depending on what `type` declares.

attributes.typestring

How to interpret `value`. Accepted values: text, number, Date, boolean, array. Default: text. Mind the capital in `Date`: the other four are lowercase.

attributes.groupIdstring

Group the attribute belongs to, used to cluster attributes on the product page. Default: `null`.

seoobject

Search metadata. There is no `/products/{sku}/seo` route: it is written by resending the `seo` object via `PUT /products/{id}`.

seo.metaTitlestring

Title for search engines.

seo.metaDescriptionstring

Description for search engines.

seo.slugstring

Slug of the product's public URL.

priceSchemasarray

Prices per segment or channel. They are written by resending the entire `priceSchemas[]` array via `PUT /products/{id}`.

priceSchemas.idstringrequired

Price schema identifier.

priceSchemas.namestringrequired

Schema name, used to tell schemas apart in the interface.

priceSchemas.isWholesaleboolean

Whether the schema is a wholesale price. Default: false.

priceSchemas.contentobjectrequiredestructura libre

Price definition. It is `Mixed` in the schema: it has no fixed shape.

priceSchemas.currencystringrequired

Schema currency. The schema declares the same constraint as the product's `currency` —uppercase and exactly three letters (`^[A-Z]{3}$`)— but since these prices are only written through `PUT /products/{id}`, which does not enable Mongoose validators, in practice it is not checked. Validate the code yourself before sending it.

priceSchemas.targetstringrequired

Who the price applies to. Closed list of 3 accepted values: customers (everyone), client (one specific client), segment (a segment). It determines which of the next two fields is required.

priceSchemas.clientstring

Client the price applies to. Required only when `target` is `client`.

priceSchemas.segmentstring

Segment the price applies to. Required only when `target` is `segment`.

priceSchemas.channelsstring

Channel the schema is restricted to. Always optional.

bundleConfigobject

Components of a product with `productType: bundle`. There is no «bundle» entity with its own endpoints and no `/products/{sku}/bundle` route: it is just another product sub-shape, managed inside the `PUT /products/{id}` payload.

bundleConfig.inventoryModestring

How the kit's stock is computed. Accepted values: calculated (derived from the scarcest component, with inventory shared with the individual products), reserved (the kit has its own pre-assembled, independent stock). Default: calculated.

bundleConfig.componentsarrayrequired

Products that make up the kit. It must carry at least one element: an empty array is rejected.

bundleConfig.components.productSkustringrequired

SKU of the product used as a component.

bundleConfig.components.variantModestring

How the component's variant is chosen. Accepted values: fixed (one specific variant, in `variantSku`), selectable (the buyer picks from `allowedVariants`), any (any available variant). Default: fixed.

bundleConfig.components.variantSkustring

Specific variant of the component. Applies only with `variantMode: fixed`. Default: `null`.

bundleConfig.components.selectableAttributestring

Attribute the buyer chooses by, for example `Talla`. Applies only with `variantMode: selectable`.

bundleConfig.components.allowedVariantsstring[]

Variant SKUs that can be chosen from. Applies only with `variantMode: selectable`. Default `null`, meaning «all».

bundleConfig.components.quantitynumberrequired

Units of this component per kit unit. Integer greater than or equal to 1. Default: 1.

bundleConfig.components.requiredboolean

Whether the component is mandatory. Default: true.

BOM is the only composition feature with its own endpoints

The only product-of-products composition mechanism with its own API surface is BOM (bill of materials), aimed at manufacturing and material consumption — not at "sales kits". See BOM and materials.

Next steps