Documentation

DeveloperKey extends AbstractBaseApi
in package

Canvas Developer Keys API

Manages Canvas API keys used for OAuth access. This API handles both Canvas API keys and LTI 1.3 registrations, though this implementation focuses on Canvas API keys.

Developer Keys follow Account-as-default context pattern:

  • Direct calls use Account context from Config::getAccountId()
  • Mixed endpoint routing: CREATE/LIST use account context, UPDATE/DELETE use direct ID
Tags
see
https://canvas.instructure.com/doc/api/developer_keys.html

Table of Contents

Constants

AUDIENCE_EXTERNAL  = 'external'
AUDIENCE_INTERNAL  = 'internal'
STATE_ACTIVE  = 'active'
STATE_DELETED  = 'deleted'
STATE_INACTIVE  = 'inactive'

Properties

$accessTokenCount  : int|null
$accountName  : string|null
$allowIncludes  : bool|null
$apiKey  : string|null
$clientCredentialsAudience  : string|null
$createdAt  : string|null
$email  : string|null
$iconUrl  : string|null
$id  : int|null
$isLtiKey  : bool|null
$isLtiRegistration  : bool|null
$lastUsedAt  : string|null
$ltiRegistration  : array<string, mixed>|null
$name  : string|null
$notes  : string|null
$publicJwk  : array<string, mixed>|null
$publicJwkUrl  : string|null
$redirectUri  : string|null
$redirectUris  : array<string|int, string>|null
$requireScopes  : bool|null
$scopes  : array<string|int, string>|null
$testClusterOnly  : bool|null
$toolConfiguration  : array<string, mixed>|null
$updatedAt  : string|null
$userId  : string|null
$userName  : string|null
$vendorCode  : string|null
$visible  : bool|null
$workflowState  : string|null
$apiClient  : HttpClientInterface
$methodAliases  : array<string|int, mixed>
Define method aliases

Methods

__callStatic()  : mixed
Magic method to handle function aliases
__construct()  : mixed
BaseApi constructor.
all()  : array<string|int, static>
Get all pages of results
allowsIncludes()  : bool
Check if key allows includes parameters
create()  : self
Create a new developer key Uses account-scoped endpoint: POST /api/v1/accounts/:account_id/developer_keys
delete()  : array<string, mixed>
Delete a developer key Uses direct ID endpoint: DELETE /api/v1/developer_keys/:id
find()  : self
Find a developer key by ID Note: Canvas doesn't have a direct GET endpoint for individual developer keys This method fetches all keys and filters by ID
get()  : array<string|int, self>
Get all developer keys using account context Uses account-scoped endpoint: GET /api/v1/accounts/:account_id/developer_keys
getClientCredentialsAudienceDisplay()  : string|null
Get client credentials audience display name
getPaginated()  : PaginatedResponse
Get paginated developer keys
getRedirectUrisString()  : string|null
Get redirect URIs as comma-separated string
getScopesString()  : string|null
Get scopes as comma-separated string
getWithInherited()  : array<string|int, self>
Get developer keys with inherited keys from Site Admin
isActive()  : bool
Check if this developer key is active
isApiKey()  : bool
Check if this is a Canvas API key (vs LTI key)
isDeleted()  : bool
Check if this developer key is deleted
isInactive()  : bool
Check if this developer key is inactive
isLti()  : bool
Check if this is an LTI key (vs Canvas API key)
isTestClusterOnly()  : bool
Check if key is restricted to test cluster only
paginate()  : PaginationResult
Get paginated results with metadata
remove()  : array<string, mixed>
Delete this developer key instance
requiresScopes()  : bool
Check if key requires scopes in token requests
save()  : self
Update this developer key instance
setApiClient()  : void
Set the API client
update()  : self
Update an existing developer key Uses direct ID endpoint: PUT /api/v1/developer_keys/:id
castValue()  : DateTime|mixed
Cast a value to the correct type
checkApiClient()  : void
Check if the API client is set, if not, instantiate a new one
convertPaginatedResponseToModels()  : array<string|int, static>
Helper method to convert paginated response data to model instances
createConfiguredHttpClient()  : HttpClient
Create an HttpClient with configured middleware
createPaginationResult()  : PaginationResult
Helper method to create PaginationResult from paginated response
getEndpoint()  : string
Get the base endpoint for account-scoped operations (CREATE/LIST)
getPaginatedResponse()  : PaginatedResponse
Helper method to get paginated response from API endpoint
populate()  : void
Populate the object with new data
toDtoArray()  : array<string|int, mixed>
Convert the object to an array

Constants

AUDIENCE_EXTERNAL

public mixed AUDIENCE_EXTERNAL = 'external'

AUDIENCE_INTERNAL

public mixed AUDIENCE_INTERNAL = 'internal'

Properties

$accessTokenCount

public int|null $accessTokenCount = null

$clientCredentialsAudience

public string|null $clientCredentialsAudience = null

$isLtiRegistration

public bool|null $isLtiRegistration = null

$ltiRegistration

public array<string, mixed>|null $ltiRegistration = null

$publicJwk

public array<string, mixed>|null $publicJwk = null

$redirectUris

public array<string|int, string>|null $redirectUris = null

$scopes

public array<string|int, string>|null $scopes = null

$testClusterOnly

public bool|null $testClusterOnly = null

$toolConfiguration

public array<string, mixed>|null $toolConfiguration = null

$methodAliases

Define method aliases

protected static array<string|int, mixed> $methodAliases = ['get' => ['fetch', 'list', 'fetchAll'], 'all' => ['fetchAllPages', 'getAll'], 'paginate' => ['getPaginated', 'withPagination', 'fetchPage'], 'find' => ['one', 'getOne']]

Methods

__callStatic()

Magic method to handle function aliases

public static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string
$arguments : array<string|int, mixed>
Tags
throws
InvalidArgumentException

__construct()

BaseApi constructor.

public __construct(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>

all()

Get all pages of results

public static all([array<string, mixed> $params = [] ]) : array<string|int, static>
Parameters
$params : array<string, mixed> = []

Query parameters

Return values
array<string|int, static>

allowsIncludes()

Check if key allows includes parameters

public allowsIncludes() : bool
Return values
bool

create()

Create a new developer key Uses account-scoped endpoint: POST /api/v1/accounts/:account_id/developer_keys

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

Developer key creation data

Tags
throws
CanvasApiException

If creation fails

Return values
self

The created DeveloperKey instance

delete()

Delete a developer key Uses direct ID endpoint: DELETE /api/v1/developer_keys/:id

public static delete(int $id) : array<string, mixed>
Parameters
$id : int

The developer key ID

Tags
throws
CanvasApiException

If deletion fails

Return values
array<string, mixed>

The deleted developer key data

find()

Find a developer key by ID Note: Canvas doesn't have a direct GET endpoint for individual developer keys This method fetches all keys and filters by ID

public static find(int $id[, array<string|int, mixed> $params = [] ]) : self
Parameters
$id : int

The developer key ID

$params : array<string|int, mixed> = []

Optional query parameters

Tags
throws
CanvasApiException

If key not found

Return values
self

The DeveloperKey instance

get()

Get all developer keys using account context Uses account-scoped endpoint: GET /api/v1/accounts/:account_id/developer_keys

public static get([array<string, mixed> $params = [] ]) : array<string|int, self>
Parameters
$params : array<string, mixed> = []

Query parameters (e.g., 'inherited' => true)

Return values
array<string|int, self>

Array of DeveloperKey instances

getClientCredentialsAudienceDisplay()

Get client credentials audience display name

public getClientCredentialsAudienceDisplay() : string|null
Return values
string|null

getPaginated()

Get paginated developer keys

public static getPaginated([array<string, mixed> $params = [] ]) : PaginatedResponse
Parameters
$params : array<string, mixed> = []

Query parameters

Return values
PaginatedResponse

getRedirectUrisString()

Get redirect URIs as comma-separated string

public getRedirectUrisString() : string|null
Return values
string|null

getScopesString()

Get scopes as comma-separated string

public getScopesString() : string|null
Return values
string|null

getWithInherited()

Get developer keys with inherited keys from Site Admin

public static getWithInherited() : array<string|int, self>
Return values
array<string|int, self>

Array of DeveloperKey instances including inherited keys

isActive()

Check if this developer key is active

public isActive() : bool
Return values
bool

isApiKey()

Check if this is a Canvas API key (vs LTI key)

public isApiKey() : bool
Return values
bool

isDeleted()

Check if this developer key is deleted

public isDeleted() : bool
Return values
bool

isInactive()

Check if this developer key is inactive

public isInactive() : bool
Return values
bool

isLti()

Check if this is an LTI key (vs Canvas API key)

public isLti() : bool
Return values
bool

isTestClusterOnly()

Check if key is restricted to test cluster only

public isTestClusterOnly() : bool
Return values
bool

remove()

Delete this developer key instance

public remove() : array<string, mixed>
Tags
throws
CanvasApiException

If key has no ID

Return values
array<string, mixed>

The deleted developer key data

requiresScopes()

Check if key requires scopes in token requests

public requiresScopes() : bool
Return values
bool

update()

Update an existing developer key Uses direct ID endpoint: PUT /api/v1/developer_keys/:id

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

The developer key ID

$data : array<string, mixed>|UpdateDeveloperKeyDTO

Update data

Tags
throws
CanvasApiException

If update fails

Return values
self

The updated DeveloperKey instance

castValue()

Cast a value to the correct type

protected castValue(string $key, mixed $value) : DateTime|mixed
Parameters
$key : string
$value : mixed
Tags
throws
Exception
Return values
DateTime|mixed

checkApiClient()

Check if the API client is set, if not, instantiate a new one

protected static checkApiClient() : void

convertPaginatedResponseToModels()

Helper method to convert paginated response data to model instances

protected static convertPaginatedResponseToModels(PaginatedResponse $paginatedResponse) : array<string|int, static>
Parameters
$paginatedResponse : PaginatedResponse
Return values
array<string|int, static>

getEndpoint()

Get the base endpoint for account-scoped operations (CREATE/LIST)

protected static getEndpoint() : string
Return values
string

The API endpoint

getPaginatedResponse()

Helper method to get paginated response from API endpoint

protected static getPaginatedResponse(string $endpoint[, array<string|int, mixed> $params = [] ]) : PaginatedResponse
Parameters
$endpoint : string

The API endpoint path

$params : array<string|int, mixed> = []

Query parameters for the request

Return values
PaginatedResponse

populate()

Populate the object with new data

protected populate(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Tags
throws
Exception

toDtoArray()

Convert the object to an array

protected toDtoArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results