Enonic version: 6.4.2
OS: Mac and Linux

Is there an API for adding, updating and deleting content, hopefully REST?

If not, could I add, update and delete content from within a controller?
Then I could simple load some endpoint, say once an hour, to run that controller to sync content.


I think there is not any REST interface that we can use that are supported. But we have used the content API and created our own service on top of that to create the REST API.

Content API doc:!/module-lib_xp_content.html

Ah I hadn’t notice contentLib had full CRUD :slight_smile:

So when you say “service” is that available from outside Enonic?

I would like to run this as a cron job.

Since Enonic is built on Java, I’m sure you could set up a CRON job somehow. Brighter minds than me would have to speak to how it would be done though.

A service is available as a mountable endpoint. Quoting the docs:

Services allow the creation of http endpoints without binding them to specific paths.

If you don’t need an endpoint (if you’re going to trigger this via CRUD, it seems like you might not), services are not the droids you are looking for. Simply create a Java class that does the dirty work for you. Again, I’m not sure how to run code on startup (i.e. register a CRUD operation), but perhaps @tsi or @bwe know?

I use the Content API in my feedback app if you want to see an example:

@ComLock A service in XP is a REST interface and are available from the “outside” from Enonic XP thru the Service URL.

I have a simple solution run with CRON that post content to our intranet from Enonic XP.
This is my content in that file that runs the REST/SERVICE script.

curl -u USER:PASSWORD “https://MYURL/_/service/MY APP/tripletex/company/projectsFee?poster=true”