diff --git a/libvoice/libvoice.h b/libvoice/libvoice.h
index c344235fac49cbbb2210b3dbae30b06864b6dac9..5ac21db8289c4ed7d8660802360a64f0b162f092 100644
--- a/libvoice/libvoice.h
+++ b/libvoice/libvoice.h
@@ -213,6 +213,16 @@ struct codec_capability {
 	} codecs[MAX_CODECS];
 };
 
+// ubus request for set codec
+enum VOICE_CODEC {
+	VOICE_CODEC_G711U,
+	VOICE_CODEC_G711A,
+	VOICE_CODEC_G722,
+	VOICE_CODEC_G723,
+	VOICE_CODEC_G726,
+	VOICE_CODEC_G729,
+};
+
 #define ENABLE_VOICE_DEBUG    0 // Enable/disable voice debug
 #if ENABLE_VOICE_DEBUG
 // log to file
@@ -257,7 +267,7 @@ int voice_connection_close_all(void);
 int voice_connection_conference_start(int line, int connection);
 int voice_connection_conference_stop(int line, int connection);
 int voice_connection_find(int line, int connection);
-
+int voice_connection_set_codec(int line, int connection, enum VOICE_CODEC codec);
 // Line API
 int voice_line_preinit(void);
 int voice_line_init(int has_dect);
diff --git a/line.c b/line.c
index 2272b04fa51aa65ccd38045735af53748d8ce133..e6845e175bb70c4bbb90f3ae3f46801aef00f551 100644
--- a/line.c
+++ b/line.c
@@ -352,6 +352,22 @@ int line_new_connection_by_asterisk(int line, int connection, struct voice_ubus_
 	return res;
 }
 
+//---------------------------------------------------------------------------------------------------
+// Reception of a modify connection request from Asterisk.
+int line_connection_modify_codec_by_asterisk(int line, int connection, enum VOICE_CODEC codec) {
+	int res = 0;
+
+	if (!voice_line_is_ready(line))
+		return -1;
+
+	ENDPT_DBG("%s line: %d, connection: %d, codec: %d\n", __func__, line, connection, codec);
+	pcm_states_dump(__func__, line);
+
+	res = voice_connection_set_codec(line, line, codec);
+
+	return res;
+}
+
 //-------------------------------------------------------------
 // Reception of a close connection request from Asterisk. If
 // line type is Dect we need to relay the requets to the dectmngr.
diff --git a/line.h b/line.h
index 8a420ba7c284e49bf03dba0ee90324836e8dfc0a..a616218e7a714daf08b756b916f2dd1565441d4c 100644
--- a/line.h
+++ b/line.h
@@ -56,6 +56,7 @@ int line_close_connection_by_asterisk(int line, int connection, struct voice_ubu
 int line_release_connection_by_asterisk(int line, int connection, struct voice_ubus_req_t *ubus_req);
 int line_update_connection_by_pbx(int line, int pcm_callid);
 int line_new_connection_by_dect(int line, const char *cid, int pcm, struct voice_ubus_req_t *ubus_req);
+int line_connection_modify_codec_by_asterisk(int line, int connection, enum VOICE_CODEC codec);
 int line_close_connection_by_dect(int line, int pcm, struct voice_ubus_req_t *ubus_req);
 int line_signal(int line, const char *signame, const char *data, struct voice_ubus_req_t *ubus_req);
 void pcm_states_dump(const char* func, int line);
diff --git a/ubus.c b/ubus.c
index 389049d5e4a5d1a0add8a2ae0d610164953fb059..e15d03d7c3d86a4e3f264570d68b5ebc2586bf0a 100644
--- a/ubus.c
+++ b/ubus.c
@@ -39,6 +39,7 @@ enum {
 	CONNECTION_LINE,
 	CONNECTION_ID,
 	CONNECTION_ACTION,
+	CONNECTION_DATA,
 	__CONNECTION_MAX,
 };
 
@@ -139,6 +140,7 @@ static const struct blobmsg_policy request_connection_policy[] = {
 	[CONNECTION_LINE] = { .name = "line", .type = BLOBMSG_TYPE_INT32 },
 	[CONNECTION_ID] = { .name = "id", .type = BLOBMSG_TYPE_INT32 },			// rtp stream connection identifier (unique number generated by asterisk)
 	[CONNECTION_ACTION] = { .name = "action", .type = BLOBMSG_TYPE_STRING },
+	[CONNECTION_DATA] = { .name = "data", .type = BLOBMSG_TYPE_STRING },
 };
 
 static const struct blobmsg_policy request_count_policy[] = {
@@ -550,6 +552,25 @@ static int ubus_request_signal(struct ubus_context *uctx, struct ubus_object *ob
 		return UBUS_STATUS_OK;
 }
 
+// codec data string to codec enum
+static enum VOICE_CODEC codec_string_to_enum(char *data){
+	if (strcmp(data, "ulaw") == 0) {
+		return VOICE_CODEC_G711U;
+	} else if (strcmp(data, "alaw") == 0) {
+		return VOICE_CODEC_G711A;
+	} else if (strcmp(data, "g722") == 0) {
+		return VOICE_CODEC_G722;
+	} else if (strcmp(data, "g723") == 0) {
+		return VOICE_CODEC_G723;
+	} else if (strcmp(data, "g726") == 0) {
+		return VOICE_CODEC_G726;
+	} else if (strcmp(data, "g729") == 0) {
+		return VOICE_CODEC_G729;
+	} else {
+		return VOICE_CODEC_G711A;
+	}
+}
+
 // Reception of ubus call endpt connection '{ "line" : 1 , "id" : 0, "action" : "create" }'
 static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object *obj __attribute__((unused)),
 			  struct ubus_request_data *req, const char *method __attribute__((unused)),
@@ -558,7 +579,7 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object
 	struct blob_attr *keys[__CONNECTION_MAX];
 	struct voice_ubus_req_t ubusReq;
 	int line, id;
-	char *action_str;
+	char *action_str, *data;
 
 	if(blobmsg_parse(request_connection_policy, __CONNECTION_MAX,
 			keys, blob_data(msg), blob_len(msg))) {
@@ -591,6 +612,10 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object
 	ubusReq.reqIn = req;
 
 	action_str = blobmsg_get_string(keys[CONNECTION_ACTION]);
+	data = NULL;
+	if (keys[CONNECTION_DATA]){
+		data = blobmsg_get_string(keys[CONNECTION_DATA]);
+	}
 	ENDPT_DBG("%s() line: %d connection_id: %d action: %s\n", __func__, line, id, action_str);
 	if (strcmp("create", action_str) == 0) {
 		if(line_new_connection_by_asterisk(line, id, &ubusReq))
@@ -610,6 +635,9 @@ static int ubus_request_connection(struct ubus_context *uctx, struct ubus_object
 	} else if (strcmp("update", action_str) == 0) {
 		if(line_update_connection_by_pbx(line, id))
 			return UBUS_STATUS_UNKNOWN_ERROR;
+	} else if (strcmp("set_codec", action_str) == 0) {
+		if(line_connection_modify_codec_by_asterisk(line, id, codec_string_to_enum(data)))
+			return UBUS_STATUS_UNKNOWN_ERROR;
 	} else {
 		ENDPT_DBG("Error! No such action: %s\n", action_str);
 		return UBUS_STATUS_INVALID_ARGUMENT;