Docswrite API
Introduction
You can make a POST
request to the endpoint URL to create/update a blog post/page on your WordPress site.
You can even mention most of the parameters in the Google Docs document itself.
- Create a table in the Google Docs document. It should be the first table in the document.
- The table should have two columns. The first column should contain the parameter name and the second column should contain the parameter value.
- The column name should be
docswrite_settings
. Otherwise, we won't be able to read the table.
For example, you can add a title
parameter in the Google Docs document itself and it will be used as the title of the blog post.
Link to the Google Docs (opens in a new tab)
First, you need to connect your WordPress site to Docswrite. Once you have connected your WordPress site, you will be able to make API requests to create & update posts and pages on your WordPress site.
Endpoint URL to create/update a blog post/page on WordPress
- Login to your Docswrite account (opens in a new tab) and go to the settings page.
- Grab the endpoint URL from the Docswrite settings page. It will look something like this:
https://api.docswrite.com/api/export?token=xxx
Parameters to create/update a blog post/page on WordPress
google_docs_url
(required) (API requests only)
The URL of the Google Document that contains the content of the blog post. The google doc must be shared with "anyone with link." This is extremely important and otherwise we won't be able to read the google doc. This parameter is required.
title
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
The title of the blog post. If not provided, the title of the Google Docs will be used.
slug
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
The slug you want to use for the blog post. If not provided, the slug will be generated from the title of the blog post.
tags
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
A comma-separated list of tags associated with the blog post. If any of the tags do not exist, they will be created.
categories
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
A comma-separated list of categories associated with the blog post. If any of the categories do not exist, they will be created.
state
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
The state of the blog post. This can be one of publish
or draft
. If not provided, the default state is draft
. If you set a date
parameter, the state will be set to future
automatically.
author
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
The exact username of the user who created the blog post. You may use the full name of the author. We will try to find the user with the given username or full name. If not provided, the default author is the user who created the API token.
date
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
If you want to schedule the blog post for a future date, you can provide the date in the following format: YYYY-MM-DD HH:MM:SS
. If you provide a date, the state of the blog post will be set to future
.
excerpt
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
An excerpt of the blog post that can be used as the meta description for SEO purposes.
post_type
(optional) (This parameter can be mentioned in the Google Docs Table and API request)
The type of the blog post. This can be one of post
or page
. If not provided, the default post type is post
.
featured_image_url
(optional) (only for API requests)
The URL of the featured image for the blog post. The image will be downloaded and set as the featured image for the blog post.
featured_image_alt_text
(optional) (only for API requests)
The alt text for the featured image.
featured_image_caption
(optional) (only for API requests)
The caption for the featured image.
export_settings
(optional) (only for API requests)
The export settings for the blog post. This is an json object that contains the following parameters:
compress_images
(optional) If set totrue
, the images will be compressed before they are uploaded to the WordPress site. The default value istrue
.demote_headings
(optional) If set totrue
, the headings will be demoted by one level. For example, if the document contains anh1
heading, it will be converted to anh2
heading. The default value isfalse
.convert_to_webp
(optional) If set totrue
, the images will be converted to the WebP format. The default value istrue
.first_image_as_featured_image
(optional) If set totrue
, the first image in the document will be set as the featured image for the blog post. The default value istrue
.add_no_follow_to_external_links
(optional) If set totrue
, the external links will be set tonofollow
. The default value istrue
.bold_as_strong
(optional) If set totrue
, the bold text will be converted to thestrong
tag. The default value isfalse
.
newspack_settings
(optional) (only for Newspack sites) (only for API requests)
The newspack settings for the blog post. This is an json object that contains the following parameters:
newspack_article_summary
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Newspack article summary for the blog post.newspack_article_summary_title
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Newspack article summary title for the blog post.newspack_post_subtitle
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Newspack post subtitle for the blog post.
You need to download and install the
Docswrite plugin
on your WordPress site to use Yoast & Rank Math SEO features.
yoast_settings
(optional) (only for Yoast sites) (only for API requests)
The Yoast settings for the blog post. You must install the Docswrite Plugin. This is an json object that contains the following parameters:
yoast_focuskw
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Yoast focus keyword for the blog post.yoast_metadesc
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Yoast meta description for the blog post.yoast_title
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Yoast title for the blog post.yoast_canonical
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The Yoast canonical URL for the blog post.
rankmath_settings
(optional) (only for RankMath sites) (only for API requests)
The RankMath settings for the blog post. You must install the Docswrite Plugin. This is an json object that contains the following parameters:
rank_math_focus_keyword
(optional) (This parameter can be mentioned in the Google Docs Table and API request) The RankMath focus keyword for the blog post.
Example Request body
{
"google_docs_url": "https://docs.google.com/document/d/1aBcDeFgHiJkLmNopQrStUvWxYz/edit?usp=sharing",
"title": "Example Blog Post Title",
"slug": "example-blog-post-title",
"tags": "example, blog post",
"categories": "uncategorized",
"state": "draft",
"author": "Jane Doe",
"date": "2023-04-01 09:00:00",
"excerpt": "This is an example excerpt for the blog post.",
"post_type": "post",
"featured_image_url": "https://images.unsplash.com/photo-1662572091420-95992f339784?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80",
"featured_image_alt_text": "Example Featured Image Alt Text",
"featured_image_caption": "Example Featured Image Caption",
"export_settings": {
"compress_images": true,
"demote_headings": false,
"convert_to_webp": true,
"first_image_as_featured_image": true,
"add_no_follow_to_external_links": true,
"bold_as_strong": false
},
"newspack_settings": {
"newspack_article_summary": "This is an example article summary for the blog post.",
"newspack_article_summary_title": "Example Article Summary Title",
"newspack_post_subtitle": "Example Post Subtitle"
},
"yoast_settings": {
"yoast_focuskw": "example",
"yoast_metadesc": "This is an example meta description for the blog post.",
"yoast_title": "Example Blog Post Title"
},
"rankmath_settings": {
"rank_math_focus_keyword": "example"
}
}