Cosmic Object revisions API
Revisions are the version history of an Object. They can be created and read, but never edited or deleted.
Revisions are the version history of an Object. They can be created and read, but never edited or deleted.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/cosmicjs-com:cosmicjs-com-object-revisions-api"
curl "https://apis.io/api/v1/apis?limit=25"
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. By signing up you are subscribing to the APIs.io and API Evangelist newsletters — you can unsubscribe from any issue. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Cosmic REST API v3 Object revisions API
version: 3.0.0
summary: Read and write content, content models, and media in a Cosmic Bucket.
description: 'The Cosmic v3 REST API for content operations against a single Bucket.
## When to use this API
Reach for this API to model content (Object types and Metafields), create and query content (Objects), read version history (Revisions), and manage media metadata. A Bucket is the unit of isolation: every path below is scoped to one Bucket slug, and the access keys are per-Bucket.
## Authentication
Reads use the Bucket read key as a `read_key` query parameter. Writes use the Bucket write key as an `Authorization: Bearer` header. Both keys are found under Bucket > Settings > API Access in the dashboard. There is no account-level credential: a key grants access to exactly one Bucket.
## Scope of this document
This document describes only the endpoints served by `https://api.cosmicjs.com/v3`. Other documented parts of the Cosmic surface live on different hosts and are not yet specified here:
- Agent signup, agent status, and user endpoints (`/v3/agents/*`, `/v3/users/*`) are served by `https://dapi.cosmicjs.com`. An agent with no prior Cosmic account should start at `POST https://dapi.cosmicjs.com/v3/agents/sign-up`.
- Media upload (`POST /v3/buckets/{slug}/media`) is served by `https://workers.cosmicjs.com`. Media read, update, and delete are on this host and are specified below.
- AI generation endpoints (`/v3/ai/*`) are served by `https://dapi.cosmicjs.com`.
Be aware of one quirk when probing this host: an unrecognized path under `/v3` currently answers `200` with a body of `{"message":"Route not found", ...}` rather than a `404`. Treat that body, not the status line, as the signal that a path does not exist. The response names the host that serves the path you probably wanted.'
termsOfService: https://www.cosmicjs.com/terms-of-service
contact:
name: Cosmic Support
email: support@cosmicjs.com
url: https://www.cosmicjs.com/contact
license:
name: Proprietary
url: https://www.cosmicjs.com/terms-of-service
servers:
- url: https://api.cosmicjs.com/v3
description: Production
security:
- readKey: []
tags:
- name: Object revisions
description: Revisions are the version history of an Object. They can be created and read, but never edited or deleted.
externalDocs:
url: https://www.cosmicjs.com/docs/api/revisions
paths:
/buckets/{slug}/objects/{object_id}/revisions:
parameters:
- $ref: '#/components/parameters/BucketSlug'
- $ref: '#/components/parameters/ObjectId'
get:
operationId: listObjectRevisions
tags:
- Object revisions
summary: List an Object's revisions
description: Retrieve the version history of an Object, newest first by default. Revisions are immutable.
parameters:
- $ref: '#/components/parameters/ReadKey'
- $ref: '#/components/parameters/PreviewToken'
- $ref: '#/components/parameters/Props'
- $ref: '#/components/parameters/RevisionSort'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Skip'
- $ref: '#/components/parameters/UseCache'
- $ref: '#/components/parameters/Pretty'
responses:
'200':
description: The Object's revisions.
content:
application/json:
schema:
$ref: '#/components/schemas/RevisionListResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
$ref: '#/components/responses/PaymentRequired'
'404':
$ref: '#/components/responses/NotFound'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/InternalServerError'
post:
operationId: createObjectRevision
tags:
- Object revisions
summary: Add a revision to an Object
description: 'Create a new revision of an Object without publishing it. The revision is created with status `draft`; publish it by updating the Object itself with `status: published`. Use this to stage an edit for review rather than changing live content.'
security:
- writeKey: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RevisionCreate'
examples:
draftEdit:
summary: Stage a title and content edit
value:
title: Updated Blog Post Title
metadata:
content: This is the updated content for the blog post...
featured_post: true
status: draft
responses:
'200':
description: The created revision.
content:
application/json:
schema:
$ref: '#/components/schemas/RevisionResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
$ref: '#/components/responses/PaymentRequired'
'404':
$ref: '#/components/responses/NotFound'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/InternalServerError'
/buckets/{slug}/objects/{object_id}/revisions/{revision_id}:
parameters:
- $ref: '#/components/parameters/BucketSlug'
- $ref: '#/components/parameters/ObjectId'
- $ref: '#/components/parameters/RevisionId'
get:
operationId: getObjectRevision
tags:
- Object revisions
summary: Get a single revision
description: Retrieve one revision of an Object by its id, including the `metadata` values as they were at that point in history.
parameters:
- $ref: '#/components/parameters/ReadKey'
- $ref: '#/components/parameters/PreviewToken'
- $ref: '#/components/parameters/Props'
- $ref: '#/components/parameters/UseCache'
- $ref: '#/components/parameters/Pretty'
responses:
'200':
description: The requested revision.
content:
application/json:
schema:
$ref: '#/components/schemas/RevisionResponse'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'402':
$ref: '#/components/responses/PaymentRequired'
'404':
$ref: '#/components/responses/NotFound'
'429':
$ref: '#/components/responses/TooManyRequests'
'500':
$ref: '#/components/responses/InternalServerError'
components:
responses:
TooManyRequests:
description: Too many requests hit the API too quickly. Back off and retry.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
status: 429
message: Too many requests.
NotFound:
description: The addressed resource does not exist in this Bucket. Note that this covers a resource missing from a route that exists; an unrecognized route answers 200 with a `Route not found` body instead, as described in the API description above.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
status: 404
message: 'object with id: ''5ff75368c2dfa81a91695cec'' not found in bucket ''my-bucket'''
Unauthorized:
description: The access key is missing or incorrect.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
status: 401
message: Not authorized. This Bucket requires the correct read access key. Find this in Bucket > Settings in your Dashboard after logging in. Read the docs for more info https://www.cosmicjs.com/docs
PaymentRequired:
description: The Bucket needs to be upgraded before it can be used again.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
status: 402
message: Payment required. Please upgrade your plan to continue.
BadRequest:
description: The request was invalid, most often a malformed `query` or a Metafield value that failed validation.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
status: 400
message: 'Metafield validation: invalid ''value'' for metafield with key: ''number'' and type: ''number'''
InternalServerError:
description: Something went wrong on the Cosmic side.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
status: 500
message: Internal server error. Please contact support@cosmicjs.com
parameters:
Limit:
name: limit
in: query
required: false
description: Maximum number of results to return.
schema:
type: integer
minimum: 1
default: 1000
Skip:
name: skip
in: query
required: false
description: 'Offset pagination: number of results to skip. Use `after` instead for large collections. Only one of `skip` and `after` may be used.'
schema:
type: integer
minimum: 0
default: 0
Props:
name: props
in: query
required: false
description: Comma-separated list of properties to return, including nested metadata paths. Omit to return everything. Narrowing `props` is the main way to keep responses under the 6 MB response cap and to reduce latency.
schema:
type: string
example: id,slug,title,metadata.content,metadata.image.imgix_url
UseCache:
name: useCache
in: query
required: false
description: Set to `false` to bypass the cache and read through to the database. Guarantees you see writes you just made, at the cost of higher latency.
schema:
type: boolean
default: true
PreviewToken:
name: preview_token
in: query
required: false
description: A short-lived JWT issued by the Cosmic dashboard (object editor > Preview). When present and valid, the request is treated as `status=any` so the latest draft is returned. Bound to one Bucket for one hour. Still requires `read_key`. Invalid or expired tokens return 401.
schema:
type: string
ObjectId:
name: object_id
in: path
required: true
description: The Object id.
schema:
type: string
example: 5ff75368c2dfa81a91695cec
Pretty:
name: pretty
in: query
required: false
description: Set to `true` to indent the JSON response for human reading. Increases response size.
schema:
type: boolean
default: false
BucketSlug:
name: slug
in: path
required: true
description: The Bucket slug. Found under Bucket > Settings in the dashboard.
schema:
type: string
example: my-bucket
RevisionSort:
name: sort
in: query
required: false
description: Sort order. Prefix with `-` for descending.
schema:
type: string
enum:
- created_at
- -created_at
default: -created_at
RevisionId:
name: revision_id
in: path
required: true
description: The revision id.
schema:
type: string
example: 64fe8a1b24090e0008683e53
ReadKey:
name: read_key
in: query
required: false
description: The Bucket read key. Required unless the Bucket has no read key configured.
schema:
type: string
schemas:
Error:
type: object
description: The error shape returned by every non-2xx response.
required:
- status
- message
properties:
status:
type: integer
description: The HTTP status code, repeated in the body.
message:
type: string
description: A human-readable explanation that tries to name the specific problem.
documentation:
type: string
format: uri
description: Where to look for the correct usage. Present on the `Route not found` response returned for unrecognized paths.
hints:
type: array
description: Recovery suggestions, such as the host that actually serves the requested path. Present on the `Route not found` response returned for unrecognized paths.
items:
type: string
details:
type: array
description: Per-field validation failures, when the error came from schema validation.
items:
type: object
additionalProperties: true
RevisionListResponse:
type: object
required:
- revisions
properties:
revisions:
type: array
items:
$ref: '#/components/schemas/Revision'
total:
type: integer
limit:
type: integer
Revision:
type: object
description: An immutable snapshot of an Object at a point in time.
properties:
id:
type: string
object_id:
type: string
description: The Object this revision belongs to.
type:
type: string
title:
type: string
slug:
type: string
status:
type: string
enum:
- published
- draft
content:
type:
- string
- 'null'
deprecated: true
metadata:
$ref: '#/components/schemas/Metadata'
bucket:
type: string
thumbnail:
type:
- string
- 'null'
locale:
type:
- string
- 'null'
created_at:
type: string
format: date-time
created_by:
type: string
modified_at:
type: string
format: date-time
published_at:
type:
- string
- 'null'
format: date-time
additionalProperties: true
Metadata:
type: object
description: 'Values of the Metafields defined on the Object type, keyed by Metafield `key`.
The value shape follows the Metafield type, and differs between write and read for two of them:
- Text, textarea, markdown, and HTML Metafields are strings. Number Metafields are numbers, switches are booleans, dates are ISO 8601 strings.
- Object Relationship Metafields are written as an Object `id` string (or an array of ids for the multiple variant) and returned as a nested Object (or array of Objects) once `depth` is at least 1.
- File and Image Metafields are written as a media `name` string (or an array of names) and returned as an object with `url` and `imgix_url`, plus `alt_text`, `width`, and `height` when requested via `props`.
- Repeater Metafields are arrays of objects keyed by the child Metafield keys.'
additionalProperties: true
RevisionResponse:
type: object
required:
- revision
properties:
revision:
$ref: '#/components/schemas/Revision'
RevisionCreate:
type: object
description: 'Creates a draft revision. Publish by updating the Object with `status: published`.'
properties:
title:
type: string
slug:
type: string
status:
type: string
enum:
- published
- draft
default: draft
content:
type: string
deprecated: true
metadata:
$ref: '#/components/schemas/Metadata'
thumbnail:
type: string
description: Media `name`.
locale:
type: string
publish_at:
type:
- string
- number
description: UNIX millisecond timestamp.
unpublish_at:
type:
- string
- number
description: UNIX millisecond timestamp.
trigger_webhook:
type: boolean
additionalProperties: false
securitySchemes:
readKey:
type: apiKey
in: query
name: read_key
description: The Bucket read key, passed as a query parameter. Grants read access to a single Bucket and nothing else. Find it under Bucket > Settings > API Access in the dashboard. Buckets with no read key configured accept reads without one.
writeKey:
type: http
scheme: bearer
description: 'The Bucket write key, passed as `Authorization: Bearer <write_key>`. Grants read and write access to a single Bucket and nothing else. Find it under Bucket > Settings > API Access in the dashboard. The bare key without the `Bearer ` prefix is also accepted, but `Bearer` is the documented form. Buckets with no write key configured accept writes without one.'
externalDocs:
description: Cosmic API documentation
url: https://www.cosmicjs.com/docs/api