Create a new page

    Bludit API provides the features to create a new page.

    All request to the API need the API Token, you can find the token in the settings of the plugin.

    All request to the API to write content is necessary to provide an Authorization Token. To get this kind of token you need a user with ADMINISTRATOR role. You can get the Authorization Token on Admin panel > Manage > Users > {Username} > Edit User > Authentication Token > Token.

    Request

    • Endpoint: /api/pages
    • Method: POST
    • Content-Type: application/json
    • Content
    {
        "token": "24a8857ed78a8c89a91c99afd503afa7",
        "authentication": "193569a9d341624e967486efb3d36d75",
        "title": "My dog",
        "content": "Content of the page here, support Markdown code and HTML code."
    }

    Response

    • HTTP Code: 200
    • Content-Type: application/json
    • Content
    {
        "status": "0",
        "message": "Page created.",
        "data": {
            "key": "my-dog"
        }
    }

    CURL command example

    Here is an example that shows you how to create a new page via the command line with the command curl. The file data.json has the basic data needed to create a new page.

    File data.json

    {
        "token": "24a8857ed78a8c89a91c99afd503afa7",
        "authentication": "193569a9d341624e967486efb3d36d75",
        "title": "My dog",
        "content": "Content of the page here, support Markdown code and HTML code."
    }

    Execute the command and attach the file data.json

    $ curl -vvv \
        -X POST \
        -H "Content-Type: application/json" \
        -d @data.json \
        "https://example.com/api/pages"
    
    > POST /api/pages HTTP/1.1
    > Host: example.com
    > User-Agent: curl/7.54.0
    > Accept: */*
    > Content-Type: application/json
    
    < HTTP/1.1 200 OK
    < Date: Sun, 27 Aug 2017 18:58:25 GMT
    < Set-Cookie: Bludit-KEY=3de3df692e83b9cbbf5d31de385110bb; path=/; HttpOnly
    < Expires: Thu, 19 Nov 1981 08:52:00 GMT
    < Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    < Pragma: no-cache
    < Access-Control-Allow-Origin: *
    < Content-Length: 50731
    < Content-Type: application/json
    
    {
        "status": "0",
        "message": "Page created.",
        "data": {
            "key": "my-dog"
        }
    }