Docswrite API
Introduction
Docswrite API is a RESTful API that allows you to create, update posts and pages on WordPress sites.
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
The request body contains the following parameters:
google_docs_url
(required)
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)
The title of the blog post. If not provided, the title of the Google Docs will be used.
slug
(optional)
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)
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)
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)
The state of the blog post. This can be one of publish, future, 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)
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)
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)
An excerpt of the blog post that can be used as the meta description for SEO purposes.
post_type
(optional)
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)
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)
The alt text for the featured image.
featured_image_caption
(optional)
The caption for the featured image.
export_settings
(optional)
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
.
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
}
}