.. _types:

Types
=====

.. note::
    These docs are generated by code tests, therefore you will see some 'test' contenttypes appear here.

Available content types in a Plone site can be listed and queried by accessing the ``/@types`` endpoint on any context (requires an authenticated user). The 'addable' key specifies if the content type can be added to the current context. The 'layouts' key specifies the defined views.


..  http:example:: curl httpie python-requests
    :request: ../../src/plone/restapi/tests/http-examples/types.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/types.resp
   :language: http



To get the schema of a content type, access the ``/@types`` endpoint  with the name of the content type, e.g. '/plone/@types/Document':

..  http:example:: curl httpie python-requests
    :request: ../../src/plone/restapi/tests/http-examples/types_document.req

.. literalinclude:: ../../src/plone/restapi/tests/http-examples/types_document.resp
   :language: http

The content type schema uses the `JSON Schema <http://json-schema.org/>`_ format.
The tagged values for the widgets are also exposed in the the "properties" attribute of the schema.

For ``Choice`` fields, their vocabulary or source will be linked to in a ``vocabulary`` or ``querysource`` property (one or the other, never both):


- If a ``querysource`` property is included, that field is backed by an ``IQuerysource``.
  In that case, the source's terms can't be enumerated, and the terms need to be **queried** by issuing a request to the linked endpoint and including the user's search terms in the ``?query=`` parameter.
- If a ``vocabulary`` property is included, the field is backed by a vocabulary or another kind of iterable source.
  The terms can then be **enumerated** by issuing a request to the linked endpoint.

See :ref:`vocabularies` for details on these endpoints.

See :ref:`types-schema` for a detailed documentation about the available field types.
