Media Management

The media management API allow you to manage items within the media library.


The Media Resource

Properties

  • Name
    id
    Required
    Type
    integer
    Description

    Unique identifier for the media record.

  • Name
    title
    Required
    Type
    string
    Description

    A title or name for the media item

  • Name
    description
    Required
    Type
    string
    Description

    A description for the media.

  • Name
    media
    Required
    Type
    object
    Description
    • Name
      type
      Required
      Type
      string
      Description

      The type of media this is

    • Name
      value
      Required
      Type
      string
      Description

      The pointer towards the media. For example, if type is a youtube video, value would be the youtube URL.

  • Name
    dates
    Required
    Type
    DateCollection
    Description
    • Name
      created_at
      Required
      Type
      datetime
      Description

      The date the media item was created, represented in YYYY-MM-DD HH:MM:SS format

    • Name
      updated_at
      Required
      Type
      datetime
      Description

      The date the media item was last updated, represented in YYYY-MM-DD HH:MM:SS format

    • Name
      deleted_at
      Required
      Type
      null | datetime
      Description

      The date the media item was deleted, represented in YYYY-MM-DD HH:MM:SS format. If the record is not deleted, this will be null

Media Resource

{
  "id": 1,
  "title": "GAP Explainer",
  "description": "Explains what the GAP insurance product is",
  "media": {
    "type": "youtube",
    "value": "https://youtube.com/12345"
  },
  "dates": {
    "created_at": "2024-01-01 00:00:00",
    "updated_at": "2024-01-02 12:00:00",
    "deleted_at": null,
  }
}

GET/v2/media

Search Media

The search media endpoint uses the standard Search package from the SDK.

An array of Media 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 item by ID

  • Name
    filters.id.in
    Required
    Type
    array<integer>
    Description

    Match media items by multiple IDs

  • Name
    filters.title.contains
    Required
    Type
    string
    Description

    Match media records by a title partial

  • Name
    filters.type.equals
    Required
    Type
    string
    Description

    Match a media record by its type

  • Name
    filters.type.in
    Required
    Type
    array<string>
    Description

    Match media items by multiple types

  • Name
    filters.created_at.before_or_on
    Required
    Type
    datetime
    Description

    Match all media items that were created before or on this datetime.

  • Name
    filters.created_at.after_or_on
    Required
    Type
    datetime
    Description

    Match all media items that were created after or on this datetime.

  • Name
    filters.updated_at.before_or_on
    Required
    Type
    datetime
    Description

    Match all media items that were last updated before or on this datetime.

  • Name
    filters.updated_at.after_or_on
    Required
    Type
    datetime
    Description

    Match all media 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 items from results, provide true. If you only non-deleted media items, provide false

Search Ordering

  • id
  • title
  • type
  • created_at
  • updated_at
  • deleted_at

Request

GET
/v2/media
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()
  ->search($search);

Response

{
  "data": [
    {
      "id": 1,
      "title": "GAP Explainer",
      "description": "Explains what the GAP insurance product is",
      "media": {
        "type": "youtube",
        "value": "https://youtube.com/12345"
      },
      "dates": {
        "created_at": "2024-01-01 00:00:00",
        "updated_at": "2024-01-02 12:00:00",
        "deleted_at": null,
      }
    }
  ]
}

POST/v2/media

Create Media

Will attempt to create a new media item

Payload

  • Name
    title
    Required
    required
    Type
    string
    Description

    The title of the media item

  • Name
    description
    Required
    required
    Type
    string
    Description

    The description for this media item

  • Name
    type
    Required
    Type
    string
    Description

    The type of media

  • Name
    value
    Required
    Type
    string
    Description

    The value of this media type - for example, if type is a Youtube video, the value will be the URL to the video.

Error Codes

Status Description
422 The data provided in the payload was invalid. See errors for more details.

Request

POST
/v2/media
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->media()
  ->create(
    'GAP Explainer',
    'Video to explain what GAP insurance is',
    'youtube',
    'https://www.youtube.com/12345'
  );

Response

{
  "data": {
    "id": 1,
    "title": "GAP Explainer",
    "description": "Video to explain what GAP insurance is",
    "media": {
      "type": "youtube",
      "value": "https://www.youtube.com/12345"
    },
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": null,
    }
  }
}

GET/v2/media/:media_id

Retrieve Media

Will retrieve a single media item by ID

URL Parameters

  • Name
    media_id
    Required
    required
    Type
    integer
    Description

    ID of the media to retrieve

Error Codes

Status Description
404 The requested media could not be found.

Request

GET
/v2/media/:media_id
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->media(1)
  ->get();

Response

{
  "data": {
    "id": 1,
    "title": "GAP Explainer",
    "description": "Explains what the GAP insurance product is",
    "media": {
      "type": "youtube",
      "value": "https://youtube.com/12345"
    },
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": null,
    }
  }
}

PUT/v2/media/:media_id

Update Media

Will attempt to update the media item by ID.

Only values provided in the request payload will be updated.

URL Parameters

  • Name
    media_id
    Required
    required
    Type
    integer
    Description

    ID of the media item to update

Payload

  • Name
    title
    Required
    Type
    string
    Description

    The new title for the media item

  • Name
    description
    Required
    Type
    string
    Description

    The new description for the media item

Error Codes

Status Description
404 The requested media could not be found.
422 The data provided in the payload was invalid. See errors for more details.

Request

PUT
/v2/media/:media_id
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->media(1)
  ->update([
    'title' => 'New Title',
    'description' => 'New description',
  ]);

Response

{
  "data": {
    "id": 1,
    "title": "New Title",
    "description": "New description",
    "media": {
      "type": "youtube",
      "value": "https://youtube.com/12345"
    },
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": null,
    }
  }
}

DELETE/v2/media/:media_id

Delete Media

Will attempt to delete the media item. This endpoint will only affect non-deleted media.

The API will return a successful response if the media is already deleted, but won't update the deleted_at timestamp.

URL Parameters

  • Name
    media_id
    Required
    required
    Type
    integer
    Description

    ID of the media to delete

Error Codes

Status Description
404 The requested media could not be found.

Request

DELETE
/v2/media/:media_id
use Compliance\Sdk\ApexV3\Contracts\ApexV3SdkInterface;
use Compliance\Sdk\Authentication\Types\Machine;

private ApexV3SdkInterface $sdk;

$response = $this->sdk
  ->v2(new Machine())
  ->media(1)
  ->delete();

Response

{
  "data": {
    "id": 1,
    "title": "GAP Explainer",
    "description": "Explains what the GAP insurance product is",
    "media": {
      "type": "youtube",
      "value": "https://youtube.com/12345"
    },
    "dates": {
      "created_at": "2024-01-01 00:00:00",
      "updated_at": "2024-01-02 12:00:00",
      "deleted_at": "2024-01-03 00:00:00"
    }
  }
}