mediatype.create

Description

object mediatype.create(object/array **mediaTypes**)

This method allows to create new media types.

This method is only available to Super admin user type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Media types to create.

The method accepts media types with the standard media type properties.

Return values

(object) Returns an object containing the IDs of the created media types under the mediatypeids property. The order of the returned IDs matches the order of the passed media types.

Examples

Creating a media type

Create a new e-mail media type.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "mediatype.create",
  4. "params": {
  5. "name": "E-mail",
  6. "type": 0,
  7. "smtp_server": "[email protected]",
  8. "smtp_helo": "company.com",
  9. "smtp_email": "[email protected]",
  10. "content_type": 1
  11. },
  12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  13. "id": 1
  14. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "mediatypeids": [
  5. "7"
  6. ]
  7. },
  8. "id": 1
  9. }

Creating a media type with custom options

Create a new script media type with custom value for number of attempts and interval between them.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "mediatype.create",
  4. "params": {
  5. "type": 1,
  6. "name": "Push notifications",
  7. "exec_path": "push-notification.sh",
  8. "exec_params": "{ALERT.SENDTO}\n{ALERT.SUBJECT}\n{ALERT.MESSAGE}\n",
  9. "maxattempts": "5",
  10. "attempt_interval": "11s"
  11. },
  12. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  13. "id": 1
  14. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "mediatypeids": [
  5. "8"
  6. ]
  7. },
  8. "id": 1
  9. }

Source

CMediaType::create() in ui/include/classes/api/services/CMediaType.php.