Import a blog post from a markdown file
const url = 'https://apibase.ecomweb.app/api/v1/stores/example/blog/posts/import/markdown';const form = new FormData();form.append('markdown_file', 'file');form.append('featured_image', 'file');form.append('inline_images', 'file');form.append('title', 'example');form.append('slug', 'example');form.append('status', 'draft');form.append('should_publish', 'true');
const options = {method: 'POST', headers: {'x-api-key': '<x-api-key>'}};
options.body = form;
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://apibase.ecomweb.app/api/v1/stores/example/blog/posts/import/markdown \ --header 'Content-Type: multipart/form-data' \ --header 'x-api-key: <x-api-key>' \ --form markdown_file=@file \ --form featured_image=@file \ --form inline_images=@file \ --form title=example \ --form slug=example \ --form status=draft \ --form should_publish=trueCreates a post from a markdown file with frontmatter, uploading the referenced images, converting the markdown to HTML, generating the table of contents, creating or linking categories and tags, and linking suggested products. A post with the same slug is updated instead of duplicated. In the response, categories_created and tags_created are currently always 0. The post is a draft unless status or should_publish says otherwise. Send the request as multipart/form-data.
Required scopes: write:blog
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”The store’s ref, as returned by GET /stores.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The markdown file, with frontmatter.
The featured image referenced by the frontmatter.
Images referenced from the markdown body, up to 20.
Overrides the title from the frontmatter.
Overrides the slug from the frontmatter.
Publication status. Defaults to draft.
Publishes the post immediately, overriding status.
Responses
Section titled “Responses”object
The imported post.
object
Post body as HTML, or null when empty.
Table of contents generated from the headings in content.
object
Anchor ID of the heading.
Heading level, from 1 to 6.
Text of the heading.
Position of the heading in the post content.
Short summary shown in listings, or null.
URL of the featured image, or null.
SEO title and description. Present only when requested with include_seo_metadata.
object
Page title for search engines, or null.
Page description for search engines, or null.
Publication status. Only published posts are visible on the storefront list; unlisted posts are reachable by their link.
Categories of the post.
object
ID.
Display name.
URL slug, unique within the store.
Description. Present on categories only; null when none is set.
Hex colour such as #ff6600. Present on categories only; null when none is set.
Manual position in the category list. Present on categories only.
When it was created, as an ISO 8601 timestamp.
When it was last updated, as an ISO 8601 timestamp. Present on categories only.
Tags of the post.
object
ID.
Display name.
URL slug, unique within the store.
Description. Present on categories only; null when none is set.
Hex colour such as #ff6600. Present on categories only; null when none is set.
Manual position in the category list. Present on categories only.
When it was created, as an ISO 8601 timestamp.
When it was last updated, as an ISO 8601 timestamp. Present on categories only.
IDs of the products recommended in the post, in display order. Present on single-post responses.
Post ID.
Title.
URL slug, unique within the store.
Whether the post is marked as featured.
When a scheduled post will be published, as an ISO 8601 timestamp, or null.
When the post was published, as an ISO 8601 timestamp, or null while unpublished.
ID of the user who created the post, or null (for example when created with an API key).
Name or email of the author. Present when the author is known and, on lists, when include_author is set.
Number of storefront views.
Estimated reading time in minutes.
When the post was created, as an ISO 8601 timestamp.
When the post was last updated, as an ISO 8601 timestamp.
When the post was deleted, or null. Deleted posts are not returned.
File names of the missing images.
Number of new images uploaded.
Number of existing images reused when an existing post was updated.
Number of images referenced in the markdown that were not among the uploaded files.
Number of categories created. Currently always 0, whatever the import created.
Number of tags created. Currently always 0, whatever the import created.
A readable confirmation.
Example
{ "blog_post": { "status": "draft" }}The request is malformed or failed validation.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key is missing, invalid, revoked or expired.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}The key may not do this: a missing scope, a readonly key, a publishable key on a Store API route, or a disallowed origin.
object
The HTTP status code.
What went wrong; validation failures list one message per problem.
The HTTP status text, such as Bad Request.
object
A stable, machine-readable error code.
A human-readable explanation.
Extra context about the error, when there is any.
object
When the error happened, as an ISO 8601 timestamp.
Example generated
{ "statusCode": 1, "message": [ "example" ], "error": "example"}