REST API

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.

Demo Google Docs with table 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

  1. Login to your Docswrite account (opens in a new tab) and go to the settings page.

Grab endpoint url

  1. Grab the endpoint URL from the Docswrite settings page. It will look something like this:
https://api.docswrite.com/api/export?token=xxx
 

Supported parameters

Click here to see the list of supported parameters

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,
    "wp_content_editor": "classic"
  },
  "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"
  }
}

Job Status Tracking

When you create a post using the API, you'll receive a jobId in the response. You can use this ID to track the status of your job.

Example Response with Job ID

{
  "error": false,
  "message": "Post added to queue",
  "data": {
    "google_docs_url": "https://docs.google.com/document/d/1aBcDeFgHiJkLmNopQrStUvWxYz/edit?usp=sharing",
    "title": "Example Blog Post Title",
    "jobId": "job-123" // This is the ID you'll use to track the job status
  }
}

Checking Job Status

You can check the status of your job using the following endpoint:

POST /api/job/status

Headers

x-access-token: YOUR_JWT_TOKEN

Request Body

{
  "jobId": "job-123",
  "queueType": "post"
}

Response

{
  "success": true,
  "data": {
    "id": "job-123",
    "state": "completed", // or "failed", "active", "waiting", "delayed"
    "progress": 100,
    "returnValue": {},
    "failedReason": null,
    "timestamp": 1234567890,
    "processedOn": 1234567890,
    "finishedOn": 1234567890
  }
}

Example cURL Request

curl -X POST 'https://api.docswrite.com/api/job/status' \
  -H 'Content-Type: application/json' \
  -H 'x-access-token: YOUR_JWT_TOKEN' \
  -d '{
    "jobId": "job-123",
    "queueType": "post"
  }'

Job States

  • completed: Job finished successfully
  • failed: Job failed with an error
  • active: Job is currently being processed
  • waiting: Job is in the queue waiting to be processed
  • delayed: Job is scheduled to run later
ℹ️

You can only check the status of jobs that you created. The API will return a 403 error if you try to check someone else's job.