Libraries

Libraries are the central hubs for brand assets in Cake Slice. On this page, we'll dive into the different library endpoints you can use to manage libraries programmatically. We'll look at how to query, create, update, and delete libraries.

The library model

Properties

  • Name
    id
    Type
    uuid
    Description

    Unique identifier for the library.

  • Name
    name
    Type
    string
    Description

    The name for the library.

  • Name
    slug
    Type
    string
    Description

    The vanity url path for the library.

  • Name
    privacy
    Type
    enum
    Description

    The privacy setting of the library.

    Can be one of public, private, or stealth.

  • Name
    organization_id
    Type
    uuid
    Description

    The unique identifier of the organization the library belongs to.

  • Name
    created_at
    Type
    timestamp
    Description

    Timestamp of when the library was created.

  • Name
    updated_at
    Type
    timestamp
    Description

    Timestamp of when the library was last updated.


GET/v1/organizations/:organization_id/libraries

List all libraries

This endpoint allows you to retrieve a list of all the libraries for a given organization.

Optional params

  • Name
    include
    Type
    string
    Description

    A comma separated list of related resources to return in the response. The only valid resource to include for libraries is organization.

    See the API Overview guide for more details on usage.

  • Name
    fields
    Type
    array
    Description

    Not applicable for libraries.

    See the API Overview guide for more details on usage.

Request

GET
/v1/organizations/:organization_id/libraries
const response = await fetch(
  "https://api.cakeslice.com/v1/organizations/:organization_id/libraries",
  {
    headers: {
      "Authorization": `Bearer ${token}`
    }
  }
)

await response.json()

Response

{
  "data": [
    {
      "id": "abc-def-123",
      "type": "library",
      "attributes": {
        "name": "ACME Brand Assets",
        "slug": "assets",
        "privacy": "private",
        "organization_id": "abc-def-123",
        "created_at": "2025-01-02T21:59:53.475Z",
        "updated_at": "2025-03-17T18:10:11.946Z"
      },
      "relationships": {}
    },
    ...
  ]
}

POST/v1/organizations/:organization_id/libraries

Create a library

This endpoint allows you to create a new library for a given organization.

Required attributes

  • Name
    name
    Type
    string
    Description

    The name for the library.

  • Name
    slug
    Type
    string
    Description

    The vanity url path for the library.

Optional attributes

  • Name
    privacy
    Type
    enum
    Description

    The privacy setting of the library.

    Can be one of public, private, or stealth. Defaults to private.

Optional params

  • Name
    include
    Type
    string
    Description

    A comma separated list of related resources to return in the response. The only valid resource to include for libraries is organization.

    See the API Overview guide for more details on usage.

  • Name
    fields
    Type
    array
    Description

    Not applicable for libraries.

    See the API Overview guide for more details on usage.

Request

POST
/v1/organizations/:organization_id/libraries
const response = await fetch(
  "https://api.cakeslice.com/v1/organizations/:organization_id/libraries",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${token}`
    },
    body: JSON.stringify({
      data: {
        attributes: {
          name: "ACME Brand Assets",
          slug: "assets"
        }
      }
    })
  }
)

await response.json()

Response

{
  "data": {
    "id": "abc-def-123",
    "type": "library",
    "attributes": {
      "name": "ACME Brand Assets",
      "slug": "assets",
      "privacy": "private",
      "organization_id": "abc-def-123",
      "created_at": "2025-01-02T21:59:53.475Z",
      "updated_at": "2025-03-17T18:10:11.946Z"
    },
    "relationships": {}
  }
}

GET/v1/libraries/:id

Retrieve a library

This endpoint allows you to retrieve a library by providing the library id.

Optional params

  • Name
    include
    Type
    string
    Description

    A comma separated list of related resources to return in the response. The only valid resource to include for libraries is organization.

    See the API Overview guide for more details on usage.

  • Name
    fields
    Type
    array
    Description

    Not applicable for libraries.

    See the API Overview guide for more details on usage.

Request

GET
/v1/libraries/:id
const response = await fetch(
  "https://api.cakeslice.com/v1/libraries/:id",
  {
    headers: {
      "Authorization": `Bearer ${token}`
    }
  }
)

await response.json()

Response

{
  "data": {
    "id": "abc-def-123",
    "type": "library",
    "attributes": {
      "name": "ACME Brand Assets",
      "slug": "assets",
      "privacy": "private",
      "organization_id": "abc-def-123",
      "created_at": "2025-01-02T21:59:53.475Z",
      "updated_at": "2025-03-17T18:10:11.946Z"
    },
    "relationships": {}
  }
}

PUT/v1/libraries/:id

Update a library

This endpoint allows you to perform an update on a library. Examples of updates are changing the name, slug, and privacy settings of the library.

Optional attributes

  • Name
    name
    Type
    string
    Description

    The name for the library.

  • Name
    slug
    Type
    string
    Description

    The vanity url path for the library.

  • Name
    privacy
    Type
    enum
    Description

    The privacy setting of the library.

    Can be one of public, private, or stealth.

Optional params

  • Name
    include
    Type
    string
    Description

    A comma separated list of related resources to return in the response. The only valid resource to include for libraries is organization.

    See the API Overview guide for more details on usage.

  • Name
    fields
    Type
    array
    Description

    Not applicable for libraries.

    See the API Overview guide for more details on usage.

Request

POST
/v1/libraries/:library_id/attachments
const response = await fetch(
  "https://api.cakeslice.com/v1/libraries/:library_id/attachments",
  {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${token}`
    },
    body: JSON.stringify({
      data: {
        attributes: {
          filename: "cake.png"
        }
      }
    })
  }
)

await response.json()

Response

{
  "id": "abc-def-123",
  "type": "attachment",
  "attributes": {
    "filename": "cake.png",
    "height": 1024,
    "width": 512,
    "size": 561744,
    "mimetype": "image/png",
    "tags": [
      "ai",
      "dessert"
    ],
    "caption": "a slice of cake with a cherry on top",
    "description": "The image features a slice of cake with a cherry on top, placed on a white plate. The cake is white and appears to be a delicious dessert. The plate is positioned on a dining table, which occupies the majority of the scene. The close-up view of the cake slice and cherry creates a mouth-watering visual, inviting the viewer to indulge in a sweet treat.",
    "state": "previewable",
    "library_id": "abc-def-123",
    "created_at": "2025-02-09T21:20:58.501Z",
    "updated_at": "2025-02-14T20:11:46.591Z"
  },
  "relationships": {}
}

DELETE/v1/libraries/:id

Delete a library

This endpoint allows you to delete libraries. Note: This will permanently delete the library, including its attachments.

Request

DELETE
/v1/libraries/:id
const response = await fetch(
  "https://api.cakeslice.com/v1/libraries/:id",
  {
    method: "DELETE",
    headers: {
      "Authorization": `Bearer ${token}`
    }
  }
)

await response.json()

Response

No Content