Create an option
Create an option in the library, as Settings › Options’ Add option does, with its values: a dropdown (or swatches), a number, a size (its measurements), text, a text area or text with a picture, and where Shopify catalog lines offer it (products, categories, locations). It is attached to no template: attach it to a template with POST /product-templates/{id}/options or put it in a bundle. A name the library already has is 409 CONFLICT. A price on a new value needs Change the catalog or Prices and exceptions; a changed price, Change the catalog; any cost, Enter and correct costs. 201 with the option.
Required access
- API key
- Change the catalogpermission
- Request limit
- Counts as 5 requests. Each key has a capacity of 15, restored at 0.6 a second.
Idempotent-Replayed: true. Responses are saved for 24 hours.Headers
Bearer and your key, opk_….
Up to 100 characters (letters, digits, - _ : .). Kept for 24 hours.
application/json. A body is at most 256 KB.
Body
JSONA dropdown also takes a value typed in (Other…).
Which Shopify catalog lines offer it: every one (all, at location_ids), the products in product_ids, or those in category_ids. A template offers it only when it is attached.
One of all, products, categories.
Categories, ids from GET /categories (up to 100); null or []: none.
Starts as: a dropdown’s value by name (one of its values), or a typed option’s text or number as text.
Help text under it.
Leave it out of generated SKUs.
What customers see, when it differs from the name.
The locations it is offered at, ids from GET /locations (up to 250); null or []: every location.
Its default look online; null: automatic.
One of dropdown, buttons, segmented, radio_list, colour_swatches, image_swatches, image_cards, add_on_checkbox, number_box, stepper, slider, text_box, text_area, info_block.
The online look’s settings, by key: columns (2–6), shape (square, round), show_value_names (always, selected), show_prices. null drops one.
One of square, round.
One of always, selected.
A text’s most characters.
The name staff see, unique in the library (up to 255 characters).
Its values’ prices read as part of the item’s price, never as “+$”.
Shopify products, ids from GET /products (up to 500).
A size’s 2 or 3 measurements in order, as its editor sets them: label (up to 40 characters), key (made from the label when left out), min, max, step. A new size without them measures Length × Width × Height.
Lower-case letters, digits and _; an edit keeps a part by its key from GET /options/{id}.
Track each value’s stock in Shopify (not for a size).
dropdown (a list), swatch (a list shown as colours), number, dimensions (a size), text, textarea or text_image (text with a picture; no values).
One of dropdown, swatch, number, dimensions, text, textarea, text_image.
A number’s or a size’s unit (in, cm, …).
A dropdown’s values (up to 500, the most an option holds). A typed option takes at most one: its price, cost and lead time.
Its cost; null: unknown. Needs costs.
One sentence shown online, up to 160 characters.
The picture’s shopify_file_id from POST /files: required with image_url, null with it.
Its picture: the url POST /files answered (a Shopify Files address); null removes it.
What customers see, when it differs.
Days it adds to the lead time (0 is Same day); null: none.
Its place in the list, from 0.
Its price, 0 or more (0 is Included).
#rrggbb, for a swatches option.
Its name, up to 255 characters: required for a dropdown’s value (a typed option’s one row is named after the option).
Returns
Created: allow_other, applies_to, category_ids, created_at, default_value, description, disabled, exclude_from_sku, id, label and more
Errors
Errors use { "error": { "code", "message" } }. Use code to handle the error. View all error codes.
The request isn’t valid (see error.code), or the API version isn’t supported.
No valid access token or API key.
The store’s subscription isn’t active.
Not allowed: the API is off for this store, or the caller lacks the scope or permission.
Not found, or not visible to this caller.
Wrong method for this path; Allow lists every method the path takes.
The request body didn’t arrive in time.
The same Idempotency-Key is still being processed (REQUEST_IN_PROGRESS), its outcome is unknown (OUTCOME_UNKNOWN: check the record), or the record changed since it was read.
The request body is too large.
The request is valid JSON but can’t be done (a rule of the store refuses it), or the Idempotency-Key was used with a different body.
The app is older than the oldest version still served (error.code CLIENT_TOO_OLD); see error.min_version and error.upgrade_url.
Over a rate limit; wait Retry-After seconds.
Something went wrong on our side. A write may have partly happened: check the record before retrying it.
Busy, switched off, or billing couldn’t be checked; wait Retry-After seconds.