# API: Duration Parameter In Update User Presense Status

**URL:** <https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280>\
**Category:** API and Webhooks\
**Created:** [August 31, 2023, 4:03pm UTC](https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280 "2023-08-31T16:03:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amushtaq](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amushtaq/32/51326_2.png) [@amushtaq](https://devforum.zoom.us/u/amushtaq)\
**Post date:** [August 31, 2023, 4:03pm UTC](https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280/1 "2023-08-31T16:03:12Z")

</div>

I’ve tested several scenarios, and unfortunately, changing the status to “Away” doesn’t revert the user’s status to “Available” after the set time expires.  
Interestingly, when I switch the status to “Do Not Disturb,” the presence status does return to “Available” after the designated time lapses.

Why is that?

```
SetMemberPresenceStatus(Member, " Do_Not_Disturb",20);

SetMemberPresenceStatus(Member, " Away",20);

```

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [September 5, 2023, 8:12pm UTC](https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280/2 "2023-09-05T20:12:13Z")

</div>

Hi @amushtaq  
Thanks for reaching out to us!  
Have you been able to troubleshoot this on your end?  
Also could you please share with me the workflow you are following so I can try and replicate this on my end?

---

<div class="post-metadata">

**Author:** ![amushtaq](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/amushtaq/32/51326_2.png) [@amushtaq](https://devforum.zoom.us/u/amushtaq)\
**Post date:** [September 6, 2023, 10:41am UTC](https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280/3 "2023-09-06T10:41:01Z")

</div>

Hi Elisa,

Thank you for your response. To provide some context, we operate a C# service that runs daily and automatically marks users as “Away” if they have a holiday booked in our HR system. However, during testing, we discovered that once a user’s status is set to “away,” they are not automatically switched back to “online” when the designated time period has elapsed.

I also tested the same code and marked the status to ''Do\_Not\_Disturb", in that case the user was set back to online when the timer period elapsed.

code :

```
	public async Task Invoke()
	{
		AppLog.Instance.Write("UpdatePresenceStatus Job Started");
		_settings ??= await _sqlDal.GetZoomSetting();

		List<Holiday> holidays = await _sqlDal.GetHolidayRelations();
	
		DateTime targetDate = new DateTime(2023, 9, 5);

		try
		{
		
				if (holidays.Count()>0)
				{
					foreach (var item in holidays)
					{
						SetMemberPresenceStatus(item, "Away", 1000);
					}
				}
		
			

		}
		catch (Exception exception)
		{

			AppLog.Instance.WriteError(exception.Message, exception.InnerException);
		}

	}

	public async Task<bool> SetMemberPresenceStatus(Holiday member, string presenceStatus,int duration)
	{
		_settings ??= await _sqlDal.GetZoomSetting();
		await RefreshAccessToken();

		try
		{
			var handler = new HttpClientHandler();

			using (var client = new HttpClient(new RetryHandler(handler)))
			{
				client.BaseAddress = new Uri("https://api.zoom.us/");
				client.DefaultRequestHeaders.Clear();
				client.DefaultRequestHeaders.Authorization =
					new AuthenticationHeaderValue("Bearer", _settings.AccessToken);
				client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

				var endpoint = $"v2/users/{member.Email}/presence_status";

				// Create the JSON body
				var jsonBody = new
				{
					duration = duration,
					status = presenceStatus
				};

				var jsonContent = new StringContent(JsonConvert.SerializeObject(jsonBody), Encoding.UTF8, "application/json");

				var response = await client.PutAsync(endpoint, jsonContent);

				if (!response.IsSuccessStatusCode)
				{
					var errorMessage = await response.Content.ReadAsStringAsync();
					AppLog.Instance.Warn($"Code: {response.StatusCode}, Reason: {response.ReasonPhrase}");
					AppLog.Instance.WriteError($"Error Response: {errorMessage}");
					return false;
				}

				return true;
			}
		}
		catch (Exception exception)
		{

			AppLog.Instance.WriteError(exception.Message, exception.InnerException);
			return false;
		}
	}

```

I am happy to get on a screen share session and show you the use case using our IDE.

Thanks for your hlep,  
Ajwad

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [September 18, 2023, 8:31pm UTC](https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280/4 "2023-09-18T20:31:25Z")

</div>

Hi @amushtaq  
Thanks for your patience here, I just did some testing on my end and it looks like the duration field is only valid when using the status “Do\_Not\_Disturb” that is why when you pass the status Away with a duration field, it does not change anything on your end

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [September 21, 2024, 12:08pm UTC](https://devforum.zoom.us/t/api-duration-parameter-in-update-user-presense-status/94280/5 "2024-09-21T12:08:00Z")

</div>

Closed on September 21, 2024, 12:08pm UTC

This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.
