API Reference

Authentication

$ curl https://api.fridgecms.com/v1/oauth/token \
    -d grant_type="client_credentials" \
    -d client_id="sk_xxxxxxxxxxx" \
    -d client_secret="xxxxxxxxxxx"
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

Example Response:

{
  "access_token": "36334bb25b63b843754b34057f4ea66756fbc14d",
  "expires_in": 3600,
  "token_type": "Bearer",
  "scope": null
}

The Fridge API uses OAuth 2.0 to facilitate authentication. You provide the public/private key and secret to retrieve an access token that can be used to make requests. You can manage API keys on the settings page for any site you have administrator privileges.

API clients will take care of getting an access token for you. You only need to provide your key and secret when creating the client.

You must replace `client_id` and `client_secret` with the keys provided in your site settings.

Sites

Create a new Fridge site

$ curl https://api.fridgecms.com/v1/sites \
    -X POST \
    -d name="Website"
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('sites', {
  'name': 'Website'
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

site = fridge.post("sites", {
  :name => "My Website"
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("sites", array(
  "name" => "Website"
));

Example Response:

{
  "id": 1,
  "name": "Website",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "endpoints": [],
  "clients": [],
  "webhooks": []
}

Creates a new site. A default set of API keys will be generated and you will be added to the reserved Admin User Role of the new site.

Arguments

nameREQUIREDThe name of the site.
webhooksAn array of URLs that will be sent a POST request upon site actions.
endpointsExperimentalAn array of URLs that will be whitelisted for providing API access.

HTTP Request

POST https://api.fridgecms.com/v1/sites

Retrieve an existing Fridge site

$ curl https://api.fridgecms.com/v1/sites/1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

const site = fridge.get('sites/1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

site = fridge.get("sites/1")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("sites/1");

Example Response:

{
  "id": 1,
  "name": "Website",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "endpoints": [],
  "clients": [],
  "webhooks": []
}

Retrieve the details of an existing site. You must supply the unique site id.

Arguments

:idREQUIREDThe id of the site to retrieve.

HTTP Request

GET https://api.fridgecms.com/v1/sites/:id

Update a Fridge site

$ curl https://api.fridgecms.com/v1/sites/1 \
    -X PUT \
    -d webhooks[]="http://example.com"
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.put('sites/1', {
  'webhooks': [
    'http://example.com'
  ]
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

site = fridge.get("sites/1")
site.webhooks = ["http://example.com"]
fridge.put("sites/1", site.commit())
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->put("sites/1", array(
  "webhooks" => array("http://example.com")
));

Example Response:

{
  "id": 1,
  "name": "Website",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "endpoints": [],
  "clients": [],
  "webhooks": [
    "http://example.com"
  ]
}

Updates the specified site by setting the values of the paramters passed.

Arguments

nameThe name of the site.
webhooksAn array of URLs that will be sent a POST request upon site actions.
endpointsExperimentalAn array of URLs that will be whitelisted for providing API access.

HTTP Request

PUT https://api.fridgecms.com/v1/sites/:id

Delete a Fridge site

$ curl https://api.fridgecms.com/v1/sites/1 \
    -X DELETE
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.delete('sites/1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.delete("sites/1")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->delete("sites/1");

Example Response:

{
  "status": 200
}

Permanently deletes a site. It cannot be undone.

All content, settings, and users belonging to the specified site are also permanently deleted.

Arguments

idREQUIREDThe ID of the site to be deleted.

HTTP Request

DELETE https://api.fridgecms.com/v1/sites/:id

List all Fridge sites

$ curl https://api.fridgecms.com/v1/sites
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('sites')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

sites = fridge.get("sites")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("sites");

Example Response:

[
  {
    "id": 1,
    "name": "Website",
    "date_created": "2015-01-01 01:00:00",
    "date_updated": "2015-01-01 01:00:00",
    "endpoints": [],
    "clients": [],
    "webhooks": []
  },
  {
    "id": 2,
    "name": "Other Website",
    "date_created": "2015-01-01 01:00:00",
    "date_update": "2015-01-01 01:00:00",
    "endpoints": [],
    "clients": [],
    "webhooks": []
  }
]

Retrieve a list of sites.

HTTP Request

GET https://api.fridgecms.com/sites

Regenerate API keys for a Fridge site

$ curl https://api.fridgecms.com/v1/sites/1/regenerate_keys \
    -X PUT
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.put('sites/1/regenerate_keys')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

site = fridge.put("sites/1/regenerate_keys")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->put("sites/1/regenerate_keys");

Example Response:

{
  "id": 1,
  "name": "Website",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "endpoints": [],
  "clients": [
    {
      "key": "pk_xxxxxxxxxxx",
      "secret": "",
      "type": "public"
    },
    {
      "key": "sk_xxxxxxxxxxx",
      "secret": "xxxxxxxxxxx",
      "type": "private"
    }
  ],
  "webhooks": []
}

Deletes existing API keys and creates a new public key and private key/secret pair.

Arguments

idREQUIREDThe ID of the site.

HTTP Request

PUT https://api.fridgecms.com/sites/:id/regenerate_keys

Content Types

Create a new Content Type

$ curl https://api.fridgecms.com/v1/types \
    -X POST \
    -d site=1 \
    -d name="Post" \
    -d parts[]={"name":"title","label":"Title","type":"text"}
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('types', {
  'site': 1,
  'name': 'Post',
  'parts': [
    {
      'name': 'title',
      'label': 'Title',
      'type': 'text'
    }
  ]
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

content_type = fridge.post("types", {
  :name => "Post",
  :parts => [
    {
      :name => "title",
      :label => "Title",
      :type => "text"
    }
  ]
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("types", array(
  "site" => 1,
  "name" => "Post",
  "parts" => array(
    array(
      "name" => "title",
      "label" => "Title",
      "type" => "text"
    ))
));

Example Response:

{
  "id": 3,
  "site_id": 1,
  "name": "Post",
  "slug": "post",
  "collection": true,
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "display_order": 0,
  "options": {
    "layout": "default",
    "api_access": true,
    "sort_order": "desc",
    "sort_method": "date_created"
  },
  "parts": [
    {
      "name": "title",
      "label": "Title",
      "type": "text"
    }
  ]
}

Arguments

siteREQUIREDThe id of the site where the content type will be created.
nameREQUIREDThe name of the content type.
display_orderA 0-based number specifying the default order in which the content type is listed.
optionsAn object of key/value pair options.
partsREQUIREDAn array of part definition objects.

HTTP Request

POST https://api.fridgecms.com/v1/types

Retrieve an existing Content Type

$ curl https://api.fridgecms.com/v1/types/3?site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('types/3?site=1')
Coming soon...
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("types/3?site=1");

Retrieve the details of an existing content type. You must supply the unique content type id or slug.

Arguments

siteREQUIREDThe id of the site where the content type belongs.
:identifierREQUIREDThe id or slug of the content type to retrieve.

HTTP Request

GET https://api.fridgecms.com/v1/types/:identifier

Update a Content Type

$ curl https://api.fridgecms.com/v1/types/3 \
    -X PUT \
    -d site=1 \
    -d name="Post" \
    -d parts[]={"name":"published","label":"Publish Date","type":"date"}
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.put('types/3', {
  'site': 1,
  'name': 'Post',
  'parts': [
    {
      'name': 'title',
      'label': 'Title',
      'type': 'text'
    },
    {
      'name': 'published',
      'label': 'Publish Date',
      'type': 'date'
    }
  ]
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

content_type = fridge.put("types/3", {
  :name => "Post",
  :parts => [
    {
      :name => "title",
      :label => "Title",
      :type => "text"
    },
    {
      :name => "published",
      :label => "Published",
      :type => "date"
    }
  ]
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->put("types/3", array(
  "site" => 1,
  "name" => "Post",
  "parts" => array(
    array(
      "name" => "title",
      "label" => "Title",
      "type" => "text"
    ),
    array(
      "name" => "published",
      "label" => "Publish Date",
      "type" => "date"
    ))
));

Example Response:

{
  "id": 3,
  "site_id": 1,
  "name": "Post",
  "slug": "post",
  "collection": true,
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "display_order": 0,
  "options": {
    "layout": "default",
    "api_access": true,
    "sort_order": "desc",
    "sort_method": "date_created"
  },
  "parts": [
    {
      "name": "title",
      "label": "Title",
      "type": "text"
    },
    {
      "name": "published",
      "label": "Publish Date",
      "type": "date"
    }
  ]
}

Updates the specified content type by setting the values of the parameters passed.

Arguments

siteREQUIREDThe id of the site where the content type belongs.
nameThe name of the content type.
display_orderA 0-based number specifying the default order in which the content type is listed.
optionsAn object of key/value pair options.
partsREQUIREDAn array of part definition objects.

HTTP Request

PUT https://api.fridgecms.com/v1/types/:identifier

Delete a Content Type

$ curl https://api.fridgecms.com/v1/types/3 \
    -X DELETE \
    -d site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.delete('types/3', {
  'site': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.delete("types/3")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->delete("types/3", array(
  "site" => 1
));

Example Response:

{
  "status": 200
}

Permanently deletes a content type. It cannot be undone.

Arguments

siteREQUIREDThe id of the site where the content type belongs.
idREQUIREDThe id of the content type.

HTTP Request

DELETE https://api.fridgecms.com/v1/types/:id

List all Content Types

$ curl https://api.fridgecms.com/v1/types
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('types')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

types = fridge.get("types")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("types");

Example Response:

[
  {
    "id": 3,
    "site_id": 1,
    "name": "Post",
    "slug": "post",
    "collection": true,
    "date_created": "2015-01-01 01:00:00",
    "date_updated": "2015-01-01 01:00:00",
    "display_order": 0,
    "options": {
      "layout": "default",
      "api_access": true,
      "sort_order": "desc",
      "sort_method": "date_created"
    },
    "parts": [
      {
        "name": "title",
        "label": "Title",
        "type": "text"
      }
    ]
  },
  {
    "id": 4,
    "site_id": 1,
    "name": "Event",
    "date_created": "2015-01-01 01:00:00",
    "date_updated": "2015-01-01 01:00:00",
    "display_order": 1,
    "options": {},
    "parts": [
      {
        "id": 12,
        "name": "location",
        "label": "Location",
        "hint": "Where the event will be held",
        "type": "text",
        "required": true
      }
    ]
  }
]

Retrieve a list of content types.

Arguments

siteREQUIREDThe id of the site.

HTTP Request

GET https://api.fridgecms.com/v1/types

Content

Create a new content item

$ curl https://api.fridgecms.com/v1/content/type/post \
    -X POST \
    -d site=1 \
    -d content[title]="My Post Title" \
    -d content[published]="2015-02-01" \
    -d active=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('content/type/post', {
  'site': 1,
  'content': {
    'title': 'My Post Title',
    'published': '2015-02-01'
  },
  'active': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

post = fridge.post("content/type/post", {
  :content => {
    :title => "My Post Title",
    :published => "2015-02-01"
  },
  :active => true
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("content/type/post", array(
  "site" => 1,
  "content" => array(
    "title" => "My Post Title",
    "published" => "2015-02-01"
  ),
  "active" => 1
));

Example Response:

{
  "id": 15,
  "site_id": 1,
  "document_definition_id": 3,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "display_order": 0,
  "active": 1,
  "content": {
    "10": "My Post Title",
    "11": "2015-02-01"
  },
  "slug": "my_post_title",
  "user_id": 90
}

Creates a new content item.

Arguments

siteREQUIREDThe id of the site where the content will be created.
:identifierREQUIREDThe id or slug of the content type used to create the content item. The name of the content type.
activedefault is trueBoolean value indicates if the content item is active or not.
slugA unique slug identifier for the content item. One will be intelligently generated for you if not specified.
contentREQUIREDAn array or hash of content values paired to part definition identifiers.

HTTP Request

POST https://api.fridgecms.com/v1/content/type/:identifier

Retrieve an existing Content item

$ curl https://api.fridgecms.com/v1/content/15 \
    -d site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('content/15', {
  'site': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

post = fridge.get("content/15")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("content/15", array(
  "site" => 1
));

Example Response:

{
  "id": 15,
  "site_id": 1,
  "document_definition_id": 3,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "display_order": 0,
  "active": 1,
  "content": {
    "10": "My Post Title",
    "11": "2015-02-01"
  },
  "slug": "my_post_title",
  "user_id": 90
}

Retrieve the details of an existing content item. You must supply the unique site id and content id.

Arguments

siteREQUIREDThe id of the site where the content belongs.
:identifierREQUIREDThe id or slug of the content item.

HTTP Request

GET https://api.fridgecms.com/v1/content/:identifier

Update a Content item

$ curl https://api.fridgecms.com/v1/content/15 \
    -X PUT \
    -d site=1 \
    -d content[title]="Draft Title" \
    -d active=0
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.put('content/15', {
  'site': 1,
  'content': {
    'title': 'Draft Title',
    'published': '2015-02-01'
  },
  'active': 0
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

post = fridge.put("content/15", {
  :content => {
    :title => "Draft Title",
    :published => "2015-02-01"
  },
  :active => false
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->put("content/15", array(
  "site" => 1,
  "content" => array(
    "title" => "Draft Title",
    "published" => "2015-02-01"
  ),
  "active" => 0
));

Example Response:

{
  "id": 15,
  "site_id": 1,
  "document_definition_id": 3,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "display_order": 0,
  "active": false,
  "content": {
    "10": "Draft Title",
    "11": "2015-02-01"
  },
  "slug": "my_post_title",
  "user_id": 90
}

Updates the specified content item by setting the values of the parameters passed.

Arguments

siteREQUIREDThe id of the site where the content will be created.
:identifierREQUIREDThe id or slug of the content type used to create the content item. The name of the content type.
activedefault is trueBoolean value indicates if the content item is active or not.
slugA unique slug identifier for the content item. One will be intelligently generated for you if not specified.
contentREQUIREDAn array or hash of content values paired to part definition identifiers.

HTTP Request

PUT https://api.fridgecms.com/v1/content/:identifier

Delete a Content item

$ curl https://api.fridgecms.com/v1/content/15 \
    -X DELETE \
    -d site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.delete('content/15', {
  'site': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.delete("content/15")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->delete("content/15", array(
  "site" => 1
));

Example Response:

{
  "status": 200
}

Permanently deletes a content item. It cannot be undone.

Arguments

siteREQUIREDThe id of the site.
:identifierREQUIREDThe id of the content.

HTTP Request

DELETE https://api.fridgecms.com/v1/content/:identifier

List all Content

$ curl https://api.fridgecms.com/v1/content?type=post&site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('content?type=post&site=1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

posts = fridge.get("content", {type: "post"})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("content?type=post&site=1");

Example Response:

[
  {
    "id": 15,
    "site_id": 1,
    "document_definition_id": 3,
    "date_created": "2015-02-01 01:00:00",
    "date_updated": "2015-02-01 01:00:00",
    "display_order": 0,
    "active": 1,
    "content": {
      "10": "My Post Title",
      "11": "2015-02-01"
    },
    "slug": "my_post_title",
    "user_id": 90
  }
]

Retrieve a list of content.

Arguments

siteREQUIREDThe id of the site.
typeThe id or slug of a content type to filter by.
activetrue or false or all. Filters content by active, inactive, or both.
limitA number which limits the amount of content retrieved.
offsetA number which offsets the start of content retrieved.
sort_methoddefault is date_created or the sort method of the content typeSpecify how content is sorted. Options are date_created, manual, hierarchy, or any valid part name.
sort_orderSpecify the direction of the sort. asc or desc
{part_name}Any part name/part value pair to filter by.

HTTP Request

GET https://api.fridgecms.com/v1/content

Upload a file


$ curl https://api.fridgecms.com/v1/content/upload     -F file=@/path/to/filename.jpg     -H "Authorization: token xxxxxxxxxxx"     -d site=1 
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('content/upload', {
  'site': 1,
  'file': 'file'
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.post("content/upload", {:file => file})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("content/upload", array(
  "site" => 1,
  "file" => "file"
));

Example Response:

{
  "message": "filename.jpg",
  "status": 200
}

Upload a file asset to the specified site.

Arguments

siteREQUIREDThe id of the site.
fileREQUIREDThe file to upload.

HTTP Request

POST https://api.fridgecms.com/v1/content/upload

Retrieve an existing file

$ curl https://api.fridgecms.com/v1/content/upload/my_filename.txt \
    -d site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('content/upload/my_filename.txt', {
  'site': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

file = fridge.get("content/upload/my_filename.txt")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("content/upload/my_filename.txt", array(
  "site" => 1
));

Example Response:

"Binary"

Retrieve an existing file. The file is sent as binary with proper Content-Type headers. You must supply the unique site id and filename.

Arguments

siteREQUIREDThe id of the site.
:filenameREQUIREDThe name of the file.

HTTP Request

GET https://api.fridgecms.com/v1/content/upload/:filename

Public Content creation

$ curl https://api.fridgecms.com/v1/public/post \
    -d site=1 \
    -d content[title]="User submitted post" \
    -d content[published]="2015-02-02" \
    -d active=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('public/post', {
  'site': 1,
  'content': {
    'title': 'User submitted post',
    'published': '2015-02-01'
  },
  'active': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

post = fridge.post("public/post", {
  :content => {
    :title => "User submitted post",
    :published => "2015-02-02"
  },
  :active => true
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("public/post", array(
  "site" => 1,
  "content" => array(
    "title" => "User submitted post",
    "published" => "2015-02-01"
  ),
  "active" => 1
));

Example Response:

{
  "id": 23,
  "site_id": 1,
  "document_definition_id": 3,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "display_order": 0,
  "active": 1,
  "content": {
    "10": "User submitted post",
    "11": "2015-02-01"
  },
  "slug": "user_submitted_post"
}

If a content type allows for public content creation by setting the api_create option to true, a valid public key authorized token can create content.

Arguments

:typeREQUIREDThe id or slug of the content type used to create the content.
contentREQUIREDAn array or hash of content values paired to part definition identifiers.

HTTP Request

POST https://api.fridgecms.com/v1/public/:type

User Roles

Create a new User Role

$ curl https://api.fridgecms.com/v1/roles \
    -X POST \
    -d site=1 \
    -d name="Member" \
    -d parts[]={"name":"avatar","label":"Avatar","type":"image"}
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('roles', {
  'site': 1,
  'name': 'Member',
  'parts': [
    {
      'name': 'avatar',
      'label': 'Avatar',
      'type': 'image'
    }
  ]
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

member_role = fridge.post("roles", {
  :name => "Member",
  :parts => [
    {
      :name => "avatar",
      :label => "Avatar",
      :type => "image"
    }
  ]
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("roles", array(
  "site" => 1,
  "name" => "Member",
  "parts" => array(
    array(
      "name" => "avatar",
      "label" => "Avatar",
      "type" => "image"
    ))
));

Example Response:

{
  "id": 7,
  "site_id": 1,
  "name": "Member",
  "slug": "member",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "display_order": 0,
  "options": {},
  "parts": [
    {
      "name": "photo",
      "label": "Photo",
      "type": "image"
    }
  ],
  "admin_access": false,
  "permissions": {}
}

Creates a new user role.

Arguments

siteREQUIREDThe id of the site where the user role will be created.
nameREQUIREDThe name of the user role.
display_orderA 0-based number specifying the default order in which the content type is listed.
optionsAn object of key/value pair options.
partsREQUIREDAn array of part definition objects.
admin_accessAdmins onlyControl if this role has access to the Fridge dashboard.
permissionsAdmins onlyAn object of role-based permissions

HTTP Request

POST https://api.fridgecms.com/v1/roles

Retrieve an existing User Role

$ curl https://api.fridgecms.com/v1/roles/member?site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('roles/member?site=1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

member_role = fridge.get("roles/member")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("roles/member?site=1");

Example Response:

{
  "id": 7,
  "site_id": 1,
  "name": "Member",
  "slug": "member",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "display_order": 0,
  "options": {},
  "parts": [
    {
      "name": "photo",
      "label": "Photo",
      "type": "image"
    }
  ],
  "admin_access": false,
  "permissions": {}
}

Retrieve the details of an existing user role. You must supply the unique site id and user role id or slug.

Arguments

siteREQUIREDThe id of the site where the user role belongs.
:identifierREQUIREDThe id or slug of the user role.

HTTP Request

GET https://api.fridgecms.com/v1/roles/:identifier

Update a User Role

$ curl https://api.fridgecms.com/v1/roles/member \
    -X PUT \
    -d site=1 \
    -d permissions={"content_type":["read"],"content":["read","create","update","delete"]}
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.put('roles/member', {
  'site': 1,
  'permissions': {
    'content_type': [
      'read'
    ],
    'content': [
      'read',
      'create',
      'update',
      'delete'
    ]
  }
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.put("roles/member", {
  :permissions => {
    :content_type => [:read],
    :content => [:read, :create, :update, :delete]
  }
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->put("roles/member", array(
  "site" => 1,
  "permissions" => array(
    "content_type" => array("read"),
    "content" => array("read", "create", "update", "delete")
  )
));

Example Response:

{
  "id": 7,
  "site_id": 1,
  "name": "Member",
  "slug": "member",
  "date_created": "2015-01-01 01:00:00",
  "date_updated": "2015-01-01 01:00:00",
  "display_order": 0,
  "options": {},
  "parts": [
    {
      "name": "photo",
      "label": "Photo",
      "type": "image"
    }
  ],
  "admin_access": false,
  "permissions": {}
}

Updates the specified user role by setting the values of the parameters passed.

Arguments

siteREQUIREDThe id of the site where the user role will be created.
nameThe name of the user role.
display_orderA 0-based number specifying the default order in which the content type is listed.
optionsAn object of key/value pair options.
partsREQUIREDAn array of part definition objects.
admin_accessAdmins onlyControl if this role has access to the Fridge dashboard.
permissionsAdmins onlyAn object of role-based permissions

HTTP Request

PUT https://api.fridgecms.com/v1/roles/:identifier

Delete a User Role

$ curl https://api.fridgecms.com/v1/roles/member \
    -X DELETE \
    -d site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.delete('roles/member', {
  'site': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.delete("roles/member")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->delete("roles/member", array(
  "site" => 1
));

Example Response:

{
  "status": 200
}

Permanently deletes a user role. It cannot be undone.

Arguments

siteREQUIREDThe id of the site where the user role belongs.
:identifierREQUIREDThe id or slug of the user role.

HTTP Request

DELETE https://api.fridgecms.com/v1/roles/:identifier

List all User Roles

$ curl https://api.fridgecms.com/v1/roles?site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('roles?site=1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

user_roles = fridge.get("roles")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("roles?site=1");

Example Response:

[
  {
    "id": 7,
    "site_id": 1,
    "name": "Member",
    "slug": "member",
    "date_created": "2015-01-01 01:00:00",
    "date_updated": "2015-01-01 01:00:00",
    "display_order": 0,
    "options": {},
    "parts": [
      {
        "name": "photo",
        "label": "Photo",
        "type": "image"
      }
    ],
    "admin_access": false,
    "permissions": {}
  }
]

Retrieve a list of user roles.

Arguments

siteREQUIREDThe id of the site.

HTTP Request

GET https://api.fridgecms.com/v1/roles

Users

Create a new user

$ curl https://api.fridgecms.com/v1/users/role/member \
    -X POST \
    -d site=1 \
    -d email="[email protected]" \
    -d active=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.post('users/role/member', {
  'site': 1,
  'email': '[email protected]',
  'active': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

user = fridge.post("users/role/member", {
  :email => "[email protected]",
  :active => true
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->post("users/role/member", array(
  "site" => 1,
  "email" => "[email protected]",
  "active" => 1
));

Example Response:

{
  "id": 21,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "active": true,
  "content": [],
  "email": "[email protected]"
}

Creates a new user.

Arguments

siteREQUIREDThe id of the site where the user will be created.
:identifierREQUIREDThe id or slug of the user role used to create the user.
activedefault is trueThe id of the site where the user will be created.
emailREQUIREDuniqueEmail address.
passwordREQUIREDPassword.
contentREQUIREDAn array or hash of content values paired to part identifiers

If you create a new user that has the same email as another user from a different site, Fridge will allow that existing user access to the specified site id rather than creating a new user.

HTTP Request

POST https://api.fridgecms.com/v1/users/role/:identifier

Retrieve an existing User

$ curl https://api.fridgecms.com/v1/users/21?site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('users/21?site=1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

user = fridge.get("users/21")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("users/21?site=1");

Example Response:

{
  "id": 21,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "active": true,
  "content": [],
  "email": "[email protected]"
}

Retrieve the details of an existing user. You must supply the unique site id and user id.

Arguments

siteREQUIREDThe id of the site where the user belongs.
:idREQUIREDThe id of the user.

HTTP Request

GET https://api.fridgecms.com/v1/users/:identifier

Update a User

$ curl https://api.fridgecms.com/v1/users/21 \
    -X PUT \
    -d site=1 \
    -d active=0
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.put('users/21', {
  'site': 1,
  'active': 0
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

user = fridge.put("users/21", {
  :active => false
})
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->put("users/21", array(
  "site" => 1,
  "active" => 0
));

Example Response:

{
  "id": 21,
  "date_created": "2015-02-01 01:00:00",
  "date_updated": "2015-02-01 01:00:00",
  "active": true,
  "content": [],
  "email": "[email protected]"
}

Updates the specified user by setting the values of the parameters passed.

Arguments

siteREQUIREDThe id of the site where the user belongs.
:idREQUIREDThe id of the user.
activedefault is trueBoolean which indicates if the user is active or not.
emailREQUIREDuniqueEmail address.
passwordREQUIREDAdmins onlySupplying a passowrd will change the password of the user.
contentREQUIREDAn array or hash of content values paired to part identifiers

HTTP Request

PUT https://api.fridgecms.com/v1/users/:id

Delete a User

$ curl https://api.fridgecms.com/v1/users/21 \
    -X DELETE \
    -d site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.delete('users/21', {
  'site': 1
})

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

fridge.delete("users/21")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->delete("users/21", array(
  "site" => 1
));

Example Response:

{
  "status": 200
}

Permanently deletes a user. It cannot be undone.

Arguments

siteREQUIREDThe id of the site where the user belongs.
:idREQUIREDThe id of the user.
activedefault is trueBoolean which indicates if the user is active or not.
emailREQUIREDuniqueEmail address.
passwordREQUIREDAdmins onlySupplying a passowrd will change the password of the user.
contentREQUIREDAn array or hash of content values paired to part identifiers

HTTP Request

DELETE https://api.fridgecms.com/v1/user/:id

List all Users

$ curl https://api.fridgecms.com/v1/users?role=member&site=1
const Fridge = require('fridge')
const fridge = new Fridge({
  client_id: 'sk_xxxxxxxxxxx',
  client_secret: 'xxxxxxxxxxxx'
})

fridge.get('users?role=member&site=1')

require 'fridge_api'

fridge = FridgeApi.client({
  :client_id => "sk_xxxxxxxxxxx"
  :client_secret => "xxxxxxxxxxx"
})

members = fridge.get("users/role/member")
$fridge = new \FridgeApi\Client("sk_xxxxxxxxxxx", "xxxxxxxxxxx");

$fridge->get("users?role=member&site=1");

Example Response:

[
  {
    "id": 21,
    "date_created": "2015-02-01 01:00:00",
    "date_updated": "2015-02-01 01:00:00",
    "active": true,
    "content": [],
    "email": "[email protected]"
  }
]

Retrieve a list of users.

Arguments

siteREQUIREDThe id of the site.
roleThe id or slug of a user role to filter by.
activetrue or false or all. Filters content by active, inactive, or both.
limitA number which limits the amount of content retrieved.
offsetA number which offsets the start of content retrieved.
sort_methoddefault is date_created or the sort method of the user roleSpecify how users are sorted. Options are date_created, manual, or any valid part name.
sort_orderSpecify the direction of the sort. asc or desc
{part_name}Any part name/part value pair to filter by.

HTTP Request

GET https://api.fridgecms.com/v1/users