Creating an Encryption Task
Function
This API is used to create an encryption task.
Constraints:
-
Only transcoded files are encrypted.
-
A file to be encrypted must be an .m3u8 or .mpd file.
URI
POST /v1/{project_id}/encryptions
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Project ID. For details about how to obtain a project ID, see Obtaining a Project ID. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
No |
String |
User token. The token is obtained by calling the IAM API used to obtain a user token. The token is the value of X-Subject-Token in the response header. |
|
Authorization |
No |
String |
Authentication information. This parameter is mandatory when AK/SK-based authentication is used. |
|
X-Project_Id |
No |
String |
Project ID. This parameter is mandatory when AK/SK-based authentication is used. It is same as the project ID in path parameters. |
|
X-Sdk-Date |
No |
String |
Time when the request is sent. This parameter is mandatory when AK/SK-based authentication is used. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
input |
No |
ObsObjInfo object |
Storage location of an input file |
|
output |
No |
ObsObjInfo object |
Storage location of an output file |
|
encryption |
No |
Encryption object |
Encryption information |
|
user_data |
No |
String |
Custom user data |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
bucket |
Yes |
String |
OBS bucket name |
|
location |
Yes |
String |
Region where an OBS bucket is located. It must be the same as the region where MPC is deployed. |
|
object |
Yes |
String |
File path.
|
|
file_name |
No |
String |
Name of an output file. This parameter is valid only for packaging tasks.
|
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
hls_encrypt |
No |
HlsEncrypt object |
Encryption parameters for HLS videos |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
key |
Yes |
String |
Content encryption key, which is in base64Binary format |
|
url |
Yes |
String |
Address of Key Management Service (KMS) used by the tenant |
|
iv |
No |
String |
Initial vector, which is a random number in base64Binary format |
|
algorithm |
No |
String |
Encryption algorithm. Possible values are:
Default value: AES-128-CTR |
Response Parameters
Status code: 202
|
Parameter |
Type |
Description |
|---|---|---|
|
task_id |
String |
Task ID |
Status code: 400
|
Parameter |
Type |
Description |
|---|---|---|
|
error_code |
String |
Error code |
|
error_msg |
String |
Error description |
Example Requests
POST https://{endpoint}/v1/{project_id}/encryptions
{
"output": {
"bucket": "obs-bucket06",
"location": "region1",
"object": "sswoutput"
},
"input": {
"bucket": "vostest",
"location": "region1",
"object": "vos_video/hls/index.m3u8"
},
"encryption": {
"hls_encrypt": {
"iv": "kadGyMP9MbMkB1IfIKCNaA==",
"key": "NqdGyMP9MbMiB1IfIKCNeQ==",
"url": "xxxxxxx",
"algorithm": "AES-128-CBC"
},
"preview_duration": 2,
"multidrm": {
"emi": 16420,
"content_id": "jjJr6K",
"streaming_mode": "HLS",
"drm_list": [
"PLAYREADY"
],
"encrypt_audio": 0
}
}
}
Example Responses
Status code: 202
Encryption task created successfully.
{
"task_id" : 100211
}
Status code: 400
Failed to create an encryption task.
{
"error_code" : "MPC.10202",
"error_msg" : "Invalid request parameter"
}
Status Codes
|
Status Code |
Description |
|---|---|
|
202 |
Encryption task created successfully. |
|
400 |
Failed to create an encryption task. |
Error Codes
See Error Codes.
Last Article: Encryption APIs
Next Article: Canceling an Encryption Task
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.