Learn how Scrivito CMS can help you deliver amazing digital experiences
See Scrivito CMS in action

Create or update an object

Creates or updates a CMS object.

PUT /tenants/:tenant_id/workspaces/:working_copy_id/objs/:obj_id

For creating an object, provide a randomly generated hexadecimal ID (16 characters long) for the :obj_id parameter, for example using the shell command openssl rand -hex 8. If the object does not exist, it will be created if at least _obj_class has been specified.

If the object does not exist in the working copy but still exists in published, its content is restored. Any object attribute which is not explicitly overwritten will be restored to its previous value.

Params

  • tenant_id – The ID of the tenant.
  • working_copy_id – The ID of the working copy
  • obj_id – The ID of the object to be updated or created.

Params as part of the payload

  • obj – object attributes.
    • The following internal attributes can be specified (internal attributes other than these will be silently ignored).
      • _conflicts
      • _id
      • _path
      • _permalink
      • _site_id
      • _restriction
      • _widget_pool
    • For custom attributes, specify a pair made up of a type and a value. Valid types are:
      • binary
      • boolean
      • date
      • html
      • link
      • linklist
      • number
      • reference
      • referencelist
      • string
      • stringlist
      • widget
      • widgetlist

Example of the obj parameter:

{ "_obj_class": "Publication", "_restriction": ["_auth"], "title": ["string", "My Object Title"] }

Response

The created or updated object.

Error codes

  • precondition_not_met.obj_not_found
  • precondition_not_met.workspace_not_found
  • validation.illegal_value
  • validation.invalid_value

Example

curl \ -X PUT \ -H 'Content-Type: application/json' \ -u 'api_token:MYTOKEN' \ -d '{ "obj": { "_id": "3a3a11c8c4775cde", "_obj_class": "Page", "title": ["string", "the obj title"] } }' \ https://api.scrivito.com/tenants/:tenant_id/workspaces/:ws_id/objs/:obj_id
{ "_created_at": "20190322170625", "_id": "3a3a11c8c4775cde", "_obj_class": "Page", "title": ["string", "the obj title"], ... }