Cosmic Object types API

Object types define the content model: the Metafields, localization settings, and display options shared by every Object in the type.

GitHub OpenAPI

Operations 5

GET /buckets/{slug}/object-types List Object types #
POST /buckets/{slug}/object-types Create an Object type #
GET /buckets/{slug}/object-types/{type_slug} Get an Object type #
PATCH /buckets/{slug}/object-types/{type_slug} Update an Object type #
DELETE /buckets/{slug}/object-types/{type_slug} Delete an Object type #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • 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.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/cosmicjs-com:cosmicjs-com-object-types-api"
All apis
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.

Get an API 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 Specification

cosmicjs-com-object-types-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Cosmic REST API v3 Object types 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 types
  description: 'Object types define the content model: the Metafields, localization settings, and display options shared by every Object in the type.'
  externalDocs:
    url: https://www.cosmicjs.com/docs/api/object-types
paths:
  /buckets/{slug}/object-types:
    parameters:
    - $ref: '#/components/parameters/BucketSlug'
    get:
      operationId: listObjectTypes
      tags:
      - Object types
      summary: List Object types
      description: 'Retrieve every Object type in the Bucket, each with its full Metafield model. Use this to discover the content model before creating or querying Objects: the `slug` of each type is what you pass as `type` in Object queries, and the `metafields` array tells you which `metadata` keys an Object of that type accepts.'
      parameters:
      - $ref: '#/components/parameters/ReadKey'
      - $ref: '#/components/parameters/Pretty'
      responses:
        '200':
          description: The Object types in the Bucket.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectTypeListResponse'
        '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: createObjectType
      tags:
      - Object types
      summary: Create an Object type
      description: Create a new Object type, defining the content model that its Objects will follow. Only `title` is required; the `slug` is derived from the title when omitted. Define `metafields` here so that Objects created in this type can carry the corresponding `metadata` values.
      security:
      - writeKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ObjectTypeCreate'
            examples:
              minimal:
                summary: Title only
                value:
                  title: Motorcycles
              withMetafields:
                summary: With a content model
                value:
                  title: Bikes
                  slug: bikes
                  singular: Bike
                  emoji: 🏍️
                  metafields:
                  - title: Image
                    key: image
                    type: file
                    required: true
                    media_validation_type: image
                  - title: Headline
                    key: headline
                    type: text
                    required: false
      responses:
        '200':
          description: The created Object type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectTypeResponse'
        '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}/object-types/{type_slug}:
    parameters:
    - $ref: '#/components/parameters/BucketSlug'
    - $ref: '#/components/parameters/TypeSlug'
    get:
      operationId: getObjectType
      tags:
      - Object types
      summary: Get an Object type
      description: Retrieve a single Object type by its slug, including the full Metafield model. Use this when you already know the type and want its field definitions without listing every type in the Bucket.
      parameters:
      - $ref: '#/components/parameters/ReadKey'
      - $ref: '#/components/parameters/Pretty'
      responses:
        '200':
          description: The requested Object type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectTypeResponse'
        '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'
    patch:
      operationId: updateObjectType
      tags:
      - Object types
      summary: Update an Object type
      description: Update an Object type in place. Only the properties you send are changed. Sending `metafields` replaces the whole array, so read the type first and send the complete list rather than only the field you want to alter.
      security:
      - writeKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ObjectTypeUpdate'
            examples:
              rename:
                summary: Rename a type
                value:
                  title: Motorcycles
                  slug: motorcycles
                  singular: Motorcycle
      responses:
        '200':
          description: The updated Object type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectTypeResponse'
        '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'
    delete:
      operationId: deleteObjectType
      tags:
      - Object types
      summary: Delete an Object type
      description: 'Delete an Object type and every Object in it. This is destructive and not reversible through the API: confirm with the user before calling it.'
      security:
      - writeKey: []
      parameters:
      - $ref: '#/components/parameters/TriggerWebhook'
      responses:
        '200':
          description: The Object type was deleted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
              example:
                message: Object Type with slug 'bikes' deleted successfully from bucket.
        '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
  schemas:
    ObjectType:
      type: object
      description: The content model shared by every Object in the type.
      properties:
        id:
          type: string
        title:
          type: string
        singular:
          type: string
          description: Singular label, used in dashboard copy such as "New Bike".
        slug:
          type: string
          description: Unique within the Bucket. This is the value you pass as `type` when querying Objects.
        singleton:
          type: boolean
          description: Whether the type holds exactly one Object, as for a home page.
        emoji:
          type: string
          description: Unicode emoji shown beside the type in the dashboard.
        metafields:
          type: array
          items:
            $ref: '#/components/schemas/Metafield'
        options:
          type: object
          properties:
            slug_field:
              type: boolean
              description: Whether editors can see and edit the slug field.
          additionalProperties: true
        localization:
          type: boolean
          description: Whether Objects in this type can exist in multiple locales.
        locales:
          type: array
          description: Locale codes available in this type.
          items:
            type: string
        priority_locale:
          type:
          - string
          - 'null'
          description: Default locale for new Objects in this type.
        created_at:
          type: string
          format: date-time
        modified_at:
          type: string
          format: date-time
      additionalProperties: true
    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
    MessageResponse:
      type: object
      description: Returned by delete operations.
      required:
      - message
      properties:
        message:
          type: string
    ObjectTypeUpdate:
      type: object
      description: Only the properties sent are changed. Sending `metafields` replaces the entire array.
      minProperties: 1
      properties:
        title:
          type: string
        singular:
          type: string
        slug:
          type: string
        singleton:
          type: boolean
        emoji:
          type: string
        metafields:
          type: array
          items:
            $ref: '#/components/schemas/Metafield'
        options:
          type: object
          additionalProperties: true
        localization:
          type: boolean
        locales:
          type: array
          items:
            type: string
        priority_locale:
          type: string
      additionalProperties: false
    ObjectTypeCreate:
      type: object
      required:
      - title
      properties:
        title:
          type: string
        singular:
          type: string
        slug:
          type: string
          description: Derived from `title` when omitted.
        singleton:
          type: boolean
        emoji:
          type: string
        metafields:
          type: array
          items:
            $ref: '#/components/schemas/Metafield'
        options:
          type: object
          additionalProperties: true
        localization:
          type: boolean
          default: false
        locales:
          type: array
          items:
            type: string
        priority_locale:
          type: string
      additionalProperties: false
    ObjectTypeResponse:
      type: object
      required:
      - object_type
      properties:
        object_type:
          $ref: '#/components/schemas/ObjectType'
    Metafield:
      type: object
      description: One field in an Object type's content model.
      required:
      - title
      - key
      - type
      properties:
        id:
          type: string
          description: Assigned by Cosmic. Omit when creating.
        title:
          type: string
          description: Label shown to editors in the dashboard.
        key:
          type: string
          description: The key used in an Object's `metadata`.
        type:
          type: string
          description: The Metafield type. See the Metafields documentation for the full list and the value shape each one expects.
          examples:
          - text
          - textarea
          - html-textarea
          - markdown
          - number
          - switch
          - date
          - file
          - files
          - object
          - objects
          - select-dropdown
          - radio-buttons
          - check-boxes
          - json
          - parent
          - repeater
        value:
          description: Default value for the Metafield.
        helptext:
          type: string
          description: Guidance shown to editors beneath the field.
        required:
          type: boolean
          description: Whether Objects in this type must supply a value.
        media_validation_type:
          type: string
          description: Restricts uploads for File Metafields.
          examples:
          - image
          - video
          - audio
        repeater_fields:
          type: array
          description: Child Metafields, for `repeater` types.
          items:
            $ref: '#/components/schemas/Metafield'
        options:
          type: array
          description: Choices for select, radio, and checkbox types.
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    ObjectTypeListResponse:
      type: object
      required:
      - object_types
      properties:
        object_types:
          type: array
          items:
            $ref: '#/components/schemas/ObjectType'
  parameters:
    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
    TypeSlug:
      name: type_slug
      in: path
      required: true
      description: The Object type slug, unique within the Bucket.
      schema:
        type: string
      example: blog-posts
    BucketSlug:
      name: slug
      in: path
      required: true
      description: The Bucket slug. Found under Bucket > Settings in the dashboard.
      schema:
        type: string
      example: my-bucket
    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
    TriggerWebhook:
      name: trigger_webhook
      in: query
      required: false
      description: Set to `true` to fire the corresponding webhook for this action.
      schema:
        type: boolean
        default: 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