Document publication interface

Publish new document content to the system, supporting the setting of basic information, content, classification, tags, custom fields, etc., and can also set product-related attributes such as publication time, price, and inventory.

Points to note

  • This interface uses the POST method, Content-Type is application/
  • The document needs to be published by a user who is logged in and has the corresponding publishing permissions
  • The document publishing time can be set for a future date, and the document will be published automatically at the specified time
  • The custom field must be defined in the document model in advance to take effect
  • The document may require review, and the corresponding review status will be returned according to the system settings

Request address

{域名地址}/api/archive/publish

Description:{域名地址}Replace it with your domain name, such ashttps://en.anqicms.com/api/archive/publish

Request Syntax

POST {域名地址}/api/archive/publish
Content-Type: application/json

Request Headers

This interface involves only public request headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Request parameters

Field name Type Required Description
Title string Is Document title
content string Is Document content
category_id int Is Document Category ID
keywords string No Document keyword
description string No Document summary, within 250 words
URL Token string No Custom URL alias, supports numbers and letters only
Images string array No Article group image, array, can set up to 9 images, repeat this field for multiple images. The first one is the logo
created_time int No Format: timestamp. The publication time of the document, which can be in the future. If it is in the future, the document will be officially released only after the time comes.
tags string array No Document Tag tag, array
Other custom field any No If you pass other custom fields and the document model contains the field, it also supports.
price int No Price, unit in cents, integer
stock int No Inventory
read_level int No reading level

Response header

This interface only involves common response headers. For more information, please refer toCommon Request Headers (Common Request Headers).

Return parameters

Field name Type Description
code int Error code
msg string Error description
data object result content

Data Result

Field name Type Description
id int Document ID
link string Document link
user_id int user ID
status int review status, 1 reviewed, 0 in review

Usage Example

Request example

POST /api/archive/publish HTTP/1.1
Host: your-domain.com
Content-Type: application/json

{
  "title": "欢迎使用anqicms",
  "content": "<p>欢迎使用anqicms</p>",
  "category_id": 2,
  "images": [
    "https://en.anqicms.com/uploads/arc1.png",
    "https://en.anqicms.com/uploads/arc2.png"
  ],
  "tags": ["安企CMS", "anqicms"],
  "quality": "高清"
}

Response Example

{
  "code": 0,
  "data": {
    "id": 33,
    "link": "https://en.anqicms.com/article/33.html",
    "status": 0
  },
  "msg": "发布成功"
}

error code

Error code Description
0 OK
-1 Error, the reason is indicated in msg
1001 Not logged in
1002 Not authorized