Media Assignment Management
The media assignment management API allow you to decide what resources an item from the media library is attached to.
The Media Assignment Resource
Properties
- Name
id
- Required
- Type
- integer
- Description
Unique identifier for the assignment record.
- Name
media_id
- Required
- Type
- integer
- Description
The ID of the media item this assignment belongs to
- Name
require_confirmation
- Required
- Type
- boolean
- Description
Indicates that a physical checkbox is required to be ticked by the user to indicate they've consumed the media.
- Name
restrictions
- Required
- Type
- object
- Description
- Name
dealer_id
- Required
- Type
- integer | null
- Description
The dealer ID the media is attached to, or null if not attached at a dealer level
- Name
group_id
- Required
- Type
- integer | null
- Description
The group ID the media is attached to, or null if not attached at a group level
- Name
supplier_id
- Required
- Type
- integer | null
- Description
The supplier ID the media is attached to, or null if not attached at a supplier level
- Name
resource_id
- Required
- Type
- integer | null
- Description
The specific resource this media is attached to, or null if not applied to an singular resource
- Name
resource_type
- Required
- Type
- string
- Description
The resource this media is attached to. Can be either
gi
,finance
ornip
- Name
dates
- Required
- Type
- DateCollection
- Description
- Name
live_at
- Required
- Type
- datetime | null
- Description
The datetime that this media value goes live at. It shouldn't be displayed prior to this time. If null is returned, this media item is not live and should not be displayed.
- Name
created_at
- Required
- Type
- datetime
- Description
The date the media assignment record was created, represented in
YYYY-MM-DD HH:MM:SS
format
- Name
updated_at
- Required
- Type
- datetime
- Description
The date the media assignment record was last updated, represented in
YYYY-MM-DD HH:MM:SS
format
- Name
deleted_at
- Required
- Type
- null | datetime
- Description
The date the media assignment record was deleted, represented in
YYYY-MM-DD HH:MM:SS
format. If the record is not deleted, this will benull
Media Assignment Resource
{
"id": 1,
"media_id": 2,
"require_confirmation": true,
"restrictions": {
"dealer_id": 12935,
"group_id": null,
"supplier_id": 2,
"resource_id": 54,
"resource_type": "gi"
},
"dates": {
"live_at": "2025-01-01 00:00:00",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00",
"deleted_at": null
}
}
Search Media Assignments
The search media assignments endpoint uses the standard Search package from the SDK.
An array of Media assignment resources are returned. If no results are found, an empty collection is returned.
Search Filters
- Name
filters.id.equals
- Required
- Type
- integer
- Description
Match a single media assignment item by ID
- Name
filters.id.in
- Required
- Type
- array<integer>
- Description
Match media assignment items by multiple IDs
- Name
filters.media_id.equals
- Required
- Type
- integer
- Description
Match media assignment items by media ID
- Name
filters.media_id.in
- Required
- Type
- array<integer>
- Description
Match media assignment items by multiple media IDs
- Name
filters.dealer_id.equals
- Required
- Type
- integer
- Description
Match media assignment item by dealer ID
- Name
filters.dealer_id.in
- Required
- Type
- array<integer>
- Description
Match media assignment items by multiple dealer IDs
- Name
filters.group_id.equals
- Required
- Type
- integer
- Description
Match media assignment item by group ID
- Name
filters.group_id.in
- Required
- Type
- array<integer>
- Description
Match media assignment items by multiple group IDs
- Name
filters.supplier_id.equals
- Required
- Type
- integer
- Description
Match media assignment item by supplier ID
- Name
filters.supplier_id.in
- Required
- Type
- array<integer>
- Description
Match media assignment items by multiple supplier IDs
- Name
filters.resource.equals
- Required
- Type
- integer
- Description
Match media assignment item by resource. Resources should be provided in the following structure:
<resource_type>:<resource_id>
For example, to find records for a GI product with ID 321, you should providegi:321
- Name
filters.resource.in
- Required
- Type
- array<string>
- Description
Match media assignment items by multiple resources.
- Name
filters.is_live.equals
- Required
- Type
- boolean
- Description
Match media assignment items by whether they're live or not
- Name
filters.created_at.before_or_on
- Required
- Type
- datetime
- Description
Match all media assignment items that were created before or on this datetime.
- Name
filters.created_at.after_or_on
- Required
- Type
- datetime
- Description
Match all media assignment items that were created after or on this datetime.
- Name
filters.updated_at.before_or_on
- Required
- Type
- datetime
- Description
Match all media assignment items that were last updated before or on this datetime.
- Name
filters.updated_at.after_or_on
- Required
- Type
- datetime
- Description
Match all media assignment items that were last updated after or on this datetime.
- Name
filters.deleted_at.equals
- Required
- Type
- boolean
- Description
If you want to only deleted media assignment items from results, provide
true
. If you only non-deleted media assignment items, providefalse
Search Ordering
- id
- require_confirmation
- media_id
- dealer_id
- group_id
- supplier_id
- resource_id
- resource_type
- live_at
- created_at
- updated_at
- deleted_at
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
use Compliance\Sdk\Search\Search;
private ApexV3SdkInterface $sdk;
$search = new Search();
$response = $this->sdk
->v2(new Machine())
->media()
->assignments()
->search($search);
Response
{
"data": [
{
"id": 1,
"media_id": 2,
"require_confirmation": true,
"restrictions": {
"dealer_id": 12935,
"group_id": null,
"supplier_id": 2,
"resource_id": 54,
"resource_type": "gi"
},
"dates": {
"live_at": "2025-01-01 00:00:00",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00",
"deleted_at": null
}
}
]
}
Create Media Assignment
Will attempt to assign a media item.
dealer_id
or group_id
is required, and both cannot be provided. Media attached to a specific dealer will take priority over media attached to a groupPayload
- Name
media_id
- Required
- required
- Type
- integer
- Description
ID of the media to assign
- Name
require_confirmation
- Required
- Type
- boolean
- Description
Require users to tick a confirmation box. Defaults to
false
.
- Name
dealer_id
- Required
- Type
- integer | null
- Description
ID of the dealer to assign this item to. Required without
group_id
- Name
group_id
- Required
- Type
- integer | null
- Description
ID of the group to assign this item to. Note Assigning to a group will not set the dealer ID. Required without
dealer_id
- Name
supplier_id
- Required
- Type
- integer | null
- Description
ID of the supplier (GI or Finance) to assign this item to
- Name
resource
- Required
- required
- Type
- string
- Description
Resource to attach this item to. For resources with IDs, such as insurance products, it should be provided in the format
<type>:<id>
. If no ID is required, it should be provided as just the type. For example,gi:123
,finance:53112
,partex
- Name
live_at
- Required
- Type
- datetime | null
- Description
The datetime that the media should go live after. If you don't want this to be set live, set this this value to null
Error Codes
Status | Description |
---|---|
422 | The data provided in the payload was invalid. See errors for more details. |
409 | If dealer_id and group_id are both provided |
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
->v2(new Machine())
->media()
->assignments()
->create(
1, // Media ID
2, // Dealer ID
null, // Group ID
123, // Supplier ID
'gi:32',
'2025-01-01 00:00:00',
true, // Requires Confirmation (Defaults to false)
);
Response
{
"id": 1,
"media_id": 1,
"require_confirmation": true,
"restrictions": {
"dealer_id": 2,
"group_id": null,
"supplier_id": 123,
"resource_id": 32,
"resource_type": "gi"
},
"dates": {
"live_at": "2025-01-01 00:00:00",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00",
"deleted_at": null
}
}
Retrieve Assignment
Will retrieve a single media assignment item by ID
URL Parameters
- Name
assignment_id
- Required
- required
- Type
- integer
- Description
ID of the media assignment to retrieve
Error Codes
Status | Description |
---|---|
404 | The requested media assignment could not be found. |
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
->v2(new Machine())
->media()
->assignments(1)
->get();
Response
{
"data": {
"id": 1,
"media_id": 2,
"require_confirmation": true,
"restrictions": {
"dealer_id": 12935,
"group_id": null,
"supplier_id": 2,
"resource_id": 54,
"resource_type": "gi"
},
"dates": {
"live_at": "2025-01-01 00:00:00",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00",
"deleted_at": null
}
}
}
Update Media Assignment
Will attempt to update the media assignment item by ID.
Only values provided in the request payload will be updated.
URL Parameters
- Name
assignment_id
- Required
- required
- Type
- integer
- Description
ID of the media assignment item to update
Payload
- Name
live_at
- Required
- Type
- datetime | null
- Description
The date the media should go live, or null to hide
- Name
require_confirmation
- Required
- Type
- boolean
- Description
Requires the user to tick a confirmtion box to indicate they've consumed the media
Error Codes
Status | Description |
---|---|
404 | The requested media assignment could not be found. |
422 | The data provided in the payload was invalid. See errors for more details. |
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
->v2(new Machine())
->media()
->assignments(1)
->update([
'live_at' => '2025-02-01 00:00:00',
'require_confirmation': true,
]);
Response
{
"data": {
"id": 1,
"media_id": 2,
"require_confirmation": true,
"restrictions": {
"dealer_id": 12935,
"group_id": null,
"supplier_id": 2,
"resource_id": 54,
"resource_type": "gi"
},
"dates": {
"live_at": "2025-01-01 00:00:00",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00",
"deleted_at": null
}
}
}
Delete Media Assignment
Will attempt to delete the media assignment item. This endpoint will only affect non-deleted assignments.
The API will return a successful response if the assignment is already deleted, but won't update the deleted_at
timestamp.
URL Parameters
- Name
assignment_id
- Required
- required
- Type
- integer
- Description
ID of the media assignment to delete
Error Codes
Status | Description |
---|---|
404 | The requested media assignment could not be found. |
Request
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;
private ApexV3SdkInterface $sdk;
$response = $this->sdk
->v2(new Machine())
->media()
->assignments(1)
->delete();
Response
{
"data": {
"id": 1,
"media_id": 2,
"require_confirmation": true,
"restrictions": {
"dealer_id": 12935,
"group_id": null,
"supplier_id": 2,
"resource_id": 54,
"resource_type": "gi"
},
"dates": {
"live_at": "2025-01-01 00:00:00",
"created_at": "2025-01-01 00:00:00",
"updated_at": "2025-01-01 00:00:00",
"deleted_at": "2025-02-01 00:00:00"
}
}
}