Documentation

SharedBrandConfig
in package

SharedBrandConfig API

Manage shared brand configurations (themes) that can be reused across multiple accounts. This API allows creating, updating, and deleting shared themes.

Canvas API Documentation: https://canvas.instructure.com/doc/api/shared_brand_configs.html

IMPORTANT LIMITATIONS:

  • Canvas does NOT provide endpoints to list or fetch shared brand configs
  • You must track shared config IDs externally
  • The DELETE endpoint has a different path pattern (no account_id)

Note: This class does not extend AbstractBaseApi because Canvas doesn't provide fetch/list operations for shared brand configs.

Table of Contents

Properties

$accountId  : string|null
The id of the account it should be shared within
$brandConfigMd5  : string|null
MD5 hash of the brand config to share (BrandConfigs are identified by MD5, not numeric id)
$createdAt  : string|null
When this was created
$id  : int|null
The shared brand config identifier
$name  : string|null
The name to share this theme as
$updatedAt  : string|null
When this was last updated

Methods

__construct()  : mixed
Constructor
create()  : self
Create a new shared brand config
delete()  : self
Delete a shared brand config
remove()  : self
Delete this shared brand config (instance method)
toArray()  : array<string, mixed>
Convert the shared brand config to an array
update()  : self
Update an existing shared brand config

Properties

$accountId

The id of the account it should be shared within

public string|null $accountId = null

$brandConfigMd5

MD5 hash of the brand config to share (BrandConfigs are identified by MD5, not numeric id)

public string|null $brandConfigMd5 = null

Methods

__construct()

Constructor

public __construct([array<string, mixed> $data = [] ]) : mixed
Parameters
$data : array<string, mixed> = []

The shared brand config data from Canvas API

create()

Create a new shared brand config

public static create(array<string, mixed>|CreateSharedBrandConfigDTO $data) : self

Creates a SharedBrandConfig which gives the specified brand_config a name and makes it available to other users of this account.

API Endpoint: POST /api/v1/accounts/:account_id/shared_brand_configs

Parameters
$data : array<string, mixed>|CreateSharedBrandConfigDTO

The shared brand config data

Tags
throws
CanvasApiException

If the API request fails

example
$sharedConfig = SharedBrandConfig::create([
    'name' => 'Spring 2024 Theme',
    'brand_config_md5' => 'a1f113321fa024e7a14cb0948597a2a4'
]);
Return values
self

The created SharedBrandConfig object

delete()

Delete a shared brand config

public static delete(int $id) : self

Deletes a SharedBrandConfig, which will unshare it so neither you nor anyone else in your account will see it as an option to pick from.

IMPORTANT: The DELETE endpoint has a different path pattern - it does NOT include the account_id in the path.

API Endpoint: DELETE /api/v1/shared_brand_configs/:id

Parameters
$id : int

The ID of the shared brand config to delete

Tags
throws
CanvasApiException

If the API request fails

example
$deleted = SharedBrandConfig::delete(987);
Return values
self

The deleted SharedBrandConfig object

remove()

Delete this shared brand config (instance method)

public remove() : self

Deletes the current SharedBrandConfig instance.

Tags
throws
CanvasApiException

If the config has no ID or the API request fails

example
$sharedConfig->remove();
Return values
self

The deleted SharedBrandConfig object

toArray()

Convert the shared brand config to an array

public toArray() : array<string, mixed>
Return values
array<string, mixed>

The shared brand config data as an array

update()

Update an existing shared brand config

public static update(int $id, array<string, mixed>|UpdateSharedBrandConfigDTO $data) : self

Updates the specified shared_brand_config with a new name or to point to a new brand_config MD5.

API Endpoint: PUT /api/v1/accounts/:account_id/shared_brand_configs/:id

Parameters
$id : int

The ID of the shared brand config to update

$data : array<string, mixed>|UpdateSharedBrandConfigDTO

The update data

Tags
throws
CanvasApiException

If the API request fails

example
$updated = SharedBrandConfig::update(987, [
    'name' => 'Updated Theme Name'
]);
Return values
self

The updated SharedBrandConfig object


        
On this page

Search results