We're excited to announce an important addition to our API capabilities. You can now manage and access content revision history programmatically with our new Revisions API endpoints. These endpoints allow you to track changes to your content over time and restore previous versions as needed.
1. Get Revisions Endpoint and SDK Method
The new endpoint allows you to retrieve a list of all revisions for a specific Object. This gives you a complete history of changes made to your content.
REST API:
GET /v3/buckets/:bucket_slug/objects/:object_id/revisions
With the JavaScript SDK, you can easily access revisions:
await cosmic.objectRevisions.find('object-id').props([
'id',
'title',
'created_at',
'status'
]).limit(10)
2. Single Revision Endpoint and SDK Method
The new endpoint allows you to retrieve a specific revision by its ID. This is useful when you need to examine or restore a particular version of your content.
REST API:
GET /v3/buckets/:bucket_slug/objects/:object_id/revisions/:revision_id
With the JavaScript SDK:
await cosmic.objectRevisions.findOne({
objectId: 'object-id',
revisionId: 'revision-id'
}).props([
'id',
'title',
'metadata',
'created_at'
])
3. Add a Revision API
You can now programmatically create new revisions of your content using the API, giving you more control over your content versioning:
await cosmic.objectRevisions.insertOne('object-id', {
title: 'Updated Blog Post Title',
metadata: {
content: 'This is the updated content for the blog post...',
featured_post: true
},
status: 'draft'
})
Documentation Updates
Full documentation for these new endpoints is available at https://www.cosmicjs.com/docs/api/revisions.
New LLMS Resource for AI-Enhanced Workflows
We've also added a new resource for developers using AI in their workflows. You can now access the raw markdown content of our documentation at
https://www.cosmicjs.com/docs/llms.txt
or by appending
.md
to any documentation URL (e.g.,
https://www.cosmicjs.com/docs/api/objects.md
). You can also find a new Copy Page button on the top right of each page. This makes it easier to use our documentation with AI code assistants and LLM tools.
Each blog post now includes a Copy Markdown button at the top of the page which enables you to paste into your code editor. Check out the Spotify clone article to create this app in a single prompt.
These enhancements give you more power to track, manage, and restore content throughout its lifecycle. We're committed to providing the tools you need to create and maintain exceptional content experiences.