Extensions

All Extension methods require Authorization: Bearer <ACCESS_TOKEN> present in the header.

Add Extension

There are three different methods you can use to add an Extension to your Bucket. Read more about how to build your Extension on the Extensions documentation page.

1. Upload a Zip file

The only required post value is zip which contains the file you send.

Parameter Required Type Description
zip required File Object (see below) Zip object with specific properties

Definition

POST https://api.cosmicjs.com/v1/:bucket_slug/extensions

Example Request

{
  "zip": "your-media-multipart-form-data"
}

Example Response

{
  "extension": {
    "id": "c62defe0-5f93-11e7-8054-873245f0e98d",
    "title": "Amazon Product Search",
    "image_url": "https://s3-us-west-2.amazonaws.com/cosmicjs/f1f1bd40-5dcd-11e7-b529-51f126a4b6ee-shopping-cart.jpg",
    "url": "https://cosmicjs.com/extensions/c62defe0-5f93-11e7-8054-873245f0e98d/dist",
    "zip_url": "https://cosmicjs.com/extensions/c62defe0-5f93-11e7-8054-873245f0e98d/src/build.zip",
    "installed_at": "2017-07-03T02:03:14.825Z",
    "font_awesome_class": "fa-shopping-basket"
  }
}

File Object

The zip property that includes the File Object must be an object with certain properties indicated below. If using the multer NPM module the file objects have these by default. Otherwise you should create an object with these properties:

Parameter Required Type Description
originalname required String The name of your file (something.jpg)
buffer File Buffer The File Buffer (must be zip file)

2. Upload via Zip file URL

The only required post value is zip_url which is the URL of your Extension zip file.

Parameter Required Type Description
zip_url required String Zip file URL with valid Extension properties

Definition

POST https://api.cosmicjs.com/v1/:bucket_slug/extensions

Example Request

{
	"zip_url": "https://mycdn.com/uploads/extension.zip"
}

Example Response

{
  "extension": {
    "id": "c62defe0-5f93-11e7-8054-873245f0e98d",
    "title": "Amazon Product Search",
    "image_url": "https://s3-us-west-2.amazonaws.com/cosmicjs/f1f1bd40-5dcd-11e7-b529-51f126a4b6ee-shopping-cart.jpg",
    "url": "https://cosmicjs.com/extensions/c62defe0-5f93-11e7-8054-873245f0e98d/dist",
    "zip_url": "https://cosmicjs.com/extensions/c62defe0-5f93-11e7-8054-873245f0e98d/src/build.zip",
    "installed_at": "2017-07-03T02:03:14.825Z",
    "font_awesome_class": "fa-shopping-basket"
  }
}

3. Add as URL

The required post values are title and url.

Parameter Required Type Description
title required String Extension title
url required String URL to point the Extension to (iframe). Needs to have https and X-Frame Options enabled)

    Edit Extension

    Query parameters can be added to the iframe URL of your Extension. These are great for storing third-party API keys and info. For security, query_params values will be saved as JavaScript Web Tokens (JWT), but available in your Extension as decoded values.

    Parameter Required Type Description
    query_params Array Add query parameters to your Extension. Great for adding third-party service API keys.

      Delete Extension

      Make sure you include Authorization: Bearer <ACCESS_TOKEN> in the header.