Write a blog post
const url = 'https://example.com/storefront/posts';const options = { method: 'POST', headers: { cookie: '__Host-bottle.session_token=<__Host-bottle.session_token>', 'Content-Type': 'application/json' }, body: '{"title":"example","slug":"refills-and-swaps","excerpt":"","bodyHtml":null,"coverKey":null,"coverAlt":"","authorName":"","publishedOn":null,"tags":[],"seoTitle":"","seoDescription":"","status":"draft"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/storefront/posts \ --header 'Content-Type: application/json' \ --cookie __Host-bottle.session_token=<__Host-bottle.session_token> \ --data '{ "title": "example", "slug": "refills-and-swaps", "excerpt": "", "bodyHtml": null, "coverKey": null, "coverAlt": "", "authorName": "", "publishedOn": null, "tags": [], "seoTitle": "", "seoDescription": "", "status": "draft" }'A new post, a draft unless status says published. Without a slug, one is made from the title. A published post shows from publishedOn, the day it is first published unless given one, so it can be written ahead. The body is rich text: paragraphs, two sizes of heading, bold, italic, lists, quotes, links (https, email, or a path on the shop such as /delivery), pictures and product blocks. Anything else is removed, and it is cleaned again whenever it is read. A picture is <img src="/api/public/images/{key}/large" alt="…"> with a key from POST /storefront/assets and words saying what it shows; one without words, or from anywhere else, is dropped. A product block is <bottle-products data-ids="{id},{id}"></bottle-products> with up to four of the business’s own product ids; the shop draws each as a card with its live name, picture and price, and leaves out any not on sale.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Lower-case letters, digits and single dashes, as in refills-and-swaps.
Example
refills-and-swapsUp to five short tags, such as Barbecues or Safety.
Draft: only the business sees it, in the preview. published: on the shop.
Responses
Section titled “Responses”The post
object
UUID v7
object
Draft: only the business sees it, in the preview. published: on the shop.
Example
{ "id": "019205d1-6e7a-7c3b-9f6e-3a2b1c0d9e8f", "status": "draft"}Not signed in
object
Example
{ "error": "not_found", "message": "Customer not found"}The plan does not include a shop
object
Example
{ "error": "not_found", "message": "Customer not found"}Not a member, or without the permission this needs
object
Example
{ "error": "not_found", "message": "Customer not found"}Another post has that address
object
Example
{ "error": "not_found", "message": "Customer not found"}Validation failed
object
object
Example
{ "error": "validation", "issues": [ { "path": "email", "message": "Invalid email" } ]}