Workflow: How to restrict the number of tickets a user can submit within an organization

<p>In Zendesk Support, you can't limit the number of tickets that users submit in your account. However, you can create a custom workflow that uses webhooks to restrict the number of tickets submitted by users within an organization and a specified time frame.</p><p>This workflow uses custom organization fields to monitor the volume of tickets submitted within a designated time frame. The workflow includes the steps below:</p><div style="margin-bottom: 20px; text-align: right;">
<button id="master-toggle" class="btn fw-semibold text-dark" data-action="expand" style="background-color: #DEF991; border: none; outline: none; border-radius: 7px; padding: 10px 20px; font-size: 15px; transition: background-color 0.2s ease;" onmouseover="this.style.backgroundColor='#cbef6d'" onmouseout="this.style.backgroundColor='#DEF991'">
Expand all tabs
</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const toggleBtn = document.getElementById('master-toggle');

toggleBtn.addEventListener('click', function () {
const action = this.getAttribute('data-action');
const headers = document.querySelectorAll('.accordion');

headers.forEach(header => {
const isActive = header.classList.contains('active');
const panel = header.nextElementSibling; // Grabs the corresponding .panel container

if (action === 'expand' && !isActive) {
// Open it by simulating a standard click
header.click();
} else if (action === 'collapse' && isActive) {
// Close it by simulating a standard click
header.click();
}
});

// Flip button text and states
if (action === 'expand') {
this.setAttribute('data-action', 'collapse');
this.textContent = 'Collapse all tabs';
} else {
this.setAttribute('data-action', 'expand');
this.textContent = 'Expand all tabs';
}
});
});
</script><div class="accordion"><h3 id="h_01JDP0WAGSRERVX94KHG4N6VTD">Step 1: Create the numeric organization fields</h3></div><div class="panel">
<p>This workflow uses two custom numeric organization fields to monitor and record the number of tickets submitted by the user.</p>
<p>To create the custom organization fields:</p>
<ol>
<li data-list-item-id="ec6de4cafb2ad5df1e5974e60afd2d2be">
<a href="https://support.zendesk.com/hc/en-us/articles/4408842677786-Adding-custom-fields-to-organizations" target="_blank" rel="noopener noreferrer">Create</a> a custom organization field</li>
<li data-list-item-id="e12bfe02f132a01e10edc3cf0d7f49250">Under <strong>Select field type</strong>, select <strong>Number</strong>
</li>
<li data-list-item-id="ed482f8699fcb3206ef96a9b088ff7923">Under <strong>Display name</strong>, enter <strong>Counter</strong>
</li>
<li data-list-item-id="e1936daa2c78e5db93b7fe9fb53abf0b6">Click the <strong>Save</strong> dropdown arrow and select <strong>Save and add another</strong><br><img class="wysiwyg-image-resized" style="aspect-ratio: 449/241; width: 47.41%;" src="https://support.zendesk.com/hc/article_attachments/8477282152346" alt="Counter ticket field" width="449" height="241">
</li>
<li data-list-item-id="e6ee8b0e22efb595114706e26e6830a90">Under <strong>Select field type</strong>, select <strong>Number</strong>
</li>
<li data-list-item-id="ed06313259728a97761bd109920595afa">Under <strong>Display name</strong>, enter <strong>Counter Last Update Unix</strong> and click <strong>Save</strong>
</li>
</ol>
</div><div class="accordion"><h3 id="h_01JDP0WSN2GTWGA4A8M8NKVZRS">Step 2: Create the webhooks</h3></div><div class="panel">
<p>Create webhooks for the triggers to update the requester's organization and ticket tags.</p>
<p>To create the webhooks:</p>
<ol>
<li data-list-item-id="ebd3f42e30ad90859b9960f3d8a8ab21c">Create the first <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378-Creating-webhooks-to-interact-with-third-party-systems" target="_blank" rel="noopener noreferrer">webhook</a>
</li>
<li data-list-item-id="e024f3b3f29a298a094a141ec54838aaf">Under <strong>Select a way to connect</strong>, select <strong>Trigger or automation</strong> and click <strong>Next</strong>
</li>
<li data-list-item-id="e3b9f6ad2bd155ba38ee8c2bfb6afd87e">Use the below configuration<ul>
<li data-list-item-id="eb15aeb5898a3618485731a718ff5249c">
<strong>Name: </strong>Update org</li>
<li data-list-item-id="e3eed3d1fa06e7b79c4f0369eeeebb2a4">
<strong>Endpoint URL</strong>: <code>https://<em>yoursubdomain</em>.zendesk.com/api/v2/tickets/{{ticket.organization.id}}</code> and replace <code>yoursubdomain</code> with your account subdomain</li>
<li data-list-item-id="ebef26b48a3858e99e597e84f4afae0d4">
<strong>Request</strong> <strong>method</strong>: PUT</li>
<li data-list-item-id="ec353f7e3efd88edee85cded5b7ec2b31">
<strong>Authentication</strong>: Basic authentication</li>
</ul>
</li>
<li data-list-item-id="e52596707f16659ed68187c7cdf83ffa2">Create the second <strong>Trigger or automation</strong> <a href="https://support.zendesk.com/hc/en-us/articles/4408839108378#topic_bwm_1tv_dpb" target="_blank" rel="noopener noreferrer">webhook</a> and click <strong>Next</strong>
</li>
<li data-list-item-id="e83e089ebae0b70ba29fa57af567720f9">Use the below configuration<ul>
<li data-list-item-id="ee85bed76d5e88fcfdf9782bfd4b178ff">
<strong>Name: </strong>Update ticket tags</li>
<li data-list-item-id="e9755c5049d04c056f54c82f9e4d49738">
<strong>Endpoint URL</strong>: <code>https://<em>yoursubdomain</em>.zendesk.com/api/v2/tickets/{{ticket.id}}/tags</code> and replace <code>yoursubdomain</code> with your account subdomain.</li>
<li data-list-item-id="ef3697bbd5bcf1c2807136b24197b989a">
<strong>Request</strong> <strong>method</strong>: PUT</li>
<li data-list-item-id="edea8e1e93d51ca489ecbb62cb197220c">
<p><strong>Authentication</strong>: Basic Authentication</p>
<p>The webhooks should appear similar to the below image.<img src="https://support.zendesk.com/hc/article_attachments/8477312363034" alt="Webhook setup" width="553" height="640"></p>
</li>
</ul>
</li>
</ol>
</div><div class="accordion"><h3 id="h_01JDP0XNGFPJ33X1G4PRV8MG35">Step 3: Create the triggers</h3></div><div class="panel">
<p>Create triggers that verify the requester's ticket count, update the organization fields, and add tags to the ticket.</p>
<p>To create the first trigger:</p>
<ol>
<li data-list-item-id="ecfbe77db37ff09aaa66b12c7488b9d39">
<a href="https://support.zendesk.com/hc/en-us/articles/4408886797466-Creating-triggers-for-automatic-ticket-updates-and-notifications/#topic_qfk_s23_vsb" target="_blank" rel="noopener noreferrer">Create</a> a new trigger</li>
<li data-list-item-id="e39627c532aaa49e2a2581c87bfdd6bc8">Under <strong>Meet ALL of the following conditions</strong>, add <strong>Ticket &gt; Ticket | Is | Created</strong>
</li>
<li data-list-item-id="ee09575055cd6fd65cb03c3d70c468ecd">Under <strong>Meet ANY of the following conditions</strong>, add:<ul>
<li class="wysiwyg-list-bold" data-list-item-id="e4b5e254f48051e3656102f073afd280f"><strong>Organization &gt; Counter | Less than | 5</strong></li>
<li class="wysiwyg-list-bold" data-list-item-id="e3366104d79fb94ef5efa69d92bf7f770"><strong>Organization &gt; Counter | Not present</strong></li>
</ul>
</li>
<li data-list-item-id="ed9950ab18c978b0e3c62d0e45154347f">
<p>Under <strong>Actions</strong>, add <strong>Other</strong> &gt; <strong>Notify by</strong> <strong>&gt; Active webhook &gt; Update org </strong>and in the <strong>JSON body</strong>, add the JSON information below:</p>
<pre class="wysiwyg-code-block"><code class="language-auto">{
"organization": {
"organization_fields": {
"counter": "{{ ticket.organization.custom_fields.counter | plus:'1' }}",
"counter_last_updated_epoch": "{{ 'now' | date: '%s' }}"
}
}
}</code></pre>
</li>
<li data-list-item-id="e4636dde247947758ac0709ff50c625fc">
<p>Click <strong>Create trigger</strong></p>
<p><img src="https://support.zendesk.com/hc/article_attachments/10569919820186" alt="Trigger that updates the counter when a ticket is created" width="1970" height="1911"></p>
</li>
</ol>
<p>To create the second trigger:</p>
<ol>
<li data-list-item-id="e9ddc905946fb9e90f3770fd46f76124c">
<a href="https://support.zendesk.com/hc/en-us/articles/4408886797466-Creating-triggers-for-automatic-ticket-updates-and-notifications/#topic_qfk_s23_vsb" target="_blank" rel="noopener noreferrer">Create</a> a new trigger</li>
<li data-list-item-id="e2cc7c9e7065ef4e62b37aac6b09af1d9">Under <strong>Meet ALL of the following conditions</strong>, add:<ul>
<li class="wysiwyg-list-bold" data-list-item-id="eb308ab0d7c79322831710afafe166ea3"><strong>Ticket &gt; Ticket | Is | Created</strong></li>
<li class="wysiwyg-list-bold" data-list-item-id="e128ccd5da945710c27da418946b06e84"><strong>Organization &gt; Counter | Is | 5</strong></li>
</ul>
</li>
<li data-list-item-id="e20dfd59b979dfffb6eb1b48f40db0da7">
<p>Under <strong>Actions</strong> add <strong>Other &gt; Notify by &gt; Active webhook &gt; Update ticket tags </strong>and in the <strong>JSON body</strong>, add the information below:</p>
<pre class="wysiwyg-code-block"><code class="language-auto">{% assign nowDateSec = "now" | date: "%s" | minus: 0 %}
{% assign modDateSec = ticket.organization.custom_fields.counter_last_updated_epoch | date: "%s" | minus: 0 %}
{% assign result = nowDateSec | minus: modDateSec %}
{
"tags": [
"{% if result &lt; 3600 %}last_ticket_within_1_hour{% else %}last_update_over_1_hour_ago{% endif %}"
]
}</code></pre>
</li>
<li data-list-item-id="efb12c4404f751a5e0647af52e75aa465">
<p>Click <strong>Create trigger</strong></p>
<p><img src="https://support.zendesk.com/hc/article_attachments/10569884337050" alt="Trigger that adds tags to tickets based on timeframe.png" width="1970" height="1749"></p>
</li>
</ol>
<p>To create the third trigger:</p>
<ol>
<li data-list-item-id="e70cc0244a9d50327aa23db7d8a9a0eb0">
<a href="https://support.zendesk.com/hc/en-us/articles/4408886797466-Creating-triggers-for-automatic-ticket-updates-and-notifications/#topic_qfk_s23_vsb" target="_blank" rel="noopener noreferrer">Create</a> a new trigger</li>
<li data-list-item-id="e954c5236396bfed60e7c55bcaeb16bc9">Under <strong>Meet ALL of the following conditions</strong>, add:<ul>
<li class="wysiwyg-list-bold" data-list-item-id="e3da0d90eb5371abc6aa4db0bd28f5ef9"><strong>Ticket &gt; Ticket | Is | Updated</strong></li>
<li data-list-item-id="e3915d3540f10d9971ad8cafb069c3cfd">
<strong>Ticket &gt; Tags &gt; Contains at least one of the following |</strong> <code>last_update_over_1_hour_ago</code>
</li>
</ul>
</li>
<li data-list-item-id="e34df1d46d8534971e55a4af55967cc67">Under <strong>Actions</strong> add:<ul>
<li data-list-item-id="e8fcb5855e63922f70638d448242feba3">
<p><strong>Other &gt; Notify by &gt; Active webhook &gt; Update org </strong>and in the <strong>JSON body</strong>, add the information below:</p>
<pre class="wysiwyg-code-block"><code class="language-auto">{
"organization": {
"organization_fields": {
"counter": 1,
"counter_last_updated_epoch": "{{ 'now' | date: '%s' }}"
}
}
}</code></pre>
</li>
<li data-list-item-id="e1dd6bd8dd92033fadf66f0837b420d2a">
<strong>Ticket &gt; Add tags | </strong><code>last_update_over_1_hour_ago</code>
</li>
</ul>
</li>
<li data-list-item-id="e1c07152e4fccecf999d2576cce3d096e">
<p>Click <strong>Create trigger</strong></p>
<p><img src="https://support.zendesk.com/hc/article_attachments/10569919820314" alt="Trigger that resets the counter to 1.png" width="1970" height="1848"></p>
</li>
</ol>
<p>To create the fourth trigger:</p>
<ol>
<li data-list-item-id="e33c3046f00163d9749803afe476cb968">
<a href="https://support.zendesk.com/hc/en-us/articles/4408886797466-Creating-triggers-for-automatic-ticket-updates-and-notifications/#topic_qfk_s23_vsb" target="_blank" rel="noopener noreferrer">Create</a> a new trigger</li>
<li data-list-item-id="e7ad9a5ea15d4d4a3cc5f9b0e92f766e2">Under <strong>Meet ALL of the following conditions</strong>, add:<ul>
<li class="wysiwyg-list-bold" data-list-item-id="ebea53755144f4aaf72c1f98839b2220f"><strong>Ticket &gt; Ticket | Is | Updated</strong></li>
<li data-list-item-id="e78b388032bf2fcabc56fc816b87cfbf6">
<strong>Ticket &gt; Tags | Contains at least one of the following |</strong> <code>last_ticket_within_1_hour</code>
</li>
<li class="wysiwyg-list-bold" data-list-item-id="e3589cfdb9dc805aa307ca72989d62df8"><strong>Organization &gt; Counter | Is | 5</strong></li>
</ul>
</li>
<li data-list-item-id="e87669dde2ea2183ebf690c25b1953091">
<strong>Actions</strong> add:<ul>
<li class="wysiwyg-list-bold" data-list-item-id="e5a65a755b1986cbc42a52d7cfa7ef9b9"><strong>Ticket &gt; Status category &gt; Closed</strong></li>
<li data-list-item-id="e26acaf1d89468bddc83644a7356327f2">
<strong>Other </strong>&gt;<strong> Notify by &gt; User email</strong> | <strong>Ticket</strong> <strong>&gt; (requester)</strong><br><span class="notetitle"><strong>Note</strong>: It's optional to notify the user to improve the user experience.</span>
</li>
</ul>
</li>
<li data-list-item-id="e0aa925fa60b9b87d8a2cd453fbfc3f63">
<p>Click <strong>Create trigger</strong></p>
<p><img src="https://support.zendesk.com/hc/article_attachments/10569884337178" alt="Trigger that closes the ticket when restriction is reached.png" width="1970" height="1910"></p>
</li>
</ol>
<p>This summary outlines the workflow when users submit a new ticket.</p>
<ol>
<li data-list-item-id="e63300c686702a680db7db0b46f89c98a">Ticket creation:<ul><li data-list-item-id="e2e8263af2b5b19dc71ebb178bc22e95e">When a ticket is created, the workflow updates the ticket counter and timestamp organization fields.</li></ul>
</li>
<li data-list-item-id="eb67ecb6e4b9ac8fcef28e373a098c8a2">Counter evaluation:<ul>
<li data-list-item-id="e23f046a98333542673f6aae0d77fe4d7">If the counter is below the maximum allowed limit, the ticket proceeds through the normal submission process</li>
<li data-list-item-id="e9fb9f4e40a88feeb6b88029ca4bd1825">If the counter reaches its maximum allowed limit, the system checks the last update time to determine if it was submitted within the defined time frame</li>
</ul>
</li>
<li data-list-item-id="e277914c7ae51b6794ac4987a983f3688">Time frame check:<ul>
<li data-list-item-id="e42646ae076985f142dc9bcc7100e7563">If the last update falls outside the specified time frame, the system resets the counter to 1. A new timestamp records the change</li>
<li data-list-item-id="e4e658a3e43378e6971db4198710d6fbb">If the last update is within the time frame, the system will not update the counter or save a new timestamp, and it will close the ticket immediately. User notification is optional.</li>
</ul>
</li>
</ol>
<div class="note">
<span class="notetitle"><strong>Disclaimer</strong>:</span> This article is provided for instructional purposes only. Zendesk does not support or guarantee the code. Post any issues you have in the comments section or try searching for a solution online.</div>
</div>