Cention
API Documentation
Cention Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Cention Library JSONAPI

  • To access Cention library, a JSON Web Token (JWT) with ‘Access to library’ claim attached is needed.
  • To create JWT go to Cention server → Administration tab → API → Access Tokens.
  • Check (tick) ‘Access to library’ from Others.
  • Make sure to fill up the Key field else Save button will not be activated.
  • Screenshot:

The API follows JSONAPI specification: http://jsonapi.org/ . Following is some of the specification that must follow:


Library

  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_libraries to GET all. If the name of your Cention workspace is “demo” and the cention api domain is apid.cention.com then the endpoint would be: https://apid.cention.com/s/demo/capi/json/c3_libraries
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_libraries/<id> to GET single library with database ID id.
  • Sample HTTP request body data format for GET all:
{
  "data": [
    {
      "type": "c3_libraries",
      "id": "3",
      "attributes": {
        "c3_id": 3,
        "external": false,
        "name": "cention-org - area-named-second"
      },
      "relationships": {
        "categories": {
          "data": [
            {
              "type": "c3_library_categories",
              "id": "3"
            }
          ]
        },
        "questions": {
          "data": [
            {
              "type": "c3_library_questions",
              "id": "2"
            }
          ]
        }
      }
    }
  ],
  "included": [
    {
      "type": "c3_library_attachments",
      "id": "2020",
      "attributes": {
        "attachment": {
          "c3_id": 2020,
          "content_type": "text\/plain",
          "name": "tst1_1.txt"
        },
        "c3_id": 2020
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_attachments\/2020"
        }
      }
    },
    {
      "type": "c3_library_questions",
      "id": "4",
      "attributes": {
        "answer": "New answer!",
        "c3_id": 4,
        "question": "",
        "subject": "asdadasdas"
      },
      "relationships": {
        "attachments": {
          "data": [
            {
              "type": "c3_library_attachments",
              "id": "2020"
            }
          ],
          "links": {
            "related": {
              "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/4\/attachments"
            },
            "self": {
              "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/4\/relationships\/attachments"
            }
          }
        }
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/4"
        }
      }
    },
    {
      "type": "c3_library_questions",
      "id": "2",
      "attributes": {
        "answer": "done!",
        "c3_id": 2,
        "question": "11th body<br\/>2nd line<br\/>",
        "subject": "11th title"
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/2"
        }
      }
    },
    {
      "type": "c3_library_questions",
      "id": "5",
      "attributes": {
        "answer": "done 2",
        "c3_id": 5,
        "question": "<div dir=\"ltr\">first HELP me!<\/div>\n",
        "subject": "help me!"
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/5"
        }
      }
    },
    {
      "type": "c3_libraries",
      "id": "4",
      "attributes": {
        "c3_id": 4,
        "external": false,
        "name": "cention-org - test-services-area"
      },
      "relationships": {
        "questions": {
          "data": [
            {
              "type": "c3_library_questions",
              "id": "5"
            },
            {
              "type": "c3_library_questions",
              "id": "4"
            }
          ]
        }
      }
    },
    {
      "type": "c3_library_categories",
      "id": "3",
      "attributes": {
        "c3_id": 3,
        "name": "old_libraries"
      },
      "relationships": {
        "libraries": {
          "data": [
            {
              "type": "c3_libraries",
              "id": "4"
            }
          ]
        }
      }
    }
  ]
}

Data.attributes

Field Type Description
external Boolean Flag indicate if the library external or not.
name String Library name.

Data.relationships

Field Type Description
libraries Object Sub-libraries (c3_libraries).
categories Object Sub-categories (c3_library_categories).
questions Object Questions under this library (c3_library_questions).

Query parameters

Field Type Description
data_url Boolean When true, any inlined area file archive image within library question will be parsed with data URL format where the file content is base64 encoded and embed inside library content.

External Library

  • Similar to library but only match library with external flag true and don’t return external attribute.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_external_libraries to GET all libraries with external flag true.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_external_libraries/<id> to GET single library with database ID id.
  • Sample HTTP request body data format GET single:
{
  "data": {
    "type": "c3_external_libraries",
    "id": "3",
    "attributes": {
      "c3_id": 3,
      "name": "cention-org - area-named-second"
    },
    "relationships": {
      "categories": {
        "data": [
          {
            "type": "c3_library_categories",
            "id": "3"
          }
        ]
      },
      "questions": {
        "data": [
          {
            "type": "c3_library_questions",
            "id": "2"
          }
        ]
      }
    }
  },
  "included": [
    {
      "type": "c3_library_questions",
      "id": "2",
      "attributes": {
        "answer": "ok one",
        "c3_id": 2,
        "question": "11th body<br\/>2nd line<br\/>",
        "subject": "11th title"
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/2"
        }
      }
    },
    {
      "type": "c3_library_questions",
      "id": "1",
      "attributes": {
        "answer": "n",
        "c3_id": 1,
        "question": "dfdgfd",
        "subject": "asdasda"
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/1"
        }
      }
    },
    {
      "type": "c3_libraries",
      "id": "4",
      "attributes": {
        "c3_id": 4,
        "external": false,
        "name": "cention-org - test-services-area"
      },
      "relationships": {
        "questions": {
          "data": [
            {
              "type": "c3_library_questions",
              "id": "1"
            },
            {
              "type": "c3_library_questions",
              "id": "2"
            }
          ]
        }
      }
    },
    {
      "type": "c3_libraries",
      "id": "3",
      "attributes": {
        "c3_id": 3,
        "external": true,
        "name": "cention-org - area-named-second"
      },
      "relationships": {
        "questions": {
          "data": [
            {
              "type": "c3_library_questions",
              "id": "2"
            }
          ]
        }
      }
    },
    {
      "type": "c3_library_categories",
      "id": "3",
      "attributes": {
        "c3_id": 3,
        "name": "old_libraries"
      },
      "relationships": {
        "libraries": {
          "data": [
            {
              "type": "c3_libraries",
              "id": "4"
            },
            {
              "type": "c3_libraries",
              "id": "3"
            }
          ]
        }
      }
    }
  ]
}

Data.attributes

Field Type Description
name String Library name.

Data.relationships

Field Type Description
libraries Object Sub-libraries (c3_libraries).
categories Object Sub-categories (c3_library_categories).
questions Object Questions under this library (c3_library_questions).

Query parameters

Field Type Description
data_url Boolean When true, any inlined area file archive image within library question will be parsed with data URL format where the file content is base64 encoded and embed inside library content.

Category

  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_categories to GET all.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_categories/<id> to GET single category with database ID id.
  • Data format return similar endpoint c3_libraries and c3_external_libraries.
  • Sample HTTP request body data format GET all:
{
  "data": [
    {
      "type": "c3_library_categories",
      "id": "2",
      "attributes": {
        "c3_id": 2,
        "name": "greeting"
      },
      "relationships": {
        "questions": {
          "data": [
            {
              "type": "c3_library_questions",
              "id": "5"
            }
          ]
        }
      }
    }
  ],
  "included": [
    {
      "type": "c3_library_questions",
      "id": "5",
      "attributes": {
        "answer": "ok\n",
        "c3_id": 5,
        "question": "<div dir=\"ltr\">first HELP me!<\/div>\n",
        "subject": "help me!"
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/5"
        }
      }
    }
  ]
}

Data.attributes

Field Type Description
name String Category name.

Data.relationships

Field Type Description
libraries Object Sub-libraries (c3_libraries).
categories Object Sub-categories (c3_library_categories).
questions Object Questions under this category (c3_library_questions).

Query parameters

Field Type Description
data_url Boolean When true, any inlined area file archive image within library question will be parsed with data URL format where the file content is base64 encoded and embed inside library content.

Library Question

  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_questions to GET all.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_libraries/<id>/questions to GET all questions belong to library id.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_questions/<id> to GET single question with database ID id.
  • Sample HTTP request body data format for single question:
{
  "data": {
    "type": "c3_library_questions",
    "id": "4",
    "attributes": {
      "answer": "New answer!",
      "c3_id": 4,
      "question": "",
      "subject": "asdadasdas"
    },
    "relationships": {
      "attachments": {
        "data": [
          {
            "type": "c3_library_attachments",
            "id": "2020"
          }
        ],
        "links": {
          "related": {
            "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/4\/attachments"
          },
          "self": {
            "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/4\/relationships\/attachments"
          }
        }
      }
    }
  },
  "included": [
    {
      "type": "c3_library_attachments",
      "id": "2020",
      "attributes": {
        "attachment": {
          "c3_id": 2020,
          "content_type": "text\/plain",
          "name": "tst1_1.txt"
        },
        "c3_id": 2020
      },
      "links": {
        "self": {
          "href": "https:\/\/test.example.com\/capi\/json\/c3_library_attachments\/2020"
        }
      }
    }
  ],
  "links": {
    "self": {
      "href": "https:\/\/test.example.com\/capi\/json\/c3_library_questions\/4"
    }
  }
}

Data.attributes

Field Type Description
subject String Subject field.
question String Question field.
answer String Answer field.

Data.relationships

Field Type Description
attachments Object Attachments for the library question (c3_library_attachments).

Query parameters

Field Type Description
data_url Boolean When true, any inlined area file archive image within library question will be parsed with data URL format where the file content is base64 encoded and embed inside library content.

Query parameters for GET all

Field Type Description
filter[toplist] Boolean Shown only the top list questions.
q_filter[phrase] String Search phrase.
q_filter[option] String Either ‘all’, ‘question’, or ‘answer’. Search phrase on which part of the library.

Library Attachment

  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_attachments/<id> to GET single library attachment with database ID id.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_questions/<id>/attachments to GET all attachments belong to question with database ID id.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_area_archives/<id> to GET single library inlined area file archive image with database ID id.
  • Use HTTP GET with endpoint: https://<cention api domain>/s/<workspace>/capi/json/c3_library_questions/<id>/embedded_archives to GET all inlined area file archived images belong to question with database ID id.
  • Sample HTTP request body data format single attachment:
{
  "data": {
    "id": "1270",
    "type": "c3_library_attachments",
    "attributes": {
      "attachment": {
        "c3_id": 1270,
        "content_type": "text\/plain",
        "name": "tst1_1.txt",
        "content": "QXBwbGUgUGVuIFBpbmVhcHBsZSBQZW4="
      },
      "c3_id": 1270
    }
  },
  "links": {
    "self": {
      "href": "https://test.example.com/capi/json/c3_library_attachments/1270"
    }
  }
}

Data.attributes

Field Type Description
content_type String File type RFC2616
name String Attachment file name.
content String Base64 encoded attachment content.

Query parameters

Field Type Description
without_content Boolean File content will not be returned when true.

References:

  1. JSONAPI specification.