# Object Types

# Add Object Type

Add a new Object Type to your Bucket.

Parameter Required Type Description
title required String Plural title of your Object Type
slug String Plural slug of your Object Type
singular String Singular title of your Object Type
emoji String Valid Unicode emoji
singleton Boolean Single or Multiple Objects
metafields Array Default Metafields for each Object in this type
pretty Enum true, Makes the response more reader-friendly
write_key String Restrict write access to your Bucket

    Definition

    bucket.addObjectType()
    

    Example Request

    const bucket = Cosmic.bucket({
      slug: 'bucket-slug',
      write_key: ''
    })
    const params = {
      title: 'Pages',
      singular: 'Page',
      slug: 'pages',
      emoji: '📄',
      singleton: false,
      metafields: [
        {
          type: 'text',
          title: 'Headline',
          key: 'headline',
          required: true
        },
        {
          type: 'file',
          title: 'Hero',
          key: 'hero',
          required: true
        }
      ]
    }
    bucket.addObjectType(params)
    .then(data => {
      console.log(data)
    })
    .catch(err => {
      console.log(err)
    })
    

    Example Response

    {
      "object_type": {
        "slug": "pages",
        "title": "Pages",
        "singular": "Page",
        "emoji": "📄",
        "singleton": false,
        "metafields": [
          {
            "type": "text",
            "title": "Headline",
            "key": "headline",
            "required": true
          },
          {
            "type": "file",
            "title": "Hero",
            "key": "hero",
            "required": true
          }
        ],
        "created_at": "2017-05-30T02:06:35.373Z",
        "metadata": null
      }
    }
    

    # Get Object Types

    Get all Object Types in your Bucket.

    Parameter Required Type Description
    pretty Enum true, Makes the response more reader-friendly
    read_key String Restrict read access to your Bucket

      # Edit Object Type

      Edit an existing Object Type in your Bucket.

      Parameter Required Type Description
      slug required String Plural slug of your Object Type
      title String Singular title of your Object Type
      singular String Singular title of your Object Type
      emoji String Valid Unicode emoji
      singleton Boolean Single or Multiple Objects
      metafields Array Default Metafields for each Object in this type
      pretty Enum true, Makes the response more reader-friendly
      write_key String Restrict write access to your Bucket

        # Delete Object Type

        Delete an existing Object Type from your Bucket. * This does not delete Objects in this Object Type.

        Parameter Required Type Description
        write_key String Restrict write access to your Bucket