API ReferenceView as MarkdownOpenAPI

Collections

View as Markdown

Collections group and filter the site's items. The prefix of the name is its kind: product/ is a top-level product category, grouping/ a filter inside one, service/ a service category, calendar-filter/ a filter on the booking page, blogpost/ a blog category, and so on. Collections can nest and can show their own page.

Endpoints that need a token: the site owner creates it in their admin (Developers > API reference). AI assistants: how to ask the user for one.

9 endpoints.

List all collections

Categories and filters; ?type for one kind (product, service, blogpost...). Ordered by position, then name.

Public

Public - no token needed.

Query parameters
typestring

Only collections with this type.

Returns

Returns a list of Collection objects.

Status codes

200 500

GET/collections
curl -X GET 'http://bulgariandebateassociation.max-media.io/collections?ionic=true&type=...'
Response
[
  {
    "name": "Example",
    "parent_collection": "6543210fedcba98765432100",
    "picture": "6543210fedcba98765432100",
    "about_page": "6543210fedcba98765432100",
    "match_to_option": false,
    "is_color": false,
    "color": "#3557c4",
    "position": 1,
    "items": [
      "6543210fedcba98765432101"
    ],
    "thumbnail": "6543210fedcba98765432100",
    "_id": "6543210fedcba98765432100"
  }
]

Create a collection

Creates a category or filter, placed last in its kind's order; createNav also adds it to the navigation. The name's prefix says where it shows (product/, service/, blogpost/...; see the Collection model). Answers 201 with the category.

Admin token

Needs a site admin token.

Parameters
createNavstring

The collection's create nav.

Returns

Returns the Collection object.

Status codes

201 400 401 500

POST/collections
curl -X POST 'http://bulgariandebateassociation.max-media.io/collections?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "createNav": "..." }'
Response
{
  "name": "Example",
  "parent_collection": "6543210fedcba98765432100",
  "picture": "6543210fedcba98765432100",
  "about_page": "6543210fedcba98765432100",
  "match_to_option": false,
  "is_color": false,
  "color": "#3557c4",
  "position": 1,
  "items": [
    "6543210fedcba98765432101"
  ],
  "thumbnail": "6543210fedcba98765432100",
  "_id": "6543210fedcba98765432100"
}

Reorder collections

Persist a new display order for a set of collections. Send items: [{ _id, position }]. 400 "No items" for an empty list. Answers 200.

Admin token

Needs a site admin token.

Parameters
itemsstring

The collection's items.

Status codes

200 400 401 500

PATCH/collections-reorder
curl -X PATCH 'http://bulgariandebateassociation.max-media.io/collections-reorder?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "items": "..." }'

Retrieve a collection

One category, with the grouping filters inside it. With the grouping filters that sit in it or in no category. 404 when there is no such category.

Public

Public - no token needed.

Path parameters
idstringRequired

The ID of the collection.

Returns

Returns the Collection object.

Status codes

200 404 500

GET/collections/:id
curl -X GET 'http://bulgariandebateassociation.max-media.io/collections/{id}?ionic=true'
Response
{
  "name": "Example",
  "parent_collection": "6543210fedcba98765432100",
  "picture": "6543210fedcba98765432100",
  "about_page": "6543210fedcba98765432100",
  "match_to_option": false,
  "is_color": false,
  "color": "#3557c4",
  "position": 1,
  "items": [
    "6543210fedcba98765432101"
  ],
  "thumbnail": "6543210fedcba98765432100",
  "_id": "6543210fedcba98765432100"
}

Update a collection

Updates a category. Fields outside the allowed list are ignored. A rename also renames the navigation entry that links to it. Answers the category, or 404.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the collection.

Returns

Returns the Collection object.

Status codes

200 400 401 404 500

PATCH/collections/:id
curl -X PATCH 'http://bulgariandebateassociation.max-media.io/collections/{id}?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'
Response
{
  "name": "Example",
  "parent_collection": "6543210fedcba98765432100",
  "picture": "6543210fedcba98765432100",
  "about_page": "6543210fedcba98765432100",
  "match_to_option": false,
  "is_color": false,
  "color": "#3557c4",
  "position": 1,
  "items": [
    "6543210fedcba98765432101"
  ],
  "thumbnail": "6543210fedcba98765432100",
  "_id": "6543210fedcba98765432100"
}

Delete a collection

Deletes a category. Answers the deleted category. Items in it keep its id as collection_id, and a navigation entry linking to it stays: remove those separately.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the collection.

Returns

Returns an empty answer on success.

Status codes

200 401 404 500

DELETE/collections/:id
curl -X DELETE 'http://bulgariandebateassociation.max-media.io/collections/{id}?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'

Retrieve a collection

A category's picture. Answers the picture's media id, or 404.

Public

Public - no token needed.

Path parameters
idstringRequired

The ID of the collection.

Returns

Returns the Collection object.

Status codes

200 404 500

GET/collections/:id/media
curl -X GET 'http://bulgariandebateassociation.max-media.io/collections/{id}/media?ionic=true'
Response
{
  "name": "Example",
  "parent_collection": "6543210fedcba98765432100",
  "picture": "6543210fedcba98765432100",
  "about_page": "6543210fedcba98765432100",
  "match_to_option": false,
  "is_color": false,
  "color": "#3557c4",
  "position": 1,
  "items": [
    "6543210fedcba98765432101"
  ],
  "thumbnail": "6543210fedcba98765432100",
  "_id": "6543210fedcba98765432100"
}

Create a collection

Uploads a category's picture (media, form field). Multipart upload; becomes the category's picture.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the collection.

Status codes

200 400 401

POST/collections/:id/media
curl -X POST 'http://bulgariandebateassociation.max-media.io/collections/{id}/media?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'

Delete a collection

Removes a category's picture. Deletes the media record too.

Admin token

Needs a site admin token.

Path parameters
idstringRequired

The ID of the collection.

Returns

Returns an empty answer on success.

Status codes

200 401

DELETE/collections/:id/media
curl -X DELETE 'http://bulgariandebateassociation.max-media.io/collections/{id}/media?ionic=true' \
  -H 'Authorization: Bearer <TOKEN>'
↑↓ Navigate↵ GoEsc Close