Category

Path /{category-id}

Represents a Knowledge Library category. The /{category-id} node returns a single category.

Reading

You can read information about a category by making a Graph API GET request to /{category-id}.

Permissions

Reading Category node require Read Knowledge Library content permission.

Fields

Field NameDescriptionData Type

id

The category ID

string

title

The title of the category

string

content

The text content of the category's document

string

status

Indicates the status of the category

enum {PUBLISHED,DRAFT}

last_editor

The last member to edit the content.

User

read_audience

Users/Groups/Conditional access based on profile fields to read the content in the category.

JSON

color

The color of the category.

enum {LIGHT_GRAY, LIGHT_CYAN, LIGHT_TEAL, LIGHT_YELLOW, LIGHT_ORANGE, LIGHT_ORANGE_RED, LIGHT_RED, LIGHT_PINK, LIGHT_PURPLE, GRAY, CYAN, TEAL, GREEN, YELLOW, ORANGE, ORANGE_RED, RED, PINK, PURPLE, DARK_GRAY, DARK_CYAN, DARK_TEAL, DARK_YELLOW, DARK_ORANGE, DARK_ORANGE_RED, DARK_RED, DARK_PINK, DARK_PURPLE }

icon

The icon representing the category.

enum {AIRPLANE, PROFILE_CIRCLE, SCALE, HEART, BUILDING_CITY, PRIVACY, RIBBON, DIAGNOSED , BACKPACK, COIN_STACK, BADGE, READING_GLASSES, RUNNING, MENTORSHIP, DOCUMENTS, PIN_LOCAL_BUSINESS, TROPHY, STAR, FOUNDED, QUESTION_CIRCLE, FLASH_DEFAULT, COMPASS, BADGE_CHECKMARK, ROCKET, ARMCHAIR, HEALTH, VOLUNTEER, TOOTH, FAMILY, MORTAR_BOARD }

last_updated

The time when the category was last updated.

datetime

json_content

The formatted content of category in JSON.

JSON

parent_id

ID of parent category. Null/empty if category is a root category.

string

order_index

Sequence number of the category in the parent's hierarchy.

integer

Publishing

You can't publish using this node. To make a new category in a community, use the /community/knowledge_library_categories edge as described here.

Deleting

A category can be deleted by making a DELETE request to /{category_id}. You will need Manage Knowledge Library content permission.

Updating

A category can be updated by making a POST request on the /{category_id}. You will need Manage Knowledge Library content permission.

Edges

Edge NameDescription

/subcategories

All subcategories associated with a category. Use this edge to get the list of subcategories or to create a new subcategory.

/photos

Add a new photo to a category. It supports the following format:

  • JPEG
  • PNG

File Size:

  • Files must be 4MB or smaller in size.
  • For PNG files, try keep the file size below 1 MB. PNG files larger than 1 MB may appear pixelated after upload.

/videos

Add a new video to a category. It supports the following format: MP4

/files

Add a new file to a category

/comments

The comments on a category.Supports a summary field to get a total count.

/reactions

The Members who have reacted to this post. It supports

  • A summary field to get a total count.
  • since and until fields to get the number of reactions within a given time frame.

/seen

The Members who have seen this post.It supports

  • A summary field to get a total count.
  • since and until fields to get the number of reactions within a given time frame.

Note that this is subject to the same limitations as described here

Examples


Get the title, icon, color, json_content of a category

GET /{category_id}?fields=title,icon,color,json_content HTTP/1.1
        Host: graph.facebook.com


Publish a subcategory

POST /{category_id}/subcategories?
        title={...} &
        json_content={...}
        icon ={...}

        HTTP/1.1
        Host: graph.facebook.com


Get the audience of a category, including details on whether it was shared with groups, specific users or based on profile set conditions

GET /{category_id}?
        fields=read_audience
        {audience_type, 
        groups,
        static_users,
        profile_set_conditions}

        HTTP/1.1
        Host: graph.facebook.com


Set the audience of a category

POST /{category_id} HTTP/1.1
        Host: graph.facebook.com
 Payload:
 
  //Example 1:
 {
   "read_audience": {
        "audience_type": "PROFILE_FIELDS",
        "profile_set_conditions": [
            {
                "field": "LOCATION",
                "operator": "CONTAINS",
                "values": [
                    "London",
                    "San Francisco"
                ]
            },
            {
               "field": "TITLE",
                "operator": "CONTAINS",
                "values": [
                    "Engineer"
                ]
            }
        ]
    }
}
 
  //Example 2:
  {
 "read_audience": {
        "audience_type": "GROUPS",
        "groups": [{group_id_1},{group_id_2}]
    }
}
  
  //Example 3:
  //Only for subcategories to inherit the parent category's audience
 {
   "read_audience": {
        "audience_type": "INHERIT" 
    }
}


Upload a new photo (via url) to a category:

POST graph.facebook.com
        /{category-id}/photos?url={image-url}


Upload a new video (via url) to a category:

POST graph.facebook.com
        /{category-id}/videos?url={video-url}


Upload a new file(via url) to a category:

POST graph.facebook.com
        /{category-id}/files?url={file-url}&name={file_name}

The response payload after uploading photo/video/file will return an id that can be used in json_content for the root type image/video/resource_section respectively as described in the next section.


Get the comments for a category

Get /{category_id}/comments?
        summary=true

        HTTP/1.1
        Host: graph.facebook.com


Get the reactions for a category

Get /{category_id}/reactions?
        summary=true&
        since={unix_timestamp}&
        until={unix_timestamp}

        HTTP/1.1
        Host: graph.facebook.com


Deleting a category

DELETE /{category_id} HTTP/1.1
        Host: graph.facebook.com

This would remove the category from Knowledge Library.

Supported JSON Content Syntax

json_content

 {
  "json_content": [
    {
      "type": {root_type},
    }
  ],
}

json_content[]

PropertyTypeDescription

type

String

The root type should be either text_block, image, video, resource_section or embedded_media

children

Object[]

Array of nodes

Only applicable for text_block

image_data

Object

Details of the image such as id.

Only applicable for image

halign

ENUM {left,right,center}

Horizontal alignment of the image.

Only applicable for image

image_width

Integer

Width of the image.

Only applicable for image

video_data

Object

Details of the video such as id.

Only applicable for video

is_gif

Boolean

Flag indicating if the video is a gif

Only applicable for video

name

String

Name of the section

Only applicable for resource_section

url

URL

Video url from supported websites, including: Workplace, Facebook, Vimeo and Youtube.

Only applicable for embedded_media


Root Type Example: Text Block

 {
      "type": "text_block",
      "children": [
        {
          "type": "h1",
          "children": [
            {
              "type": "text",
              "text": "Header 1"
            }
          ]
        },
        {
          "type": "p",
          "children": [
            {
              "type": "text",
              "text": "This is a paragraph"
            }
          ]
        },
      ]
    }


Root Type Example: Image

{
      "type": "image",
      "image_data": {
        "id": {image_id}
      },
      "image_width": 440,
      "halign": "center"
    }


Root Type Example: Video

 {
      "type": "video",
      "video_data": {
        "id": {video_id}
      },
      "is_gif": false
    }


Root Type Example: Resource Section

{
	"type": "resource_section",
	"name": {section_name},
	"children": [{
			"type": "resource_file",
			"file_data": {
				"id": {file_id}
			},
			"name": {file_name},
			"description": {file_description}
		},
		{
			"type": "resource_link",
			"href": {file_url},
			"name": {file_name},
			"description": {file_description}
		}
	]
}}
  


Root Type Example: Embedded Media

 {
      "type": "embedded_media",
      "url": {url}
    }

json_content[].children[]

PropertyTypeDescription

type

String

Possible child type for:

  • text_block: h1, h2, ol,p, code, ul
  • resource_section: resource_file, resource_link

children

Object[]

Array of child nodes as described in the next table

TypeDescription

h1

Heading 1

Possible children: mention, b,u, s, i, a, text

h2

Heading 2

Possible children: mention, b,u, s, i, a, text

ol

  1. Numbered List
Possible children: li

p

Defines a paragraph


Possible children: mention, b,u, s, i, a, text

code

code

Possible children: mention, b,u, s, i, a, text

ul

  • Bulleted List
Possible children: li

mention

Mention a Member


Along with this type the other fields present are created by and entity(Workplace Member)


Possible children: b,u, s, i, a, text

b

Bold

Possible children: mention, u, s, i, a, text

u

Underline

Possible children: mention, b, s, i, a, text

s

Strikethrough

Possible children: mention, b, u, i, a, text

i

Italics

Possible children: mention, b, u, s,a, text

a

Hyperlink

Possible children: b, u, s, i, text

text

Text

This is the ultimate child of all child types when the root type is text_block and is of type string

resource_file

Object

Details of the resource file within a resource_section such as name, description and file_data (containing file_id)

resource_link

Object

Details of the resource link within resource_section such as name, description and href


Examples

  • Mention
 {
	"type": "mention",
	"children": [{
		"type": "text",
		"text": "Mentioned Member"
	}],
	"created_by": {
		"id":{creator_member_id},
		"name": "Creator Member"
	},
	"entity": {
		"id": {mentioned_member_id},
		"name": "Mentioned Member"
	}
}
  • Formatted Text
 {
 	"type": "p",
 	"children": [{
 		"type": "b",
 		"children": [{
 			"type": "i",
 			"children": [{
 				"type": "u",
 				"children": [{
 					"type": "text",
 					"text": "Example Content which is Bold, Italics & Underlined"
 				}]
 			}]
 		}]
 	}]
 }
  • Numbered List
 {
 	"type": "ol",
 	"children": [{
 			"type": "li",
 			"children": [{
 				"type": "text",
 				"text": "Item 1"
 			}]
 		},
 		{
 			"type": "li",
 			"children": [{
 				"type": "text",
 				"text": "Item 2"
 			}]
 		}
 	]
 }
  • Code
{
	"type": "code",
	"children": [{
		"type": "b",
		"children": [{
			"type": "text",
			"text": "console.log(\"Bold\")"
		}]
	}]
}
  • Hyperlink
 {
	"type": "a",
	"children": [{
		"type": "text",
		"text": {link_text}
	}],
	"href": {url}
}